how to save pdf on server map path using iTextsharp

谁说我不能喝 提交于 2019-12-01 08:06:36
Bruno Lowagie

You are currently writing the document to the following output stream: Response.OutputStream

Once you do pdfDoc.Close();, the PDF bytes are gone.

If you want to save the PDF to the server, then you need to replace the following line:

PdfWriter.GetInstance(pdfDoc, Response.OutputStream);

With this line:

PdfWriter.GetInstance(pdfDoc, new FileStream(context.Server.MapPath("~") + "mypdf.pdf");

Now your bytes won't be sent to the browser, but the PDF will be created on your server.

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