CopyPDF

Use the command CopyPDF to copy a set of pages into a new PDF document.

Syntax

CopyPDF
	Src (<text>)
	Dest (<text>)
	PageSet (<text>)
	ProducePDFA (True or False);

Parameters

  • Src: Required. The full path of the source PDF document.
  • Dest: Required. The full path of the result PDF document that contains the selected pages.
  • PageSet: Optional. Specifies the set of pages that must be copied into the resulting PDF document. If this parameter is omitted or empty, the full document is copied. If the source PDF file already contains attachments, they are removed from the result PDF file.
  • ProducePDFA: Optional. (Default setting: False). This parameter determines whether the resulting document is PDF/A-1b compliant.
  • InteractiveFeatures: Optional. This parameter controls how the CopyPDF command processes the following interactive PDF features of the input PDF documents:
    • Bookmarks: A PDF file can contain a bookmark structure that follows the document outline. This outline includes entries that link to the corresponding page when clicked.
    • Links: A PDF file can contain links to a particular page within the document or to an external URL.

    InteractiveFeatures parameter does not maintain bookmarks and links that have named destinations.

    This parameter can have three values:

    1. IncludeStrict: Supported interactive features of the input documents are included in the result document. Any issues related to these features are flagged as errors, and processing is stopped. IncludeStrict does not guarantee that the supported interactive features are included in the result document in exactly the same way as they were present in the input documents. However, it attempts to detect and flag issues. When bookmarks or links with named destinations are encountered an error appears.
    2. Include: Supported interactive features of the input documents are included in the result document. The interactive features are replicated as closely to the originals as possible, but any deviations are not flagged as errors. Bookmarks and links with named destinations are not included in the result document.
    3. Exclude: No interactive features of the input document are included in the result document. This option can speed up processing of documents that support a large number of interactive features. Does not include any bookmarks or links, therefore none of them is flagged as an error.

    If the InteractiveFeatures parameter is omitted, you can configure the default behavior of the CopyPDF command in the dp.ini file. Do this by assigning one of the preceding InteractiveFeatures values to the following setting:

    PDFTools.InteractiveFeatures

    If not specified, the default is include.

Note, that this command can only produce PDF/A-1b compliant documents if the source document is PDF/A-1b compliant and if the parameter ProducePDFA is set to True.

The set of pages that must be copied is specified as a comma-separated list of page ranges. Ranges refer to physical pages in the document, not to page numbers that might appear on the pages.

Ranges can be expressed in the following ways:

  • n Page n.
  • n-m Pages n to m inclusive.
  • -m All pages from the start of the source document up to page m inclusive.
  • n- All pages from page n to the end of the source document.
  • !xxx Exclude range xxx. Excluded ranges have priority over included ranges.

If the set of pages only contains excluding ranges, the whole document except those ranges is copied.

All pages are included in their original order. It is not possible to reorder or duplicate pages with the CopyPDF command.

Examples

CopyPDF ... PageSet (“2-“);	Copy all pages except the first page.
CopyPDF ... PageSet (“!1”);	Copy all pages except the first page.
CopyPDF ... PageSet ("8,!3,5,2-6"); Copies pages 2,4,5,6 and 8
from the source document.

CopyPDF retains hyperlinks and bookmarks that refer to pages included in the result document. Interactive elements and elements that refer to removed pages are omitted from the result document.