Skip to main content
Legend
December 15, 2017
Question

Why Does CFHTMLTOPDF Suck?

  • December 15, 2017
  • 3 replies
  • 3777 views

We've used ColdFusion for decades and for the longest time used CFDocument for PDFs.  We still use it for some legacy jobs.  When we saw CF11 included the new CFHTMLTOPDF tag we were excited but that feeling died instantly the first time we used it.  In some instances the results were so bad we soldiered on with CFDocument.  It's been a few years and we've long since switched to using WXHTMLTOPDF.  Our PDFs come our nearly flawless now.  However, we recently were debugging a "WX" issue on a new layout we're installing and decided to re-visit CFHTMLTOPDF.  Hideous!  While we're getting about 90-95% accuracy with WX, CFHTMLTOPDF again disappoints.

ColdFusion is made by Adobe for crying out loud! 

The quality of PDFs ColdFusion produces, by the makers of Acrobat, is embarrassing.

Why has there been no CF integration with Acrobat after all these years!

Ok, rant over.

This topic has been closed for replies.

3 replies

Charlie Arehart
Community Expert
Community Expert
March 4, 2024

In case anyone finds this thread while using (or considering) CF2023 and beyond, note that CF2023 added a new underlying engine for the PDF generation done by cfhtmltopdf, and that new engine handles most HTML (including html5), CSS (including css3), javascript, SVG and such, in a way to more faithfully render PDFs, compared to the original cfhtmltopdf engine discussed in this thread (and definitely better than the old engine still underlying cfdocument--unchanged in cf2023).

 

This new engine for cfhtmltopdf is a licensed copy of the commercial engine from pdfreactor.com, and it supports embedded video, audio, flexbot layouts, css grid layouts, PDF/A confirmance options, and more. There are also some new features for its creation of headers and footers.

 

The new engine is enabled in the CF Admin "pdf service" page with a default "engine" version of 2, so there's no code change needed to leverage the new capabilities. It's still implemented as the "add on service" like has been true for cfhtmltopdf since it came out in CF11/2014. And unlike when cfhtmltopdf first came out, the new engine is supported on all platforms CF supports (windows, linux, macos, solaris). To be clear, the new engine is NOT available for CF2021 or earlier.

 

For more, see Adobe's blog posts and docs such as:

 

Finally, there's a talk on the new cfhtmltopdf and its engine from the Online CF Summit (happening last month and this month) and the recording for that session will be posted along with others over time at Adobe's youtube page, at this playlist for the online summit.

/Charlie (troubleshooter, carehart. org)
Legend
March 4, 2024

I still find running WKHTMLTOPDF does a way better job than CFHTMLTOPDF at best reproducing the original HTML, unfortunately.  Even in CF2023. 

 

Perhaps I'm missing something?  I would certainly prefer to use the CF built-in functionality but haven't found the time to work out its kinks.

 

 

Carl Von Stetten
Legend
December 15, 2017

In addition to Charlie's comments (and don't overlook the improvements between CF11 and CF2016 as he suggested), I'll add that Adobe announced a significant overhaul of CFHTMLtoPDF coming in CF2018 (aka Aether), which should significantly improve the quality of the PDFs it produces.

It's quite possible that the version of WKHTMLtoPDF that you are using is newer than the version embedded in CF11 (which CFHTMLtoPDF is using under the hood).  It might have been updated to a newer version in CF2016.

-Carl

Charlie Arehart
Community Expert
Community Expert
April 17, 2018

Following on Carl's comment: sdsinc_pmascari, have you been able to try things in CF2016 since we wrote? or on the CF2018 beta that came out yesterday?

Note that you can install CF for free (trial or developer edition), and you can install it alongside of your current CF. As long as you don't take the last step about integrating with your external web server (such as IIS or Apache), there will be no conflict. You could test against the new version using CF's built-in web server (which CF will launch at the end of the install on Windows, or show you the URL for it on Linux).

/Charlie (troubleshooter, carehart. org)
Known Participant
October 16, 2020

We are now on CF2018 (after being forced to abandon CF11 when Adobe crippled the CF11 developer edition's IP limit) ... and CFHTMLTOPDF is BROKEN.  

Give it an Hello World and it works.  Give it anything bigger and it fails with a timeout. 

Confirmed here:

https://tracker.adobe.com/#/view/CF-4208624

and there's no fix after 6 months.  By a 3rd party no less. 

Is there an alternative to CFHTMLTOPDF from JQuery, anyone else?

 

Charlie Arehart
Community Expert
Community Expert
December 15, 2017

I get that you may just want to vent, but if you’re open to fixing whatever you see as amiss, I have a few thoughts.

First, can you offer an example? Something that someone else can try, to confirm that the problem you see is indeed generic to CF and not your specific setup? And was your revisit on CF2016, with its latest update, 5? Was the “problem” you saw the same in both CF11 and CF2-16? If you can’t share code, or even a PDF to demonstrate the issue, can you explain what was “wrong” with the result?

Next, you refer to wxhtmltopdf, and wx. Did you mean wkhtmltopdf, and wk instead? I don’t ask to be snarky: I ask because CFHTMLtoPDF is indeed just Adobe’s implementation of wk. Yeah, really.

That’s all the more reason why I wonder if your issue may be about configuration. I’ve not heard of it being so terrible as you assert (though perhaps others have). Indeed, the whole reason for it being added was to do better html to pdf generation than cfdocument.

/charlie

/Charlie (troubleshooter, carehart. org)
Legend
December 15, 2017

You're right, of course, that I should show examples.  I'll give a few screenshots.

Other details: we have not yet upgraded to CF2016.  We're on CF11 latest update.  Yes, I mistyped WX when I meant WK (WKHTMLTOPDF).  Also, I'm not sure what 'configuration' issues may be at play with CFHTMLTOPDF being so bad.  I've never read anything about setting up specific CF configs to make PDFs work.

Anyway, our latest attempt was creating a PDF of a page using the Bootstrap framework, some JS created charts, and FontAwesome icons.  We are writing the entire HTML to file including all external JS and CSS calls and feeding the same file to WKHTMLTOPDF and CFHTMLTOPDF for comparison.  Same server.  These are pretty straight forward calls.  The only options for WK is the --lowquality is turned on for speed. 

Here we go....

WKHTMLTOPDFCFHTMLTOPDF

This part is nicely laid out, the fonts and font-sizes are correct and our buttons are rounded and look good.

First, the scaling and alignment is off.  I don't see a 'scale' option in the CF tag and adjusting the margins doesn't seem to help.  The fonts are wrong, as are the font sizes, and the buttons look awful.

This is 99% how we expected this table to look.

Suffice is to say, fonts and sizing are off in the whole document so this is the last I'll mention it.  The green checks and red X are FontAwesome icons.  CF can't seem to render them.

Here we have some decent looking little charts.  These are from a 3rd party JS graphing platform.

CFHTMLTOPDF has no idea how to render these.