Cfdocument creates 0 length file

We inherited a project that uses cfdocument to create a PDF document. However, it always creates a 0 length file. We backed out all of the original code and tried to make a basic file, but that too is creating a 0 length file. Here’s the code:

table { font-family:Arial, Helvetica, sans-serif; font-size: .9em; }

Test

Page #cfdocument.currentpagenumber#

This is a pretty high-priority project so we need to get this rectified ASAP.

Thanks,
Harry

Hi Harry. Which version of Lucee? And if 5+, which PDF extension version?

Can you post the basic file generation code?

We just updgraded from 5.1.3.18 to 5.2.3.35. The PDF extension was 1.0.0.62 when we saw the issue, and we just upgraded to 1.0.0.66 and it still remains. The file generation code was in my original post.

Thanks,
Harry

I’m not seeing it. Can you post the full cfdocument call? Use the preformatted text button </> so it renders properly as code.

<cfsetting showdebugoutput="yes">
<cfparam name="inItemId" default="16850">

<style>
	table { font-family:Arial, Helvetica, sans-serif;
	font-size: .9em;
	}
</style>

<cfdocument format="pdf">

<cfdocumentsection>

<cfoutput>
<h2>PDF Test</h2>
</cfoutput>

</cfdocumentsection>

</cfdocument>

I can’t replicate the issue with Lucee 5.2.35 via commandbox. Your code produces the PDF as expected containing a heading “PDF test”.

Can you give more details of your environment? OS? Java version? Java servlet container (e.g. Tomcat)? Web server front end (e.g. Apache)?

We’re on RHEL 7.4 using Apache. Here’s the output from the tomcat’s version.sh:

Server version: Apache Tomcat/8.5.11
Server built: Jan 10 2017 21:02:52 UTC
Server number: 8.5.11.0
OS Name: Linux
OS Version: 3.10.0-693.2.2.el7.x86_64
Architecture: amd64
JVM Version: 1.8.0_144-b01
JVM Vendor: Oracle Corporation

We have Apache forwarding tomcat/CFM request to the tomcat instance on port 8009.

Let me know if you need anything else.
Harry

Code works fine for me. As the file is 0 bytes, could this me a permission issue?

1 Like

I suppose it could be. But I have my browser set to download PDFs right now as a test. Where is the PDF being created on the server? I’m assuming its in the web application’s main folder, which is set to 775 right now and owned by root. Perhaps I need an ACL or something for the apache user?

Thanks,
Harry

As a test, I created a subfolder under the applications main area called pdf, and gave it 775 with apache.apache as the owner. I then modified the tag to include a filename: filename=“pdf/printItem.pdf”. When I run it, I get:

Lucee 5.2.3.35 Error (java.lang.NoClassDefFoundError)
Could not initialize class sun.awt.X11.XToolkit

Why would that be?

Thanks,
Harry

OK, so I made the web application be owned by apache:apache, and now the PDF is created and displayed. So it was permissions related. Thanks for all of the help!

Harry

1 Like

OK, small wrinkle: I made the same permissions changes on the production server, and the PDFs don’t come out there. Any thoughts as to why?

Thanks,
Harry

Did you get to the bottom of this? Having the same issue…