0

I found this: How to set the name of the file when streaming a Pdf in a browser?

Same question exempt I am using abcpdf in Coldfusion. So the question will be:

I am use abcpdf in coldfusion, to generated Pdfs and just stream the output to the user. My code looks like the following:

<cfscript>
theDoc = createObject("com","ABCpdf6.doc");
theDoc.rect.SetRect(10, 10, 600, 777); 

theID = theDoc.AddImageHTML(strHTML, true);

while(theDoc.Chainable(theID))
{
theDoc.Page = theDoc.AddPage();
theID = theDoc.AddImageToChain(theID);
}

page_count = theDoc.PageCount;
the_data = theDoc.getData();

enter code here



// Release the Objects
theDoc.clear();
ReleaseComObject(theDoc);

</cfscript>

After this code runs it streams the Pdf to the browser opening up Acrobat Reader. Works great!

My problem is when the user tries to save the file it defaults to the actual file name ... in this case it defaults to myPagename.pdf. Is there anyway I can set this? If so, how?

Any help would be appreciated.

Community
  • 1
  • 1
Jenny
  • 1
  • 1

1 Answers1

0

You can do it outside ABC like this:

var ms = new MemoryStream();
theDoc.Save(ms);
String fileName = name + ".pdf"; // where "name" is the default name
return File(ms, "application/pdf", fileName);
Oleg
  • 1,291
  • 13
  • 16