PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 2:07 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: output stream filename
PostPosted: Wed Jul 29, 2009 9:25 am 
Offline
Supporter

Joined: Fri May 15, 2009 3:28 pm
Posts: 96
Hi All,

I am outputting my PDF to the browser using Response. Its all working perfectly except I cant get the PDF to use the filename I want it to - it always comes up with a few random numbers/letters. I have tried using
Code:
Response.AddHeader("Content-Disposition", "inline;filename=myPDFFilename.pdf")

when creating the PDF, but it doesnt seem to make any difference in Firefox, but works in IE 7...

here is the code in my save function:
Code:
protected void savePDF(PdfDocument pdfDocument)
{
            // Send PDF to browser
            MemoryStream stream = new MemoryStream();
            pdfDocument.Save(stream, false);
            Response.Clear();
            Response.ContentType = "application/pdf";
            Response.AddHeader("Content-Disposition", "inline;filename=myPDFFilename.pdf");
 
            Response.AddHeader("content-length", stream.Length.ToString());
            Response.BinaryWrite(stream.ToArray());
            Response.Flush();
            stream.Close();
            Response.End();
        }

Can I set a property of the PdfDocument object I am saving which will also set the filename? or does it have to be specifically in the Response.AddHeader()?

Also, if i change the "inline" to "attachment", the filename i set appears in the save as dialog, even in FF!

Mike


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 400 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group