PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

web PDF save-as name
https://forum.pdfsharp.net/viewtopic.php?f=2&t=837
Page 1 of 1

Author:  pchilso1 [ Tue Aug 18, 2009 10:32 pm ]
Post subject:  web PDF save-as name

I have a C# .net web application that creates PDF files and serves them up to the user in a browser (works great). What I would like is when the user clicks save-as from the PDF viewer, It's alredy got a file-name all set for them. Right now, it seems to default to the .aspx page name.

Using the latest PDFsharp dll (1.30 I think - just downloaded a few days ago)

-Paul C.

Author:  mikesowerbutts [ Wed Aug 19, 2009 9:56 am ]
Post subject:  Re: web PDF save-as name

when outputting your PDF file, you can set:
Code:
Response.AddHeader("Content-Disposition", "attachment;filename="+_filename+".pdf");

where the filename var is the string you wish to save the PDF as. Please note that changing "attachment" to inline will try to open the PDF in the browser, rather than giving a Save As prompt, but I have experienced problems with this, so I stick to using attachment (as it will always use the filename you set it to, whereas inline seems to behave differently from browser to browser)

hope this helps!

Author:  pchilso1 [ Wed Aug 19, 2009 3:08 pm ]
Post subject:  Re: web PDF save-as name

Great. Thanks. That did the trick!

Is there any way to remove the extra [1] that seems to get in the filename when saved? I've seen this before making other formats. filename.pdf becomes filename[1].pdf when saving.

Author:  mikesowerbutts [ Fri Aug 28, 2009 3:00 pm ]
Post subject:  Re: web PDF save-as name

Hi,

I have not come accross a way to get rid of this - i think its something to do with how the browser is caching files - but thats a guess!

Mike

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/