The <import/> command

The <import/> command issues a request to the TopLeaf PDF builder to import either a single page from an external PDF or the entire PDF document. The imported page replaces the page containing the import request, and is inserted into the TopLeaf PDF output at the point at which the request is processed.

The command format is:

<import file="NAME" page-number="PAGE" />

where

  • NAME is the full pathname of the PDF file.

  • PAGE is the page number within the imported PDF document.

The following example shows how to import a single page from an external PDF :

<import file="C:\MY DOCUMENTS\SAMPLE.PDF" page-number="126" />
[Warning] Warning

If you do not specify a page number, the TopLeaf PDF builder will import the entire PDF document.

Placeholder pages

Pages that contain requests to import external PDF page content are known as placeholder pages. When a placeholder page is processed by the TopLeaf PDF builder, the placeholder page will be replaced by the external PDF page content. On the other hand, if you use the TopLeaf GUI to print or preview a placeholder page, the content of the placeholder page will be rendered - the content of the external PDF page will not be shown. As a general rule, it is recommended that you include content such as

Page XXX of YYYY.pdf to be inserted here

within the content of a placeholder page.

[Warning] Warning

You must create a placeholder page for every imported PDF page if your TopLeaf document declares internal PDF link targets, and you intend to import external PDF page content with a PDF document created by TopLeaf.

Generating placeholder pages

To read a PDF document and automatically generate an XML page list description into your document at the current location use the command:

<read file="PDF_FILENAME" />

where PDF_FILENAME is the full pathname of the PDF file to be read.

You can map the generated XML page list using standard tag mappings to create placeholder pages for each page within the imported PDF document.

The following fragment shows the structure of a XML page list generated for a PDF containing 6 pages:

<tl:pdf file="C:\MY DOCUMENTS\SAMPLE.PDF">
 <tl:pdf-pagelist count="6">
   <tl:pdf-page page-number="1" />
   <tl:pdf-page page-number="2" />
   <tl:pdf-page page-number="3" />
   <tl:pdf-page page-number="4" />  
   <tl:pdf-page page-number="5" />
   <tl:pdf-page page-number="6" />
  </tl:pdf-pagelist>
</tl:pdf>

To generate a placeholder page for each PDF page:

  1. Include a <read file="C:\MY DOCUMENTS\SAMPLE.PDF" /> command to read and create an XML PDF page list at the point at which you want to import the PDF document pages.

  2. Create a tag mapping for the tag tl:pdf.

    Capture the name of the PDF file by adding the following command to the tl:pdf custom pre-content:

    <set var="PDFFILE" string="{@file}" />
  3. Create a tag mapping for the tag tl:pdf-page.

    This mapping will import a single PDF page and create a placeholder page for it. To create a page, the mappings needs to have a page break on both the start and end tags, and also create some content for the page.

    The following is an example of suitable custom content:

    <import file="{PDFFILE}" page-number="{@page-number}" />
    Placeholder page for {PDFFILE} page {@page-number}