Copy link to clipboard
Copied
We are using ColdFusion 2018, update 13. Our setup is that we are an internal shop with a production environment, test environment and the each developer has a local development environment on our PC's.
We have a situation where a colleague is using a CFDocument tag which formats and generates the pdf great on a few of the development environments, but does not on all. The formatting is also not working on our test or production environment.
Below is the cfdocument tag with
<cfdocument format="pdf" pagetype="A4" orientation="portrait" fontEmbed="true" unit="cm" localUrl="true" filename="#somefilename#.pdf" overwrite="yes" marginLeft="0" margintop="0" marginright="0" marginbottom="0">
<div> some formatted html </div>
</cfdocument>
1 Correct answer
Thanks for the suggestion. I took some time yesterday to switch over to <cfhtmltopdf> and to rework the html that was being used to generate the pdf. It seems to work now on my development and our test environment. There is still the question as to why it worked on some environments, but not all, but for now I think we will move forward with this solution. If we run into similar issues in the future and find a solution to root cause, I will be sure to post it here. Thanks again for your suggesti
...Copy link to clipboard
Copied
Are you implying that they are all at that same update 13? And what is the Java version that Cf reports using? Is THAT identical on each?
Finally, within the html inside the cf document, see if there references to urls, such as in img src, script src, link rel, etc. Then take those urls and browse them in a browser on each machine. I suspect you will find one or more fails on different ones.
More to the point, setup a cf page to do cfhttp calls to the urls, and check the result of those. Under the covers, the cfdocument does essentially this in trying to obtain the files. (It will not do it for files without full urls, since you are using the localurl attribute.) Again I suspect you'll find that one or more of these fail on the different machines.
The question will then be why they fail, on some machines, whether from a browser on the machine or from within cf. There can be many explanations. It's possible that the error you get in requesting the files individually will tell you the problem. And if the failure is ONLY within cf (the cfhttp) and NOT in a browser on the machine, I'd again suspect a possible difference in the Java version used by cf, especially if the urls are https urls.
Let us know what you find.
/Charlie (troubleshooter, carehart. org)
Copy link to clipboard
Copied
Thanks for the quick reply, Charlie. I have confirmed that we are using the same Java version (10.0.1) on all CF instances. I have also confirmed that we are not including any url references to external source code, images, etc.
Do you have any other suggestions for us to look at?
Thank you.
Copy link to clipboard
Copied
ColdFusion 2018 on Java 10.0.1? Is that a typing error? CF2018 should currently be on Java 11, the latest version of which is JDK 11.0.14. Go to the ColdFusion Downloads page and scroll to the bottom.
Copy link to clipboard
Copied
That is correct, Java 10.0.1 and CF 2018. Here's what I tried. On a working environment on java 10.0.1, I downloaded java 11.0.14 and pointed CF's java virtual machine path to this version. The result, it broke the pdf output - it behaved the same as the other broken environments. I pointed back to 10.0.1 which worked on this environment just mintues before and it's now broken even using that version of java.
Copy link to clipboard
Copied
Oh, not good.
Then you should be able to find clues in the logs. Please have a look at the log files and share any relevant entries with us.
Copy link to clipboard
Copied
I am unable to see the difference between the 2 documents you've shown. That is because I don't know what to look for.
Could you please explain:
- Which cfdocument setting you are talking about, the values you use and the effect you expect.
- What is not working (as you would expect) .
Copy link to clipboard
Copied
1. We don't know that is a specific cfdocument attribute. I would assume, since it formats fine in some environments and not others, it's not an attribute per say that is causing the issue.
2. If you look at the page breaks, you will notice that in screen shot 1 it is cleaner looking. In screen shot 2, the text runs into the subsequent page without any formatting with respect to page breaks and margins.
Copy link to clipboard
Copied
If you want more control of the PDF settings and consistency, use wkhtmltopdf instead. To see actual code examples, type wkhtmltopdf in the search bar at the top of this page.
Copy link to clipboard
Copied
Thanks for the suggestion. I took some time yesterday to switch over to <cfhtmltopdf> and to rework the html that was being used to generate the pdf. It seems to work now on my development and our test environment. There is still the question as to why it worked on some environments, but not all, but for now I think we will move forward with this solution. If we run into similar issues in the future and find a solution to root cause, I will be sure to post it here. Thanks again for your suggestions and help.
Copy link to clipboard
Copied
Thanks for the update and for sharing your solution.

