| PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
| Download file for user https://forum.pdfsharp.net/viewtopic.php?f=2&t=2017 |
Page 1 of 1 |
| Author: | kko [ Thu May 10, 2012 11:55 pm ] |
| Post subject: | Download file for user |
Okay. I'm looking at samples of PDFSharp and I'm trying to let user to download generated file on the fly. When file is generated is actually returns aspx file instead of pdf file. here's my code: Code: Document document = CreateDocument(); document.UseCmykColor = true; const bool unicode = false; const PdfFontEmbedding embedding = PdfFontEmbedding.Always; PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding); pdfRenderer.Document = document; pdfRenderer.RenderDocument(); const string filename = "HelloWorld.pdf"; Response.ContentType = "application/pdf"; StreamWriter s = new StreamWriter(Response.OutputStream); MemoryStream stream = new MemoryStream(); Response.AddHeader("Content-Disposition", filename); pdfRenderer.PdfDocument.Save(stream, true); s.Write(stream); Response.Flush(); Response.Close(); I trued many different variations but everything seems to give me back aspx file instead of pdf. Any suggestions? |
|
| Author: | () => true [ Fri May 11, 2012 7:35 am ] |
| Post subject: | Re: Download file for user |
Where do you add the stream to the Response? Check this sample: http://www.pdfsharp.net/wiki/Clock-sample.ashx |
|
| Author: | kko [ Fri May 11, 2012 4:34 pm ] |
| Post subject: | Re: Download file for user |
Apparently, it is only happening in Chrome. IE works file and download PDF file. any suggestions? Even with Clock sample it doesn't download correctly. |
|
| Author: | () => true [ Sat May 12, 2012 4:57 pm ] |
| Post subject: | Re: Download file for user |
I tried Chrome with the Clock sample running on the empira server (there's a link in the Wiki page (see the link in my earlier post)) and it worked fine. |
|
| Author: | kko [ Tue May 15, 2012 1:00 am ] |
| Post subject: | Re: Download file for user |
I don't know what I changed, but now it works. Something like content type of response or update panel was causing issues. Thanks a lot. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|