15 March 2016
An intermediate knowledge of ColdFusion tags and other core language syntax is enough to get most out of this article.
Adobe ColdFusion Enterprise Edition (2016 release) (Download trial)
Adobe ColdFusion (2016 release) introduces several new PDF features to make coding in ColdFusion a lot easier and more productive.
The new PDF features enable developers to use their PDF’s more efficiently.
When you extract the provided zip, the folder PDFEnhancement contains various sub folders. The subfolders represent each enhancement, and contain the cfm with sample code.
- The folder ‘PDFEnhancement’ is placed in the ColdFusion webroot, and the server runs on port 8500.
- Coordinates start from bottom left corner as origin. The four coordinates are:
- lower left x
- lower left y
- upper right x
- upper right y
- A file with XFDF extension is an Acrobat Forms Document file. It stores descriptions of page form elements and their values, such as the names and values for text fields. Use the file to save form data that can be imported into a PDF document.
- PDF Metadata is the information you get about a PDF, such as, the title, the fonts used, and security settings when you view it, and so on. Some of the information is set by the PDF creatoe, and some is generated automatically.
- Attached files
- Search indexes
- Form data
- Review and comment data
- Obscured text and images
- Unreferenced data
- Overlapping objects
When dealing with classified information, sanitization reduces a document’s classification level. The unclassified document becomes ready for distribution.
From Adobe Acrobat, you can view the items that can be sanitized. Open Adobe Acrobat DC, and go to Tools. Scroll down to select Redact. Once done, you will see a box on top like this:
Click Remove hidden information to see what information can be removed. The information is shown below for the selected PDF:
Now run the file sanitize.cfm inside the subfolder Sanitization. On running http://127.0.0.1:8500/PDFEnhancements/Sanitization/sanitize.cfm, the source PDF is sanitized. The destination also contains the result PDF. Perform the same operation on the output PDF to check for hidden information.
You can find the sample cfm file in the zip. You can provide a PDF of your choice and edit the cfm file with the information.
You can export comments from a PDF document to an XFDF file. You can also import comments from an XFDF file to the PDF document.
For exporting comments, specify the source and the destination of the XFDF file. For importing comments, specify the source of the PDF file, the source of the XFDF file, and the destination path.
Exporting or importing comments is important if you need to:
- Import comments from one PDF to another.
- When you want to export comments and retain a copy before sanitizing it for public release.
Go to the subfolder ExportImportComment inside the folder PDFEnhancements. The subfolder contains two cfms with the names exportComment.cfm and importComment.cfm. There are two PDF’s, comment.pdf and noComment.pdf.
Some comments are already present in the file comment.pdf, and you can export the comments to an xfdf file. The noComment.pdf does not contain any comments. You can import the comments that you had extracted to this file.
Run the file exportComment.cfm using:
On completion, you can see new file, comment_exported.xfdf, in the same folder. If you open this file in any text editor, you can see the comments that were present in the PDF.
PDF with comments:
Comment present in xfdf file:
Now, use the same xfdf file for importing comments to the pdf with no comments. Run the file importComment.cfm using:
PDF before importComment.cfm:
PDF after running importComment.cfm:
You can see that the comments have been imported in the file.
PDF documents created in Acrobat 5.0 or later contain document metadata in XML format. Metadata includes information about the document and its contents, such as the author’s name, keywords, and copyright information, which can be used by search utilities.
For exporting metadata, specify the source of the PDF and destination of the XMP file. For importing metadata, specify the source of the PDF, the source of XMP file and the destination for the file to be placed.
The Extensible Metadata Platform (XMP) provides Adobe applications with a common XML framework that standardizes the creation, processing, and interchange of document metadata across publishing workflows. You can save and import the document metadata XML source code in XMP format, making it easier to share metadata across different documents.
Virtual file system is not supported for import and export actions.
Navigate to the subfolder ‘ExportImportMetadata’ inside ‘PDFEnhancements’. The subfolder contains two cfms with the names exportMetadata.cfm and importMetadata.cfm. There are two more PDF’s, metadata.pdf and noMetadata.pdf. There is already metadata present in the file metadata.pdf, and you can export metadata from it to an xmp file. The nometadata.pdf does not have any metadata. Import the metadata to this file.
Run the file exportMetadata.cfm using:
On completion, you can see a new file, metadata_exported.xmp in the same folder. If you open this file in any text editor, you can see the metadata that was present in the.
To check a PDF’s Metadata, click File->Properties.
PDF with metadata:
Exported metadata after running the script exportMetadata.cfm:
Use the same xmp file for importing metadata to the pdf with no metadata. Run the file importMetadata.cfm using:
PDF before running importMetadata.cfm:
PDF after running importMetadata.cfm
You can see that the metadata has been imported in the file.
You can archive pdf files. PDF/A is an ISO-standardized version of the Portable Document Format (PDF) specialized for the long-term digital preservation of electronic documents.
During PDF conversion, the file that is being processed is checked against the specified standard. PDF/A differs from PDF by prohibiting features ill-suited to long-term archiving, such as font linking (as opposed to font embedding).
In previous versions of ColdFusion, there was support for PDF/A-1b standard. In Adobe ColdFusion (2016 release), there is extra support for PDF/A-2b and PDF/A-3b standard.
Archiving with 2b:
Archiving with 3b:
To check the archiving of any file:
Click Tools -> Print Production -> Pre Flight -> PDF/A Compliance -> [Verify compliance with PDF/A-2b or Verify compliance with PDF/A-3b].
This determines if PDF is compliant/archived with the given standard.
The hello.pdf file uses the compliances 2b and 3b, as shown below:
Run the file standard2b.cfm inside subfolder Archiving2b, and the file standard3b.cfm inside subfolder standard3b, using the links:
After executing, again check for compliance with standards 2b and 3b. You can see it passes the compliance.
PDF after running standard2b.cfm:
PDF after running standard3b.cfm:
You can attach PDFs and other types of files to a PDF. If you move the PDF to a new location, the attachments move with it. By using cfpdfparam, you can specify the location of the attachment, the filename for the attachment, description of the attachment, encoding, and mimetype for attaching file. The files can also be attached at document level.
This is useful when along with the PDF, you also want to send some reference material such as images, text files, or even other PDF files. You can send all the files together by attaching the files inside the original PDF.
You can check the attachments in any file in Acrobat in the Attachments section. For the pdf file.pdf, we checked for the attachments as shown:
As you can see, there are no attachments right now.
Run the file addAttachment.cfm in the subfolder AddAttachment using the link:
After it has run, check again for attachments in the result file file_result.pdf. You can see two attachments being added to the original PDF:
You can apply a stamp to a PDF in the same way you can apply a rubber stamp to a paper document. You can choose from a list of predefined stamps.
Specify the page and the location to add the stamp in addition to the content and icon.
You can check the stamps in any file in Acrobat by opening up the PDF and checking for the icons which we support. As you can see below, the example PDF currently doesn’t have any stamps:
Now run the file addStamp.cfm inside the subfolder Stamp. After running the file, check the PDF again for stamps. The resultant PDF has a stamp, as shown below:
To redact a PDF in Adobe Acrobat:
Click Tools -> Redact -> Mark for Redaction. There are various options such as Text and Images, Pages and Find Text. But currently we support only Text and Images using the coordinates of the area you want to redact.
In Acrobat you just drag the area you want to redact. In ColdFusion, you specify the coordinates of the area you want to redact. The four coordinates are such as. (Lower left x, Lower left y, Upper right x, Upper right y).
Now run the file redact.cfm in the subfolder Redaction via the link:
After the file completes, open the resultant PDF to check for redacted items. You can see the following result:
The area with coordinates, 100,200,300,400 is redacted.
This document is all about the new PDF features in ColdFusion (2016 release) and how to use them. There will be more blog posts on individual features on the ColdFusion blog site. We will talk about various ways each attribute in cfpdf and cfpdfparam tag can be used in those blogs.