PDF Box
A PDF Box displays one or more pages from a PDF document in the report.
For information about when to use elements, see Choose report elements.
PDF Box (PDFBox type) is a layout container, found in the Drawables group in the Tool Box view. The PDF Box propagates if the PDF has more than one page.
Properties
Select the object on the Report Design page to display its properties in the Properties view.
The Location property specifies the location of the PDF document using a URL.
The Password property is used for password-protected documents.
The Page Ranges property specifies the pages to include.
The cropRightWidth, cropBottomWidth, cropLeftWidth, and cropTopWidth properties specify the amount to be cropped from the margins.
If you want to preserve the aspect ratio, set the value of either length (y-size) or width (x-size), allowing Report Writer to calculate the corresponding value. If you set both properties, the resulting image appears distorted.
Embedding PDFs
To embed a document, use a URL type that allows encoding the data in the body of the URL text. The full syntax of data URLs is:
data:[MIME-type][;charset=encoding][;base64],data
See data URI scheme (Wikipedia link) for a complete description of the concept and the syntax.
For our purposes, it is sufficient to support a simplified subset
that omits the charset
and assumes that characters are encoded in
UTF-8. Image data is always encoded in base64 (Wikipedia link) while other data such as HTML content is
typically “Percent encoded” (Wikipedia
link).
data:application/pdf;base64, data
where data is the base 64 encoded data of the PDF document.
To embed PDFs, use the data protocol syntax in the Location property of the PDFBOX element.
To automatically construct this URL, click the ... button for the Location property. Choose the file and select the Embed in document check box:
Displaying PDFs depending on a variable
In this example, all PDFs are stored in the directory C:/My Docs/pdfs/, and
the PDF name is determined by the field orderline.product.pdf
. Enter the following
in the Expression Editor for the Location property:
"file:///C:/My Docs/pdfs/"+orderline.product.pdf.trim()