You use the cfpdf tag to assemble PDF documents in ColdFusion. The tag provides several actions for creating unified output files from multiple sources, as the following table shows:
Action |
Description |
---|---|
addWatermark |
Adds a watermark image to one or more pages in a PDF document. |
deletePages |
Deletes one or more pages from a PDF document. |
getInfo |
Extracts information associated with the PDF document, such as the author, title, and creation date. |
merge |
Assembles PDF documents or pages from PDF source files into one output file. |
processddx |
Extends the cfpdf tag by providing a subset of AdobeĀ® LiveCycle™ Assembler functionality. This is the default action. |
protect |
Password-protects and encrypts a PDF document. |
read |
Reads a PDF document into a ColdFusion variable. |
removeWatermark |
Removes watermarks from specified pages in a PDF document. |
setInfo |
Sets the Title, Subject, Author, and Keywords for a PDF document, |
thumbnail |
Generates thumbnail images from specified pages in a PDF document. |
write |
Writes PDF output to a file. Also use to flatten forms created in Acrobat and linearize documents. |
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:
Function |
Description |
---|---|
Determines whether a DDX file, pathname, and instructions are not null and are valid. Also verifies that the schema used for the DDX instructions is supported by ColdFusion. |
|
Determines whether a PDF source file, pathname, 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:
Task |
Action |
---|---|
Add a generated table of contents to a PDF document |
cfpdf action="processddx" with the TableOfContents DDX element |
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 |
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=" |
Change user permissions on a PDF document |
cfpdf action="protect" newOwnerPassword= |
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=" |
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=" |
Password-protect PDF documents |
cfpdf action="protect" newUserPassword=" |
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 |