Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing a TIFF file from VFP

Status
Not open for further replies.

Alexengland1

IS-IT--Management
Mar 18, 2004
88
US
I have given up trying to fiddle with the OLEcontrol I'm using, does anyone know of a quick easy way to print a TIFF file out of VFP?
 
What version and SP level of VFP are you using? In 8.0 and higher you can do it natively through a quick report.

Rick
 
If you are using VFP's Report to print out a document and you want it to go to a TIFF file, then you can do so by using a TIF Image "Printer". One of my clients is doing just that today.

We got a reasonably priced ($39.95) TIF Image Print Driver from ZanSoft ( ).

Once that was installed and configured, the rest was pretty easy.

The program changes from the workstation's original Windows Default printer to this Image "Printer", creates a single multi-page TIF file corresponding to the multi-page report (repeated many times daily for individual clients), then, when done, changes the printer back to the original Windows Default printer (see thread184-940247 ).

Good Luck,
JRB-Bldr
 
Try using the shellexecute API. Here is a sample. Notice I included a few other file types (other examples) that are commented out.

Code:
* tif file [print] example
appLaunch("c:\myfile.tif","print")


* Notepad text file example
* appLaunch("myfile.txt")

* tif file [open] example
* appLaunch("c:\myfile.tif")

* web example
*appLaunch("[URL unfurl="true"]www.deltabg.com")[/URL]
***********************************************************************
FUNCTION appLaunch
PARAMETER tcOutFile,tcCmd  

IF PCOUNT() < 1
	MESSAGEBOX("You did not provide a filename.","AppLauch Method")
	RETURN
ENDIF	

IF PCOUNT() < 2
	tcCmd = "Open"
ENDIF	
	
tcCmd = PROPER(m.tcCmd)

* This code was originally located in Ken Levy's DBF2XML program so blame 
* Ken for the bugs :)

* API Call to communicate with an application based on the registered
* file-type.  
* For example: 
* On my computer txt is notepad; DOC is word

DECLARE INTEGER ShellExecute ;
	    IN SHELL32.DLL ;
	    INTEGER nWinHandle,;
	    STRING cOperation,;   
	    STRING cFileName,;
	    STRING cParameters,;
	    STRING cDirectory,;
	    INTEGER nShowWindow
	    
* tip: to determine commands available for each filetype
* Launch explorer
* go to View / Folder Options
* Select the File Type Tag	
* go to the item you wish to look up (example Acrobat)
* Press Edit
* You will see acrobat has Open, Print, and Printto option types.    
	
IF !FILE(tcOutFile) AND ATC("[URL unfurl="true"]WWW.",UPPER(tcOutFile))[/URL] = 0
	MESSAGEBOX(tcOutFile + " does not exist!","AppLauch Method -- AppLauch Method")
ELSE	

	* play with this.  
	* by adding the ,0 instead of ,1 I was able to get it to
	* print directly without opening the document on my sceen.
	
	
	* this is handy if you wish to print a pdf, word document, 
	* spreadsheet, text file, etc. from within your applicaiton.
	IF m.tcCmd = "Print"
		lnFileStatus = ShellExecute(0,"&tcCmd",tcOutFile,"","",0)
	ELSE
		lnFileStatus = ShellExecute(0,"&tcCmd",tcOutFile,"","",1)
	ENDIF	
	DO CASE 
	CASE m.lnFileStatus > 32
		* successful open
	CASE m.lnFileStatus = 2 
		MESSAGEBOX("Bad Association (for example, invalid URL)",;
			"AppLauch Method -- AppLauch Method")
	CASE m.lnFileStatus = 29
		MESSAGEBOX("Failure to load application","AppLauch Method -- AppLauch Method")
	CASE m.lnFileStatus = 30
		MESSAGEBOX("Application is busy","AppLauch Method -- AppLauch Method")
	CASE m.lnFileStatus = 31
		MESSAGEBOX("No application association with specified "+;
			"command: " + m.tcCmd,"AppLauch Method -- AppLauch Method")
	OTHERWISE
		MESSAGEBOX("Unknown Error","AppLauch Method -- AppLauch Method")
		RETURN .F.
	ENDCASE		
ENDIF

Jim Osieczonek
Delta Business Group, LLC
 
Jim,

Thanks a usefull bit of code, thank you for posting it.

You might want to look at the messagebox dialogs though, you've got AppLaunch spelt AppLauch!



Regards

Griff
Keep [Smile]ing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top