opening PDF document from memory

不问归期 提交于 2019-12-05 12:09:28
Steve Danner

You could save the PDF to a memorystream and write it out to the browser like this.

protected void Page_Load(object sender, EventArgs e)
{
    MemoryStream ms;

    using (ms = new MemoryStream())
    {
       PdfWriter writer = PdfWriter.GetInstance(myPdfDoc, ms);

       Response.ContentType = "application/pdf";
       Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length);
       Response.OutputStream.Flush();
       Response.OutputStream.Close();

    }
}

You'll need to save it to a temporary folder, then call Process.Start on the file.

For opening/showing the PDF you could use the acrobat activex component after saving the file to a temporary folder. I could not find a free control to show PDFs in an earlier research.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!