HTMLParser 只转换文件的第一行
我正在使用 iText for .NET 将 HTML 转换为 PDF。
我正在使用 HtmlParser 将 HTML 页面转换为 PDF,但问题是 Htmlparser 似乎只将第一行转换为 pdf HTML 文件中的所有其他行都不会转换为 PDF。
这是代码
Document document = new Document();
final = new Document();
StreamWriter writer = new StreamWriter("fck.txt");
writer.WriteLine(FCKeditor1.Value);
writer.Close();
// Changing the extension of txt file to html file
File.Move("C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\fck.txt", "C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\fck.html");
PdfWriter writer1 = PdfWriter.GetInstance(final, new FileStream("final1.pdf", FileMode.Create));
final.Open();
HtmlParser.Parse(final, "fck.html");
final.Close();
File.Delete("C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\fck.html");
所以请帮助我 提前感谢您的帮助
I am using iText for .NET for converting HTML to PDF.
I'm using HtmlParser to convert an HTML page to PDF, but the problem is that Htmlparser only seems to convert the first line to pdf
all other lines from the HTML file are not converted to PDF.
Here is the code
Document document = new Document();
final = new Document();
StreamWriter writer = new StreamWriter("fck.txt");
writer.WriteLine(FCKeditor1.Value);
writer.Close();
// Changing the extension of txt file to html file
File.Move("C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\fck.txt", "C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\fck.html");
PdfWriter writer1 = PdfWriter.GetInstance(final, new FileStream("final1.pdf", FileMode.Create));
final.Open();
HtmlParser.Parse(final, "fck.html");
final.Close();
File.Delete("C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\fck.html");
So Please please help me
Any thank u in advance for helping
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我使用
并且效果也很好。 但我把处理放在最后
I use
and works fine too. but i put the dispose at the end
哦我终于找到了解决方案
我现在使用 htmlworker 类,而不是使用 htmlparser 类
这是新代码
Oh i finally got the solution
Instead of using htmlparser class i have now used htmlworker class
here is the new code
像这样使用它:
Use it like this: