C# 使用iTextSharp将pdf显示到网页?
我正在使用iTextSharp生成pdf。我想显示在网页上,让用户保存它从在线pdf查看器。dynamicpdf有一个drawtoweb()方法,但它不是免费使用的,我无法使用iTextSharp找到相同的功能。如何显示pdfC# 使用iTextSharp将pdf显示到网页?,c#,asp.net,pdf,pdf-generation,itextsharp,C#,Asp.net,Pdf,Pdf Generation,Itextsharp,我正在使用iTextSharp生成pdf。我想显示在网页上,让用户保存它从在线pdf查看器。dynamicpdf有一个drawtoweb()方法,但它不是免费使用的,我无法使用iTextSharp找到相同的功能。如何显示pdf string newFile = "Pdf Document.pdf"; Document doc = new Document(); PdfWriter writer = PdfWriter.GetInstance(doc, new Fi
string newFile = "Pdf Document.pdf";
Document doc = new Document();
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(newFile, FileMode.Create));
doc.AddCreator("Myself");
doc.AddTitle("Sample PDF Document");
doc.Open();
doc.Add(new Paragraph("Hello, World!"));
doc.Close();
有什么原因不能像其他网站那样显示PDF?只需将生成的文件作为带有正确元数据的响应流发送给用户。它将在默认的PDF查看器中自动打开,最有可能在浏览器中打开。
据我所知,这正是它正在做的 更新:
一些研究提出了这样的解决方案:
将iframe添加到网页:
<IFrame runat="server" id="iframepdf">
</IFrame>
看看我最后是怎么买了dynamicpdf的许可证的。它比itextsharp更容易使用。也许吧。我该怎么做呢?我正在查看Response.TransmitFile,但它不接受Response.TransmitFile(doc);或回复。传输文件(“Pdf Document.Pdf”);谢谢,但是我在iframe中找不到资源错误。
iframepdf.Attributes.Add("src", "showpdf.ashx?pdf=" + xyz);