HTMLParser only converts the first line of the file

后端 未结 3 539
误落风尘
误落风尘 2021-01-15 15:32

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

相关标签:
3条回答
  • 2021-01-15 16:05

    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

    0 讨论(0)
  • 2021-01-15 16:06

    Oh i finally got the solution Instead of using htmlparser class i have now used htmlworker class here is the new code

    ArrayList p = HTMLWorker.ParseToList(new StreamReader("fck.html"), st);
    for (int k = 0; k < p.Count; k++)
    {
        final.Add((IElement)p[k]);
    }
    final.Close();
    
    0 讨论(0)
  • 2021-01-15 16:14

    Error 1 Cannot implicitly convert type 'System.Collections.Generic.List' to 'System.Collections.ArrayList'

    Use it like this:

    List<IElement> htmlarraylist = HTMLWorker.ParseToList(new StreamReader(tempFile),new StyleSheet());
                    foreach (IElement element in htmlarraylist)
                    {
                        document.Add(element);
                    }
    
    0 讨论(0)
提交回复
热议问题