Skip to main content
2 de 2
replaced http://stackoverflow.com/ with https://stackoverflow.com/

https://stackoverflow.com/questions/2822843/itextsharp-html-to-pdf

pelo que vi parece haver algum bug com isso.. ai nessa resposta tem uma solucao:

 Document document = new Document();
    try
    {
        PdfWriter.GetInstance(document, new FileStream("c:\\my.pdf", FileMode.Create));
        document.Open();
        WebClient wc = new WebClient();
        string htmlText = wc.DownloadString("http://localhost:59500/my.html");
        Response.Write(htmlText);
        List<IElement> htmlarraylist = HTMLWorker.ParseToList(new StringReader(htmlText), null);
        for (int k = 0; k < htmlarraylist.Count; k++)
        {
            document.Add((IElement)htmlarraylist[k]);
        }

        document.Close();
    }
    catch
    {
    }
sir_ask
  • 402
  • 2
  • 5