CFCONTENT and Chrome

Ubuntu 18.04 LTS
Java 13.01
Tomcat 9.0.27
Lucee 5.3.3.62

I have basic lines of CF code to generate a PDF file. The PDF content is the web page itself.

The code works great with Safari.

User brought to my attention that it’s not working in Chrome. Attached is the screen shot of Chrome. ERR_INVALID_RESPONSE

I do rewrite my URL’s into friendly URL’s so that the user does not see variables most of the time.

Here is the PDF creation code. It is in my /index.cfm file. It is triggered by a URL variable:

"https://www.siteName.com/nice-url/?createPDF"

Code:

<cfheader name="Content-Disposition" value="attachment;filename=#title#.pdf">
<cfcontent type="application/pdf">
<cfdocument format="pdf" pagetype="letter" orientation="portrait">
	some text and stuff
</cfdocument>

I do not understand why Chrome and FireFox choke on this.

I just answered my own question which I suspected but needed someone else to hold my hand and tell me it’s going to be OK. :wink:

Only change:

statusCode="200"

As in:

<cfheader name="Content-Disposition" value="attachment;filename=#title#.pdf" statusCode="200">

try

`Attachment;filename="#local.filename#.png"’

note the double quotes around filename, single quotes around filename cause problems

1 Like