PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

Create and Open PDF Stream Document in New Web Page
http://forum.pdfsharp.de/viewtopic.php?f=2&t=2902
Page 1 of 1

Author:  mevasquez [ Fri Aug 15, 2014 9:14 pm ]
Post subject:  Create and Open PDF Stream Document in New Web Page

I am able to click on a button on my Web page to create a PDF document; however, the PDF document overides the Web Page. I want to be able to create the PDF docucment on a new page. Does anyone have sample code to do this.
Currently my code looks like this.
Code:
using (MemoryStream ms = new MemoryStream())
                {
                    myDoc.Save(ms, false);
                    byte[] buffer = new byte[ms.Length];
                    ms.Seek(0, SeekOrigin.Begin);
                    ms.Flush();
                    ms.Read(buffer, 0, (int)ms.Length);
                    Response.Clear();
                    Response.ContentType = "application/pdf";
                    Response.AddHeader("content-length", ms.Length.ToString());
                    Response.BinaryWrite(ms.ToArray());
                    Response.Flush();
                    ms.Close();
                }


Thanks,

Mike

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