Skip to content

Table-related infinite loop triggered in versions >= 1.0.2 #615

Closed
@bsmelo

Description

@bsmelo

Hello!

We found an infinite loop being triggered using openhtmltopdf 1.0.4. Actually, after some tests, we found our code succeeds using openhtmltopdf 1.0.1, but from 1.0.2 onwards it enters the infinite loop. The smallest input we could construct was:

<table style="float:left; margin:1px;">
   <tr></tr>
</table>
<p>NOME</p>

Since we have a preprocessing phase using jsoup, the actual input to openhtmltopdf is:

<html>
 <head>
  <style>  body { word-wrap: break-word } table { width: 100% }  </style>
 </head>
 <body>
  <table style="float:left; margin:1px;"> 
   <tbody>
    <tr></tr> 
   </tbody>
  </table> 
  <p>NOME</p>
 </body>
</html>

We still couldn't figure out what exactly causes the program to loop, but if we remove any piece of the above input (e.g.: float:left; or even <p>NOME</p>) it doesn't loop at all. The following code can be used to reproduce the issue:

            ByteArrayOutputStream streamPdfa = new ByteArrayOutputStream();
            PdfRendererBuilder geradorPdf = new PdfRendererBuilder();
            htmlConteudoAjustado = "<THE INPUT ABOVE>";
            
            geradorPdf.withProducer("Nome Produtor");
            geradorPdf.useFastMode();
            geradorPdf.withHtmlContent(htmlConteudoAjustado, "");
            geradorPdf.toStream(streamPdfa);
            geradorPdf.run();

We're introducing a local, pre-processing fix, while also debugging and trying to figure out if we can contribute a fix at the openhtmltopdf side.

Thanks for the lib!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions