使用ItextSharp将HTML字符串转换为PDF [英] Convert HTML string to PDF using ItextSharp

查看:85
本文介绍了使用ItextSharp将HTML字符串转换为PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

帮助我使用ItextSharp

解决方案

将HTML字符串转换为PDF嘿!为什么不试试谷歌它会给你很多文章,学习如何使用<$ c将 HTML 字符串转换为 PDF $ c> ITextSharp 您可以从 here [ ^ ]

如果您已尝试过某些问题,请与我们分享您的努力,我们将尽力解决。


请参阅 http://kuujinbo.info/iTextSharp/tableWithImageToPdf.aspx [ ^ ] - 这个演示可以提供帮助。


< blockquote> private void ConvertHtmlToPdf()

{

StringBuilder sbHtmlText = new StringBuilder();

sbHtmlText.Append(Employee信息);

sbHtmlText.Append(这是员工信息);



文件文件=新文件();

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(sbHtmlText.ToString()));

document.Close();

}


help me Convert HTML string to PDF using ItextSharp

解决方案

Hey! Why not try Google it will give you plenty of article to learn how to convert HTML string to PDF using ITextSharp whatever you can start from here[^]
and if you have tried something and have problem so please share your effort with us we will try to solve it.


See http://kuujinbo.info/iTextSharp/tableWithImageToPdf.aspx[^] - this demo could help.


private void ConvertHtmlToPdf()
{
StringBuilder sbHtmlText = new StringBuilder();
sbHtmlText.Append("Employee Info");
sbHtmlText.Append("Hi This is Employee Info");

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(sbHtmlText.ToString()));
document.Close();
}


这篇关于使用ItextSharp将HTML字符串转换为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆