General information
Category:
Third party products
I figured out some of my questions. It seems that it is normal for the Distiller to create the postscript file from the VFP REPORT command. I also found the API to convert a postscript file to a PDF. If some could tell me how I can send back the PDF file in an ADO Recordset field, that would be helpful. Below is the code that I used to run a VFP report and create a PDF file. I run this EXE from my VFP COM DLL via WSH Exec method. Once it finishes, I pass the name of PDF file to ASP page to display to the user.
Tim
* Purpose: To run a VFP report and send the output to a PDF file
*
* Parameters:
* tcFrxFile: VFP report
* tcPdfFile: PDF file to create
* tuParm1: Report parameter (1)
* tuParm2: Report parameter (2)
* Program constants
#DEFINE API_DISTILLER "PdfDistiller.PdfDistiller.1"
&& Acrobat Distiller object
#DEFINE PRG_PRINTER "Acrobat Distiller"
&& Name of printer for Acrobat Distiller
LPARAMETERS tcFrxFile, tcPdfFile, tuParm1, tuParm2
LOCAL lcPsFile, lcOldCentury, lcOldPrinter
LOCAL loDistiller
PRIVATE puParm1, puParm2
* Initial settings
lcOldCentury = SET("Century") && Save Century setting
lcOldPrinter = SET("Printer", 3) && Save current printer
SET CENTURY ON && Display four-digit year
SET PRINTER TO NAME (PRG_PRINTER) && Set PDF printer
lcPsFile = FULLPATH(SUBSTR(SYS(2015), 3, 10) + ".ps", tcPdfFile)
&& Postscript file for report output
puParm1 = tuParm1 && Report parameter (1)
puParm2 = tuParm2 && Report parameter (2)
* Run report
IF FILE(lcPsFile) && If text file exists...
DELETE FILE (lcPsFile) && Delete text file
ENDIF
IF FILE(tcFrxFile) && If report does exist...
REPORT FORM (tcFrxFile) TO FILE (lcPsFile) NOCONSOLE
&& Run report and send output to text file
loDistiller = CREATEOBJECT(API_DISTILLER) && Object to create PDF with Adobe Distiller
= loDistiller.FileToPdf(lcPsFile, tcPdfFile, "")
&& Convert postsript file to PDF
loDistiller = .NULL. && Destroy object for Adobe Distiller
IF FILE(lcPsFile) && If text file exists...
DELETE FILE (lcPsFile) && Delete text file
ENDIF
ENDIF
* Restore settings
SET CENTURY OFF && Restore Century setting
SET PRINTER TO NAME (lcOldPrinter) && Restore current printer
RETURN
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only