Saving the data as PDF
Contents
PowerBuilder provides three ways to save a DataWindow object or
DataStore in Portable Document Format (PDF).
Using PDFlib
Starting from PowerBuilder 2017, an alternative method is
provided to directly print data to PDF without needing to install any
third-party tool or driver or make any configuration. This method
relies on a light-weight software called PDFlib which is automatically
installed with PowerBuilder at no cost. And the DLL file for PDFlib
(PBPDF.dll) is automatically packaged into the PowerBuilder
application executable as well without requiring the developer to make
any configuration or selection during the building process.
Starting from PowerBuilder 2019 R3, for new DataWindows, this
method is automatically selected as the default PDF method (instead of
the Distill! method with Ghostscript); but for existing DataWindows,
you may need to manually set this method as the default PDF method
using one of the ways described in section Saving as PDF using NativePDF!
method with PDFlib.
Using Ghostscript
Starting from PowerBuilder 2019 R3, the Distill! method with
Ghostscript is no longer the default method for new DataWindows when
you select File>Save Rows As and select PDF as the file type. But
for existing DataWindows, the Distill! method is still the default
option in order to keep compatibility with the existing logics.
When using Ghostscript, the data is printed to a PostScript file
first and then distilled to PDF using Ghostscript.
Installing Ghostscript and PostScript drivers
For licensing reasons, Ghostscript and the PostScript drivers
required to use the Distill! method are not installed with
PowerBuilder. You (and your users) must download and install them
before you can use this technique. See System requirements for the Distill!
method.
Using XSL-FO and Java
printing
Building on the ability to save data as XML, PowerBuilder can
also save the DataWindow object’s data and presentation to PDF by
generating XSL Formatting Objects (XSL-FO). This option provides a
platform-independent solution by rendering the DataWindow using a Java
process rather than the Microsoft GDI. It also offers the possibility
of customizing the PDF file at the XSL-FO stage. Saving as PDF using
XSL-FO is particularly useful if you want to print DataWindow objects
on a UNIX operating system by using Java printing. The Ghostscript
method and the PDFlib method are not supported on UNIX.
The XSL (Extensible Stylesheet Language) W3C Recommendation has
two parts, XSLT and XSL-FO. XSLT provides the transformation typically
used to present XML documents as HTML in a browser. XSL-FO provides
extensive formatting capabilities that are not dependent on the output
format.
For more information about XSL, see the latest version of the
Extensible Stylesheet Language (XSL) at http://www.w3.org/TR/xsl/.
Limitations and unsupported
features
The Ghostscript method and the PDFlib method currently do not
support OLE DataWindow objects. The XSL-FO method currently does not
support OLE, graph, and composite DataWindow objects.
The PDFlib method currently does not support the DataWindow
object’s background.property and the DataWindow object’s margin
settings.
The RichText DataWindow (no matter it uses the TX Text Control
or the obsolete TE Edit Control) can directly generate a PDF file
(using the DataWindow SaveAs function) without needing to specify the
PDF method first, because it uses the PDF solution provided by TX Text
Control or TE Edit Control, rather than using PDFlib, Ghostscript, or
XSL-FO. Therefore, you can directly execute the following script to
generate a PDF in the RichText DataWindow: dw_1.SaveAs
(“c:dw_one.pdf”, PDF!, false).