No effect for saving PDF with saveasname

Hello,

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: 5.3.8.189

Yes, I get the same result using the PDF extension version 1.0.0.97-RC.

Here’s a possible workaround:

<cfscript>
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";
</cfscript>

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 https://luceeserver.atlassian.net/?

Fine workaround !
Thank’s a lot

Filed a bug [LDEV-3781] - 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

Now the saveasname attribute implemented in cfdocument from PDF extension version 1.1.0.3-SNAPSHOT.

https://download.lucee.org/#66E312DD-D083-27C0-64189D16753FD6F0

1 Like