RuntimeWorkerException: Invalid nested tag head found, expected closing tag meta

27,777

The error message is pretty clear, you have a <meta> tag in the header that isn't closed which is valid in HTML but not XHTML which is what you are parsing it as. You need to close those, <meta ... />

Share:
27,777
Drazen Bjelovuk
Author by

Drazen Bjelovuk

// Passion project https://bookormovie.net/

Updated on July 05, 2022

Comments

  • Drazen Bjelovuk
    Drazen Bjelovuk almost 2 years

    I'm using iText in order to convert html into a pdf, but I keep getting a RuntimeWorkerException thrown at parseXHtml. Here's my code:

    Document tempDoc = new Document();
    PdfWriter pdfWriter = PdfWriter.getInstance(tempDoc, out);
    tempDoc.open();
    XMLWorkerHelper.getInstance().parseXHtml(pdfWriter, tempDoc, new ByteArrayInputStream(html.getBytes()));
    tempDoc.close();
    

    I'm not too familiar with the differences between HTML and XHTML, so I'm at a bit of a loss as to how I should handle this. Here's the html source if it helps.

  • Drazen Bjelovuk
    Drazen Bjelovuk over 9 years
    I ended up going with JTidy to convert to xhtml, and it works pretty well.
  • mkl
    mkl over 4 years
    You can also use <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> as proposed by Chris in his answer.
  • mkl
    mkl over 4 years
    This actually has already been proposed in the accepted answer...