0

I am having a bizarre issue trying to convert an HTML string to a PDF. I have tried several example for the internet and all are given me this same error on the htmlparser.Parse() method.

Here is the code:

Byte[] bytes;
StringReader sr = new StringReader(sbEmail.ToString());

var pdfDoc = new itxt.Document(itxt.PageSize.LETTER_LANDSCAPE, 15, 15, 0, 0);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
using (MemoryStream memoryStream = new MemoryStream())
{
    PdfWriter writer = PdfWriter.GetInstance(pdfDoc, memoryStream);
    pdfDoc.Open();

    htmlparser.Parse(sr);
    pdfDoc.Close();

    bytes = memoryStream.ToArray();
    memoryStream.Close();
}

There is no physical file path involved yet. So how can there be a problem with a file path?

1 Answer 1

1

Maybe this, can help you: https://stackoverflow.com/a/12181998/9492698

It's about HTMLWorker is deprecated and you can use XMLWorker instead. See here for more advanced usage of XMLWorker: info

Sign up to request clarification or add additional context in comments.

1 Comment

XMLWorker is deprecated, you can use iText 7 + pdfHTML instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.