Need a workaround for cfdocument scale

Since upgrading to Lucee my cfdocument scales the page up about 30%. This makes the pdf document too big to print and instead of 1 page it is now 2 pages. Because the pdf needs to mimic a government document this won’t work. Also, the end users are not particularily computer saavy and telling them how to print an html document isn’t a good answer either. Here is a blank version of the page before it is populated with the student information: https://onlinenailclass.com/pdftest.cfm

Is there a workaround for cfdocument scale=“” ? And yes, I did add this.pdf.type = “classic”; to my application .cfc but got this error:

Message: class sun.net.www.protocol.https.HttpsURLConnectionImpl cannot be cast to class com.sun.net.ssl.HttpsURLConnection (sun.net.www.protocol.https.HttpsURLConnectionImpl and com.sun.net.ssl.HttpsURLConnection are in module java.base of loader ‘bootstrap’)

Don’t forget to tell us about your stack!

OS: ??? Windows 2012
Java Version: 11.0.7 (AdoptOpenJDK) 64bit
Tomcat Version: Apache Tomcat/9.0.35
Lucee Version: Lucee 5.3.7.48

Maybe there are others with more experience with pdf than I have. Maybe @Jamo can help a little, because I know from this Stackoverflow post that he has created a customtag with a pdf commandline tool in the past. Sure there is a way to get this working.

1 Like

Tweaking the CSS has worked for me in the past to solve this kind of issue. I found two things to be really effective when dealing with CFDOCUMENT:

  • Use inline CSS instead of references to external stylesheet files.
  • Define the width of your document / paper size both like this:
<html>
<head>
<style type="text/css">
html, body { width:210mm; padding:0; margin:0; }
...
</style>
</head>
<body>
<div style="position:relative; top:0mm; left:0mm; width:210mm;">
...
</div></body></html>

Hope this helps.

4 Likes

if your not using the “classic” version, and instead using the new version which is flying saucer which supports css 2.1 and some higher you can try this style addtion.

<style>
			@page {
				size:11in 8.5in;
				margin: .4in .5in .75in .5in;
				@bottom-left {
					font-family: Arial, Helvetica, sans-serif;
					font-size:11px;
					content: "Some Title Here"
				}
				@bottom-right {
					font-family: Arial, Helvetica, sans-serif;
					font-size:11px;
					content: "Page " counter(page) " of " counter(pages);
				}
			}
</style>
1 Like

Thanks to everyone who contributed. The solution ended up combining the suggestions. I had to move all of the code within the cfdocument declaration, in the old days we just enclosed the body portion. Specifying the pagewidth and pageheight in the cfdocument tag worked as long as all the rest of the css was inlined. Then I found that the tables were being messed up because I hadn’t specified a font or font size - pushing the text boxes beyond the original (old) design.

Well, if things didn’t break occasionally this would be too easy and everyone would do it :slight_smile: Thanks for all your help!

2 Likes

If you have it handy would you mind posting the final code for reference?