Copy link to clipboard
Copied
I'm using cfdocument to create a pdf. Displaying the pdf in the browser works fine, but I would like to just open a download prompt when the user opens that url.
<cfdocument format="PDF" localUrl="yes" margintop="0.25" orientation="landscape">
What I tried: I followed this and added a filename: https://community.adobe.com/t5/coldfusion-discussions/how-to-use-cfdocument-create-a-pdf-file-and-sa...
But it just saves that file in a lucee temp folder.
I also tried using a header like this:
<cfdocument format="PDF" localUrl="yes" margintop="0.25" orientation="landscape"> ... Your PDF content goes here... </cfdocument> <cfheader name="Content-Disposition" value="attachment; filename=your-file-name.pdf"> <cfcontent type="application/pdf" file="#expandPath('your-file-path.pdf')#">
But it also doesn't open a download prompt.
What I want is that it opens a prompt and asks the user, where he wants to save that file.
I think you're almost there. Try something like
<cfdocument format="PDF" localUrl="yes" margintop="0.25" orientation="landscape" filename="#expandPath('your-file-path.pdf')#">
Your PDF content goes here...
</cfdocument>
<cfheader name="Content-Disposition" value="attachment; filename=your-file-name.pdf">
<cfcontent type="application/pdf" file="#expandPath('your-file-path.pdf')#">
Copy link to clipboard
Copied
I think you're almost there. Try something like
<cfdocument format="PDF" localUrl="yes" margintop="0.25" orientation="landscape" filename="#expandPath('your-file-path.pdf')#">
Your PDF content goes here...
</cfdocument>
<cfheader name="Content-Disposition" value="attachment; filename=your-file-name.pdf">
<cfcontent type="application/pdf" file="#expandPath('your-file-path.pdf')#">
Copy link to clipboard
Copied
Sorry for the late reply.
Yes it solved the issue, but I need to add that also a browser setting might overwrite the save/show decision, based on the pdf settings (at least in Chrome).
Thanks for your help!
Copy link to clipboard
Copied
Did that solve the problem?