0

I am trying to convert html to pdf using iText and getting below error.

Invalid span tag. Expected closing br tag

How is this an invalid xhtml ?

<span style="font-size: 10pt; line-height: 14.2667px;"><br/></span>
Naxi
  • 1,504
  • 5
  • 33
  • 72
  • 1
    I see nothing wrong with the above, at least as HTML. Are you sure that the error isn't somewhere else, and perhaps the above is being flagged as a side effect? – Tim Biegeleisen Oct 15 '18 at 04:14
  • I don't think you can put `br` inside a `span`, since it's a breaking element. `span`s are inline, and must contain only other inline elements. – superstator Oct 15 '18 at 04:17
  • *"using iText"* - how exactly? There historically are three different approaches to this, one completely deprecated due to its limitations (`HtmlWorker`), one better but still limited and now in maintenance mode (`XmlWorker`) and one fairly good and still being improved (`pdfHtml`) – mkl Oct 15 '18 at 04:27
  • @mkl I am using XMLWorkerHelper. – Naxi Oct 15 '18 at 04:37
  • You asked the same question twice: https://stackoverflow.com/questions/52812243/html-parsing-exceptions-in-itext – Amedee Van Gasse Oct 15 '18 at 08:26

1 Answers1

3

A span is an inline element, and a smallest element of xhtml tree. styling tags like <u>, <i>, <strong> can be reside there.

A <br> or a <hr> is a full width element. Hence it is suggested to use <br> inside a <div></div>

Malay M
  • 1,659
  • 1
  • 14
  • 22