

The following Lucee CFML page first generates a PDF using wkhtmltopdf then, it renders that PDF document inside an iframe. As such, I'll just share the final product. There's no point in stepping through how I got here. What follows is the result of two-days of trial-and-error. Then, with this flag enabled, I was able to use the path-prefix, file:///, to embed files from the Lucee CFML server (just like we can with the CFML CFDocument tag). To do this, you have to use the following command-line option: By default, wkhtmltopdf doesn't grant access to the local file-system. Once I had my Docker playground up and running, it was time to start experimenting! What I knew I wanted to do was build an HTML document that referenced CSS files and Images on the local file-system. Generating PDFs With HTML, CSS, And wkhtmltopdf This file is what allows wkhtmltopdf to embed fonts within the generated PDF document. NOTE: The FONTCONFIG_FILE ENV variable points to a file that, in turn, points to a directory that contains True Type Fonts (TTF). which exposed localhost:8080 as the ingress to my Lucee CFML playground!

# Setup the font-configuration so that WKHTMLTOPDF knows where to locate our fonts.įONTCONFIG_FILE: "/app/wwwroot/fonts/nf" # use the CFConfig utility to configure out ColdFusion settings (such as the Admin # We are using the CommandBox image as the base for our container. With this Dockerfile in place, I created a simple docker-compose.yml file: I only have the vague notion that it's installing the wkhtmltopdf package for this particular platform.

To be clear, I don't understand the the list of apt-get packages and, I have no idea what gdebi is or what it's actually doing.
Pdfkit vs princexml install#
# Download and install wkhtmltopdf dependencies.
Pdfkit vs princexml how to#
Frankly, I don't even know how to determine which dependencies a package like I am not sure if the dependencies listed her are actually # CAUTION: The following dependencies list and installation steps have been taken from: # Prevents the keyboard from having to be configured during build. Then, I more-or-less copied the wkhtmltopdf Docker instructions from Deyan Ginev, which gave me the following Dockerfile: Now, I don't really understand the difference between "architectures" so, I just picked the first one - amd64 - and that turned out to be correct. Given this information, I was able to see that I needed to use the Ubuntu 18.04 (bionic) version with CommandBox. This gave me the following terminal output: No LSB modules are available. So, my first Dockerfile did nothing but spin-up the CommandBox base image, which I could then "bash" into and run the aforementioned command. So, I had to figure out what platform I was running on first.īased on a StackExchange post, I learned that I could run lsb_release -a to see what distribution I was using. But, I didn't know which platform the CommandBox image was actually running on - honestly, I know very little about Servers themselves. The wkhtmltopdf project provides a number of pre-compiled binaries for different platforms. And, as with my GraphicsMagick approach, my Docker container is based on the Ortus Solutions' CommandBox Docker Image for Lucee CFML 5. Just as with my GraphicsMagick exploration in Lucee CFML, I figured that the cleanest way to start playing with wkhtmltopdf would be to create a Docker container that isolates this work and allows me to easily spin-up and spin-down my experiments.

Setting Up My Docker Container / Playground As such, this weekend, I sat down and got a proof-of-concept working in Docker and Lucee CFML 5.3.4.80. Since I've been digging into PDF document generation in Lucee CFML, with varying degrees of success, I thought it was time that I try out Moberg's wkhtmltopdf recommendation. Among them is wkhtmltopdf, which is a tool that can convert HTML and CSS to PDFs using the Qt WebKit rendering engine. A few months ago, James Moberg listed out a good number of Command-Line utilities that he uses in ColdFusion.
