Displaying a pdf to webpage using iTextSharp?

我怕爱的太早我们不能终老 提交于 2019-12-05 19:31:10
Daniel Hilgarth

Is there a reason you can't just display the PDF like any other website does? Just send the generated file to the user as a response stream with the correct meta data. It will open automatically in its default PDF viewer, most likely inside the browser.
As far as I understand the DrawToWeb method of dynamicpdf that's exactly what it is doing.

UPDATE:
Some research brought up a solution like this:
Add an iframe to your web page:

<IFrame runat="server" id="iframepdf">
</IFrame>

and populate it with the PDF file:

iframepdf.Attributes.Add("src", "showpdf.ashx?pdf=" + xyz);

See How <iframe src can read local temp file? for more info.

I ended up just buying a license to dynamicpdf. It was much easier to work with than itextsharp.

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