45
130
Chapter 6: Importing Images and PDF Pages
6.2 Importing PDF Pages with PDI (PDF Import Library)
Note All functions described in this section require PDFlib+PDI. The PDF import library (PDI) is not
contained in PDFlib or PDFlib Lite. Although PDI is integrated in all precompiled editions of
PDFlib, a license key for PDI (or PPS, which includes PDI) is required.
6.2.1 PDI Features and Applications
When the optional PDI (PDF import) library is attached to PDFlib, pages from existing
PDF documents can be imported. PDI contains a parser for the PDF file format, and pre-
pares pages from existing PDF documents for easy use with PDFlib. Conceptually, im-
ported PDF pages are treated similarly to imported raster images such as TIFF or PNG:
you open a PDF document, choose a page to import, and place it on an output page, ap-
plying any of PDFlib’s transformation functions for translating, scaling, rotating, or
skewing the imported page. Imported pages can easily be combined with new content
by using any of PDFlib’s text or graphics functions after placing the imported PDF page
on the output page (think of the imported page as the background for new content). Us-
ing PDFlib and PDI you can easily accomplish the following tasks:
>overlay two or more pages from multiple PDF documents (e.g., add stationary to ex-
isting documents in order to simulate preprinted paper stock);
>place PDF ads in existing documents;
>clip the visible area of a PDF page in order to get rid of unwanted elements (e.g., crop
marks), or scale pages;
>impose multiple pages on a single sheet for printing;
>process multiple PDF/X or PDF/A documents to create a new PDF/X or PDF/A file;
>copy the PDF/X or PDF/A output intent of a file;
>add some text (e.g., headers, footers, stamps, page numbers) or images (e.g., company
logo) to existing PDF pages;
>copy all pages from an input document to the output document, and place barcodes
on the pages;
>use the pCOS interface to query arbitrary properties of a PDF document (see Chapter
8, »The pCOS Interface«, page 181).
In order to place a PDF background page and populate it with dynamic data (e.g., mail
merge, personalized PDF documents on the Web, form filling) we recommend using PDI
along with PDFlib blocks (see Chapter 10, »Variable Data and Blocks«, page 225).
6.2.2 Using PDI Functions with PDFlib
Cookbook Code samples regarding PDF import issues can be found in the pdf_import category of the
PDFlib Cookbook.
General considerations. It is important to understand that PDI will only import the ac-
tual page contents, but not any interactive features (such as sound, movies, embedded
files, hypertext links, form fields, JavaScript, bookmarks, thumbnails, and notes) which
may be present in the imported PDF document. These interactive features can be gener-
ated with the corresponding PDFlib functions. PDFlib blocks will also be ignored when
importing a page.
You can not re-use individual elements of imported pages with other PDFlib func-
tions. For example, re-using fonts from imported documents for some other content is