No effect for saving PDF with saveasname


I have a cfm script that produces a PDF file to download.
the attribute saveAsName in a tag cfdocument has no effect on the downloaded file :
it’s always [the-script-name].pdf

It was working on ACF 11, not on Lucee.
What can i do ?

OS: Ubuntu Linux 18.04.5
Java Version: 11.0.7 (AdoptOpenJDK) 64bit
Tomcat Version: Apache Tomcat/9.0.35
Lucee Version:

Yes, I get the same result using the PDF extension version

Here’s a possible workaround:

saveAsName = "mypdf.pdf";
document format="PDF" name="pdfBinary"{
	WriteOutput( "Test" );
header name="Content-Disposition" value="attachment; filename=#Chr( 34 )##saveAsName##Chr( 34 )#";
content type="application/pdf" variable=pdfBinary reset="true";

Or if you prefer tags:

<cfset saveAsName="mypdf.pdf">
<cfdocument format="PDF" name="pdfBinary">Test</cfdocument>
<cfheader name="Content-Disposition" value="attachment; filename=#Chr( 34 )##saveAsName##Chr( 34 )#">
<cfcontent type="application/pdf" variable=pdfBinary reset="true">

@Laurent Looking at the lucee pdf extension source code the attribute saveAsName is not implemented. Can you file a bug here

Fine workaround !
Thank’s a lot

Filed a bug [LDEV-3781] cfdocument attribute saveAsName not implemented - Lucee

1 Like

I recommend using double quotes around the attachment file name or you’ll encounter issues when files have spaces.

<cfheader name="Content-Disposition" value="attachment; filename=""#Chr( 34 )##saveAsName##Chr( 34 )#""">
1 Like

The use of Chr( 34 ) means that shouldn’t be necessary.

Doh! You are right.

I didn’t perform the manual conversion in my head. (I’ve been using double quotes for so long as it appears more obvious.)

1 Like