簡體   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