Originally posted in www.junblogs.com
The easiest way to convert a report into a pdf file is via using a pdfprinter. There are lots of pdf printers outside there which you can use. You can check these sites:
SET PRINTER TO NAME('PrimoPDF') && or
something like that or a variable that contains the name of the PDF printer
REPORT FORM YourReport TO PRINTER
NOCONSOLE
SET PRINTER TO DEFAULT && This
is essential to instruct VFP to return back to its default printer
In cases like that, you need to employ WinApis instead of SET PRINTER NAME trick. Here is a simple snippet for that:
?apiSetDefaultPrinter('PrimoPDF') && for this sample, I am using
PrimoPDF
Declare Integer ShellExecute In shell32.dll ;
INTEGER hndWin, ;
STRING cAction, ;
STRING cFileName, ;
STRING cParams, ;
STRING cDir, ;
INTEGER nShowWin
* I used getfile() here so you
can test but you can use the target file instead
* if you have one, e.g.,
“c:\MyFile.txt”
ShellExecute(0,'print',Getfile('txt'),'','',1)
* A delay is necessary to give
enough time for spooling, you can increase the delay
* if you think it is needed. If you don’t put this, the printer will be
switched back
* very fast by the command below
to the default printer that switching to the pdf printer
* will seem to have failed
StandbyDelay(2)
* Witch back to default printer
(what we have here in the office)
?apiSetDefaultPrinter('Canon
MF5700 Series')
***************
Function apiSetDefaultPrinter
***************
Lparameters pszPrinter
Declare Integer SetDefaultPrinter
In winspool.drv As apiSetDefaultPrinter
;
String pszPrinter
Return apiSetDefaultPrinter(m.pszPrinter)
Endfunc
***********
Function StandbyDelay(lnDelay)
***********
Declare Sleep In kernel32 Integer
dwmilliseconds = m.lnDelay * 1000
Sleep(dwmilliseconds)
Clear Dlls 'Sleep'
Return
Cheers!
Simpo PDF to Text Converter is one of the most efficient PDF converters, as this converter supports batch converting PDF documents to text files.free pdf converters
ReplyDeleteThanks for the info! TO add up to the list above, I also found pdffiller.com as useful form engine and file to pdf converter, check it out here http://goo.gl/848iAb
ReplyDeleteReally insightful! Thanks for breaking this down.
ReplyDeleteAdobe Photoshop Download
SuperAntiSpyWare Pro
PC Helpsoft Driver"