About assembling PDF documents

You use the cfpdf tag to assemble PDF documents in Adobe ColdFusion. The tag provides several actions for creating unified output files from multiple sources, as the following table shows:




Adds a watermark image to one or more pages in a PDF document.


Deletes one or more pages from a PDF document.


Adds header to a PDF document.


Adds footer to a PDF document.


Removes header and footer from a PDF document.


Reduces the quality of PDF documents by image downsampling and removing unused objects.


Extracts text from the specified pages or the entire PDF documents


Extracts images from the specified pages or the entire PDF document


Performs page level transformations


Extracts information associated with the PDF document, such as the author, title, and creation date.


Assembles PDF documents or pages from PDF source files into one output file.


Extends the cfpdf tag by providing a subset of Adobe® LiveCycle™ Assembler functionality. This action is the default.


Password-protects and encrypts a PDF document.


Reads a PDF document into a ColdFusion variable.


Removes watermarks from specified pages in a PDF document.


Sets the Title, Subject, Author, and Keywords for a PDF document,


Generates thumbnail images from specified pages in a PDF document.


Writes PDF output to a file. Also use to flatten forms created in Acrobat and linearize documents.

Note: You cannot use the cfpdf tag to create a PDF document from scratch. To create a PDF document from HTML content, use the cfdocument tag. Also, you can use Report Builder to generate a report as a PDF document. Instead of writing a PDF document to file, you can specify a PDF variable generated as the source for the cfpdf tag.

All but one of the cfpdf tag actions provide shortcuts to common tasks; for example, with one line of code, you can add a watermark image to one or more pages in an output file, merge all the PDF documents in a directory into a single output file, or password-protect a PDF document. ColdFusion provides two ways to extend the functionality of the cfpdf tag: the cfpdfparam tag and the processddx action.

You use the cfpdfparam tag only with the merge action of the cfpdf tag. The cfpdfparam tag gives you more control over which files are included in the output file; for example you can merge pages from multiple files in different directories.

The processddx action extends the cfpdf tag by providing a subset of Adobe LiveCycle Assembler functionality. You use the processddx action to process Document Description XML (DDX) instructions explained in Using DDX to perform advanced tasks. Using DDX instructions requires more coding, but it lets you perform complex tasks, such as generating a table of contents and adding automatic page numbers.

Also, ColdFusion provides three functions for PDF file, DDX file, and PDF variable verification:




Determines whether a DDX file, path, and instructions are not null and are valid. Also verifies that ColdFusion supports the schema used for the DDX instructions.


Determines whether a PDF source file, path, and version are valid and supported on the server running ColdFusion. Also verifies whether a PDF file is corrupted.


Determines whether a PDF object stored in memory is valid. Also verifies the contents of PDF variables generated by the cfdocument and cfpdf tags.

The following table describes a few document assembly tasks that you can perform with ColdFusion:



Add a generated table of contents to a PDF document

cfpdf action="processddx" with the TableOfContents DDX element

cfpdf action="extracttext" can also be used.

Add automatic page numbers to a PDF document

cfpdf action="processddx" with the _PageNumber and _LastPagenumber built-in keys. Valid only in the Header and Footer DDX elements.

Add headers and footers to a PDF document

cfpdf action="processddx" with the Header and Footer DDX elements


cfpdf action="addheader" and cfpdf action="addfooter"

Add or remove watermarks

cfpdf action="processddx" with the Watermark and Background DDX elements

cfpdf action="addWatermark" and cfpdf action="removeWatermark"

Change the encryption algorithm for PDF documents

cfpdf action="protect" encrypt="encryption algorithm"

Change user permissions on a PDF document

cfpdf action="protect" newOwnerPassword="xxxxx"permissions="comma-separated list"

Delete pages from a PDF document

cfpdf action="deletePages"

Extract text from a PDF document and export it to an XML file

cfpdf action="processddx" with the DocumentText DDX element

Flatten (remove interactivity from) forms created in Acrobat

cfpdf action="write" flatten="yes"

Generate thumbnail images from PDF document pages

cfpdf action="thumbnail"pages="page numbers"

Linearize PDF documents for faster web display

cfpdf action="write" saveOption="linear"

Merge pages and page ranges from multiple documents in different locations into one PDF document

cfpdf action="merge" with multiple cfpdfparam tags

Merge PDF documents in a directory into one PDF document

cfpdf action="merge" directory="path"

Password-protect PDF documents

cfpdf action="protect" newUserPassword="xxxx"

Set the initial view for a PDF document

cfpdf action="processddx" with the InitialViewProfile DDX element

Create different versions of a PDF document

Duplicate function to clone PDF variables