Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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....
WKHTMLTOPDF | CFHTMLTOPDF |
---|---|
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. |
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
The initial poster recommended WKHTMLTOPDF. I've been using it since ColdFusion 8 and highly recommend it. (I even created a CFML-powered API endpoint for PDF generation similar to the the service CKEditor provides for instant PDF generation.)
I hadn't seen this CFHTMLTOPDF bug reported before. Upon reviewing the uploaded HTML, I can verify that it's not a valid "HTML document". (It's just an HTML fragment.) A valid HTML document requires HTML declaration, head and body tags. When generating HTML, we always post process it using jsoup to ensure that the HTML is validly formatted and nested.
Even though it's not a valid HTML document, I tested the "httest_Content_NotWorking.html" file (shared from the bug report) using WKHTMLTOPDF and it took 1.5 seconds to successfully convert to PDF format using WKHTMLTOPDF... even with missing declaration, head and body tags.
Copy link to clipboard
Copied
Do you execute it by simply stating
<cfWKHTMLTOPDF destination="c:\???\???\file.pdf" #content#>
I'll give it a shot anyway.
Copy link to clipboard
Copied
Nope.
Can you show me in a .CFM how to execute it?
Copy link to clipboard
Copied
Hi Coder1957**,
By naming it cfWKHTMLTOPDF you mix the two. The names are:
Copy link to clipboard
Copied
In that thread Charlie says that WKHTMLTOPDF and htmltopdf are one and the same.
Nor did I see an example as to how to "use it in a sentence"
Copy link to clipboard
Copied
Please confirm whether or not you understand my last post. There I explain why the name you had used, "cfwkhtmltopdf", won't work. That is because it is neither "cfhtmltopdf" nor "wkhtmltopdf".
My last post in that previous thread in this very forum contains an example of how to use WKHTMLToPDF .
Copy link to clipboard
Copied
> coder1957**: In that thread Charlie says that WKHTMLTOPDF and htmltopdf are one and the same.
No, I don't think he does. At least not from the way I read it.
He says, "the CFHTMLTOPDF tag that was added in CF11--and which ends up using WKHTMLTTOPDF under the covers".
He then adds a word of caution, "I realize someone may well pipe up with some scenario in which cfhtmltopdf did not work for them, while talking directly to wkhtmltopdf did. One thing to note is that the library surely has changed since CF11, and may have within updates to CF 11, 2016, or 2018".
In any case, that is just my reading of it. I cannot presume to speak for Charlie.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.