繁体   English   中英

如何在Winform中使用iTextSharp将HTML转换为PDF?

[英]How to convert HTML into PDF using iTextSharp in winform?

我想将HTML转换为Windows形式的PDF。 我在网上遇到了许多很棒的文章,例如:

但是他们并没有完全解决我的问题。

是否可以只传递一个HTML字符串并将其转换为Winform中的PDF?

例如 :

string html = "<table><tr><td>Arbaaz</td><tr></table>"

我可以只将此字符串传递给某些iText方法来创建PDF吗?

得到了我在这里寻找的答案..

Document document = new Document();
PdfWriter.GetInstance(document, new FileStream(Request.PhysicalApplicationPath + "\\MySamplePDF.pdf", FileMode.Create));
document.Open();
iTextSharp.text.html.simpleparser.HTMLWorker hw = 
             new iTextSharp.text.html.simpleparser.HTMLWorker(document);
hw.Parse(new StringReader(htmlText));
document.Close();

https://stackoverflow.com/a/18378661/2064292

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM