Microsoft KB Archive/281380

= How to print multiple .tif files from Visual FoxPro =

Article ID: 281380

Article Last Modified on 2/22/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 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 &quot;Wang Imaging&quot; and &quot;Eastman Imaging&quot;), 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:   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

lcTiffDir = GETDIR(SYS(5) + SYS(2003),&quot;Select *.TIF Directory&quot;) IF EMPTY(lcTiffDir) MESSAGEBOX(&quot;No directory selected. Aborting program.&quot;,64,&quot;&quot;) RETURN .F. ENDIF
 * !* Let user choose a DIR and generate a list of *.TIF files
 * !* to print using ADIR.

CD (lcTiffDir) ADIR(laTiffArray,&quot;*.TIF&quot;) IF TYPE(&quot;laTiffArray&quot;) = &quot;L&quot; MESSAGEBOX(&quot;There are no *.TIF files in the selected directory. Aborting program.&quot;,64,&quot;&quot;) RETURN .F. ENDIF

goImaging = CREATEOBJECT(&quot;Imaging.application&quot;) goImaging.LEFT = 0 goImaging.TOP = 0 goImaging.WIDTH = 112 goImaging.HEIGHT = 27 goImaging.TopWindow = .F.
 * !* Start Kodak Imaging.
 * !* Make the Kodak Imaging window as small as possible. You cannot hide it.

goImageFile = goImaging.CreateImageViewerObject

WAIT WINDOW &quot;Printing .TIF files. Please wait...&quot; NOWAIT NOCLEAR

FOR i = 1 TO ALEN(laTiffArray) STEP 5 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
 * !* Loop through the array and print the .tif files.
 * !* We only have file names in the array. We need to give the imaging
 * !* object a full path to each file.

goImaging.QUIT RELEASE goImaging, goImageFile WAIT WINDOW &quot;Complete!&quot; TIME 2
 * !* Clean up.

 When prompted, select a directory that contains some .tif files.
 * !* END SAMPLE CODE.

Visual FoxPro prints these files.

