The fwPDF object provides functionality that helps produce and stream PDF files to the browser. There are two methods of delivering PDF files from FoxWeb:
Stream the file directly to the browser
This method involves the use of the SendPDF method to generate a PDF file and stream it directly to the browser from the FoxWeb script. In general, this is a much cleaner option and works better in most circumstances.
Create the file in the web tree and access it via a static link
This method involves using the PS2PDF method to generate and store a PDF file in a temporary, web-addressable folder and sending back to the browser a link, pointing to the file. This technique may be preferable if the files are really large, but it requires that you also establish an external process to clean up older PDF files at regular intervals.
By itself, fwPDF does not have the ability to generate PDF files, but must rather be used with 3rd-party software, such as Adobe Acrobat, or Ghostscript. For additional information on PDF file creation, please refer to the Creating PDF Files topic.
|PS2PDFOptions||Can be used to specify command line options for the conversion of Postscript files to PDF format.|
|PS2PDFPresets||Can be used to override the PS to PDF Presets option, specified in the FoxWeb Control Center.|
|PS2PDFTimeout||Can be used to override the PS to PDF Command Timeout, specified in the FoxWeb Control Center.|
|GetTempFile||Returns the full path and file name to a temporary file in FoxWeb's temporary folder.|
|PS2PDF||Converts a Postscript file to PDF format.|
|SendPDF||Streams a Postscript, or PDF file to the browser. If the file is in Postscript format, it is first converted to PDF format.|
The PS2PDFOptions property can be used to specify conversion options for situations, where a command line application is used for the conversion from Postscript to PDF format. The content of this property is inserted in the location specified by the %OPTIONS% tag in the PS to PDF command Line, specified in the FoxWeb Control Center. For example, consider the following situation:
|PS to PDF Command Line:||"C:\Program Files\PDF\PS2PDF.exe" %OPTIONS% /o "%PDFFILE%" "%PSFILE%"|
|Command Line used:||"C:\Program Files\PDF\PS2PDF.exe" /h /f:book /o "%PDFFILE%" "%PSFILE%"|
The PS2PDFPresets property can be used to override the PS to PDF Presets option that was specified in the FoxWeb Control Center. This property is only used when the PS to PDF Converter option is set to 'Ghostscript', or 'Adobe Acrobat Distiller'. Valid values will depend on the converter used. Both Ghostscript and Adobe Acrobat allow the creation of user-defined presets. For details, please refer to the documentation of your PDF software.
The PS2PDFTimeout property can be used to override the PS to PDF Command Timeout that was specified in the FoxWeb Control Center. This property is only used when the PS to PDF Converter option is set to 'Command Line'.
The fwPDF.GetTempFile method returns the full path and file name to a temporary file in FoxWeb's temporary folder. The file name is a randomly-generated, 32-character string of letters and numbers, which makes it suitable for obfuscating PDF files stored in the Web tree for static download. For sample code illustrating the use of GetTempFile, refer to the examples under the PS2PDF and SendPDF sections.
TempFile = fwPDF.GetTempFile()
Character string: The full path and file name to a temporary file.
The fwPDF.PS2PDF method can be used to convert a Postscript file to PDF format. Typically, you would only use this method in situations where the resulting PDF file would be stored in a temporary web-addressable folder for direct download as a static file. In some rare cases -- especially if the generated PDF files are really large -- this technique is preferable to using the SendPDF method to stream the file to the browser from your FoxWeb scripts.
Success = fwPDF.PS2PDF(PSFile, PDFFile, DeleteOriginal)
Character string, specifying the full path of the Postscript file to be converted to PDF format.
Character string, specifying the full path of the resulting PDF file.
Boolean value, specifying whether the method should delete the source Postscript file after a successful conversion.
Boolean: The PS2PDF method returns .T. if the conversion was successful.
The fwPDF.SendPDF method Streams a Postscript, or PDF file to the browser. If the file is in Postscript format, it is first converted to PDF format.
fwPDF.SendPDF(SourceFile, FileName, DeleteOriginal, Convert, Download)
Character string, specifying the full path to the file to be streamed to the browser.
Optional character string, specifying the file name that gets sent to the browser. Used by browsers as the default file name in the Save As dialog. If this parameter is not specified, then the source file name is used instead.
Boolean value, specifying whether the SendPDF method should delete the original file after successful streaming to the browser. If this parameter is not specified, or is set to .F., SendPDF does not delete the source file.
Optional boolean value, specifying whether SendPDF should call the PS2PDF method to convert the original file from Postscript to PDF format, before streaming the PDF file to the browser. If this parameter is not specified, or is set to .F., SendPDF assumes that the source file is already in PDF format and does not perform a conversion.
This optional boolean value controls the value of the Content Disposition HTTP header, which controls how the browser will handle the PDF file. If this value is not specified, or is set to False, then the file gets displayed inline in the browser window, using the Acrobat plug-in. If Download is set to .T. then the file is sent as an attachment, causing the browser to display the Open/Save dialog.