ColdFusion has introduced the high quality PDF generation capability from HTML using WebKit through various enhancements made to the <cfdocument> tag. However, these enhancements have been removed from the <cfdocument> tag in the beta release and hence this tag will function exactly in the same way as how it was functioning in ColdFusion 10.
To generate high quality PDFs from HTML documents, 2 new tags, <cfhtmltopdf> and <cfhtmltopdfitem> have been introduced in the beta release. This document describes the usage and functionalities of these tags.
Terminology
The following terms are the commonly used in <cfhtmltopdf> (WebKit):
- Service - Refers to the process which carries out series of activities to convert HTML documents to PDFs.
- Service Manager - Manages the PDF generation service processes, monitors the service process states, spawns new processes for conversions, and facilitates recycling of processes.
- WebKit - Is a layout engine software designed to allow web browsers to render web pages.
System requirements
PDF generation is supported on both Windows and Linux operating systems. On Windows, there are no additional requirements for generating PDFs. On Linux, ensure that the following additional requirements are met:
Additional package requirements
On Linux platforms, install the following additional packages:
glibc.i686
zlib.i686
libX11.i686
ia32-libs
expat.i686
freetype.i686
X Window System
nss-softokn.i686
libxcb.i686
libXau.i686
libXext.i686
libSM.i686
libXrandr.i686
libXrender.i686
libXinerama.i686
For instance, you can use YUM to install these packages as shown below:
$ yum install glibc.i686 |
Additional font requirements
Also, you need to install a few required fonts for generating PDFs on Linux. To install the fonts, perform the following tasks:
- In your browser, open websitehttp://cgit.freedesktop.org/xorg/font/ibm-type1/
Download the compressed filefont-ibm-type1-1.0.3.tar.gz or font-ibm-type1-1.0.3.zip.The compressed file contains the required fonts.
Extract the downloaded zip file to the/usr/share/fonts directory.
The new <cfhtmltopdf> tag
<cfhtmltopdf> creates high quality PDF output from a text block containing CFML and HTML using the PDF Service Manager.
The WebKit implementation for <cfhtmltopdf> is referred as PDFG (acronym of PDF Generator) which is shipped as part of the Jetty installer. The component running inside the Jetty server is referred as the service manager, which takes request for PDF conversion from one or many ColdFusion server/s.
The WebKit implementation for <cfhtmltopdf>:
- Encapsulates the PDF conversion library.
- Performs HTML to PDF conversion in process.
See <cfhtmltopdf> and <cfhtmltopdfitem>.
Using the remote PDF service manager
You need to use a remote PDF service manager instead of the local PDF service manager due to the following reasons:
- When the ColdFusion Server is running on an OS not supported by the local PDF service manager
- When performance of the local ColdFusion Server is critical as PDF generation is a CPU intensive operation.
- When you want to distribute the load of generating the PDFs for maximum throughput.
Adding and editing the PDF service manager
From the Administrator console, click Data & Services > PDF Service.
You can add or edit a PDF service manager by providing the name, host name, port, and other configuration details.