Some applications either can’t provide the PDF document with bookmarks or support insufficient or incorrect bookmarks. Working with PDF files becomes comfortable if the document has bookmarks with a table of contents-like structure. Here’s an example of printing colored rectangles with the prAdd subroutine. PDF::Reuse will perform no syntax checks on the instructions, so refer to the PDF reference manual. If you know low-level PDF instructions, you can add them with with the prAdd(string) subroutine. PrSinglePage takes one page after the other from an existing PDFdocument and returns the number of remaining pages after each invocation. Last unless prSinglePage('sample-letters.pdf') Sometimes you need only make a small change to a document, such as adding missing page numbers. The rest of the code is a simple loop over the file containing the customer data to filling the template with prText. The default font is Helvetica, with 12 pixel size.
The always-available options are Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic, Courier, Courier-Bold, Courier-Oblique, Courier-BoldOblique, Helvetica, Helvetica-Bold, Helvetica-Oblique, and Helvetica-BoldOblique. My ($first, $last, $street, $zipCode, $city, $country) = split(/,/, $line) Īfter opening the file with prFile, the call to prCompress(1) enables PDF compression. The following listing should be rather self explanatory. However PDF::Reuse is sufficient to create a simple PDF to use in later examples. If you want to create more sophisticated documents you should investigate other PDF-packages like PDF::API2 from Alfred Reibenschuh or Text::PDF from Martin Hosken. Example MaterialĪlthough its capabilities are limited in this area, you can also use PDF::Reuse to create PDF documents.
#Perl printf how to
This article shows how to use PDF::Reuse, by Lars Lundberg, for combining different PDF documents and adding bookmarks to them. In most cases you would not be satisfied by the resulting bookmarks panel, either. You could use a tool like HTMLDOC, but adding article number 51 would require you to fetch articles one through 50 from the Web again. Imagine that you want to collect all relevant articles in one PDF file with an up-to-date bookmarks panel. However, this software reaches its limits if you want advanced tasks such as combining different PDF documents into one single document or adding and adjusting the bookmarks panel for better navigation. Most office products can export their content into PDF. Adobe’s PDF has become a standard for text documents.