How to print multiple .tif files from Visual FoxPro (281380)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 7.0
  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows 5.0a

This article was previously published under Q281380

SUMMARY

FoxPro developers work with a variety of graphics files. One of the more popular graphics file types is the Tagged Image File Format (.tif) file. Because the current FoxPro Report Designer and Image control do not support this image format, developers must use an alternate method to print these files. This article details one such method.

MORE INFORMATION

Kodak Imaging (formally known as "Wang Imaging" and "Eastman Imaging"), which ships with Microsoft Windows 95, Windows 98, and Windows Millennium Edition , can be used to view and print .tif files. This application also exposes an object model that makes Kodak Imaging controllable from Visual FoxPro.

To automate Kodak Imaging to print all the .tif files in a specific directory, follow these steps:
  1. In Visual FoxPro, open a new program, and then save and run the following code:
    *!* START SAMPLE CODE.
    
    PUBLIC goImaging, goImageFile
    LOCAL laTiffArray[1], lcTiffDir, lcTiffFullPath, i
    
    *!* Let user choose a DIR and generate a list of *.TIF files 
    *!* to print using ADIR().
    lcTiffDir = GETDIR(SYS(5) + SYS(2003),"Select *.TIF Directory")
    IF EMPTY(lcTiffDir)
    	MESSAGEBOX("No directory selected. Aborting program.",64,"")
    	RETURN .F.
    ENDIF
    
    CD (lcTiffDir)
    ADIR(laTiffArray,"*.TIF")
    IF TYPE("laTiffArray") = "L"
    	MESSAGEBOX("There are no *.TIF files in the  selected directory. Aborting program.",64,"")
    	RETURN .F.
    ENDIF
    
    *!* Start Kodak Imaging.
    goImaging = CREATEOBJECT("Imaging.application")
    *!* Make the Kodak Imaging window as small as possible. You cannot hide it.
    goImaging.LEFT = 0
    goImaging.TOP = 0
    goImaging.WIDTH = 112
    goImaging.HEIGHT = 27
    goImaging.TopWindow = .F.
    
    goImageFile = goImaging.CreateImageViewerObject()
    
    WAIT WINDOW "Printing .TIF files. Please wait..." NOWAIT NOCLEAR
    
    *!* Loop through the array and print the .tif files.
    FOR i = 1 TO ALEN(laTiffArray) STEP 5
    *!* We only have file names in the array. We need to give the imaging
    *!* object a full path to each file.	
    	lcTiffFullPath = lcTiffDir + laTiffArray[i]
    	goImageFile.OPEN(lcTiffFullPath)
    	goImageFile.PRINT(.F.)	&& .F. suppresses the print options dialog.
    	goImageFile.CLOSE(.F.)	&& .F. closes file without saving changes.
    ENDFOR
    
    *!* Clean up.
    goImaging.QUIT()
    RELEASE goImaging, goImageFile
    WAIT WINDOW "Complete!" TIME 2
    
    *!* END SAMPLE CODE.
    					
  2. When prompted, select a directory that contains some .tif files.
Visual FoxPro prints these files.

REFERENCES

For more information about automating Kodak Imaging, download the Kodak Imaging Professional Developers Guide from the Eastman Kodak Web site: Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.

(c) Microsoft Corporation 2000, All Rights Reserved. Contributions by Trevor Hancock, Microsoft Corporation.


Modification Type:MajorLast Reviewed:2/22/2005
Keywords:kbAutomation kbhowto KB281380