HTMLParser只转换文件的第一行 [英] HTMLParser only converts the first line of the file

查看:107
本文介绍了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();
//将txt文件的扩展名更改为html文件
File.Move(C:\\ Program Files \\ Microsoft Visual Studio 9.0\\Common7\\IDE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
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\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\');

所以请请帮助我
提前感谢您的帮助

解决方案

我使用

  StreamReader tempReader = new的StreamReader(TEMPFILE); 

ArrayList p = HTMLWorker.ParseToList(tempReader,st); (int k = 0; k< p.Count; k ++)
{
documento.Add((IElement)p [k]);


}

tempReader.Dispose();
documento.Close();

并且工作正常。但我把结尾放在

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

解决方案

I use

StreamReader tempReader = new StreamReader(tempFile);

        ArrayList p = HTMLWorker.ParseToList(tempReader,st); 

        for (int k = 0; k < p.Count; k++) 
        {
            documento.Add((IElement)p[k]); 
        }

        tempReader.Dispose();
        documento.Close();

and works fine too. but i put the dispose at the end

这篇关于HTMLParser只转换文件的第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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