使用iTextSharp将pdf显示到网页?

我正在使用iTextSharp生成pdf。 我想在网页上显示它,让用户从在线pdf查看器中保存它。 dynamicpdf有一个drawtoweb()方法,但它不能免费使用,我无法使用iTextSharp找到相同的function。 如何显示pdf?

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查看器中自动打开,很可能在浏览器中。
据我所知, dynamicpdf的DrawToWeb方法正是它正在做的事情。

更新:
一些研究提出了这样的解决方案:
将iframe添加到您的网页:

  

并使用PDF文件填充它:

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

请参阅如何

我最后只是购买了dynamicpdf的许可证。 使用迭代比使用itextsharp容易得多。