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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send a PDF file and/or GIF file to printer from FoxPro 1

Status
Not open for further replies.

lifesupport

Programmer
May 18, 2004
64
US
How can I send a PDF file and/or GIF file to the printer. Another alternative I have is to programatically print from mspaint if that's possible. Preferably, I'd like to be able to print PDF files to the printer as they are the most clear. Thanks
 
I think you could do this with a ShellExecute call:

Code:
PRINTFILE("C:\MYFILE.PDF")

FUNCTION PRINTFILE
	PARAMETER m.FILENAME,m.LINEPARAMS
	LOCAL LNRETVAL, LCOPERATION
	PRIVATE m.FILENAME,m.LINEPARAMS
	LCOPERATION = "Print"
	**
	DECLARE INTEGER ShellExecute IN SHELL32.DLL ;
		INTEGER handle,;
		STRING @sFile,;
		STRING @lp,;
		STRING @DIR,;
		STRING @dir1,;
		INTEGER ncmd
	**
	IF PCOUNT() < 2
		M.LINEPARAMS = ""
	ENDIF
	LNRETVAL = SHELLEXECUTE(0, LCOPERATION, m.FILENAME, m.LINEPARAMS, "", 1)
	CLEAR DLLS SHELLEXECUTE
	RETURN(LNRETVAL)

Regards

Griff
Keep [Smile]ing
 
Thanks for the code. It's what I was trying today and 'LNRETVAL' returns a value of 31 on the shellexecute call, which means there's an error, but it's not giving me an error message. Any ideas?
 
Lifesupport,

A reply of 31 means "Invalid action" or "No application associated with the file" (in other words, you don't have a PDF viewer installed, which seems unlikely).

You might like to take a look at:

which might give you some more information.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Lifesupport,

Just to follow that up ....

I just did the following, and it works fine:

Code:
DECLARE INTEGER ShellExecute IN SHELL32.DLL ;
  INTEGER handle,;
  STRING action, ;
  STRING File,;
  STRING Directory,;
  STRING Params,;
  INTEGER WindowState
        
lnReply = ;
 ShellExecute(0, "Print","C:\SomeFile.PDF", "", "", 2)

? lnReply  && returns > 32

Give it a try.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I got it going with the GIF files. I'll keep working with the PDF. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top