title: Infinite table loop; row content is larger than the page (for instance because you didn't scale an image)
body: <p>I had used Itext library for converting table in html to pdf and getting "Infinite table loop; row content is larger than the page (for instance because you didn't scale an image)" error. Please find my code below.</p>
  
  <pre><code>public static File createPDF(File outputDir, Context context) {
      Document document = null;
      String htmlStr = "&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;div class="two-col-pair-one"&gt;&lt;div align="center"&gt;1:  9_ITEM&lt;/div&gt;&lt;div class="row-odd"&gt;
  &lt;div class="packet-font"&gt;
  &lt;div class="two-col"&gt;Cust. Name&lt;/div&gt;
  &lt;div class="two-col"&gt;Gg&lt;/div&gt;
  &lt;/div&gt;
  &lt;div style="clear:both"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="row-even"&gt;
  &lt;div class="packet-font"&gt;
  &lt;div class="two-col"&gt;Org. City&lt;/div&gt;
  &lt;div class="two-col"&gt;D&lt;/div&gt;
  &lt;/div&gt;
  &lt;div style="clear:both"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="row-odd"&gt;
  &lt;div class="packet-font"&gt;
  &lt;div class="two-col"&gt;Dest. City&lt;/div&gt;
  &lt;div class="two-col"&gt;D&lt;/div&gt;
  &lt;/div&gt;
  &lt;div style="clear:both"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="row-even"&gt;
  &lt;div class="packet-font"&gt;
  &lt;div class="two-col"&gt;Product Type&lt;/div&gt;
  &lt;div class="two-col"&gt;Domestic Moving&lt;/div&gt;
  &lt;/div&gt;
  &lt;div style="clear:both"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="row-odd"&gt;
  &lt;div class="packet-font"&gt;
  &lt;div class="two-col"&gt;Trans.Mode&lt;/div&gt;
  &lt;div class="two-col"&gt;Road&lt;/div&gt;
  &lt;/div&gt;
  &lt;div style="clear:both"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="row-even"&gt;
  &lt;div class="packet-font"&gt;
  &lt;div class="two-col"&gt;Description&lt;/div&gt;
  &lt;div class="two-col"&gt;Fridge - Regular&lt;/div&gt;
  &lt;/div&gt;
  &lt;div style="clear:both"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="two-col-pair-two"&gt;&lt;/div&gt;
  &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;";
       File pdfFile = null;
      String CSS =    body
  {
   font-family: Verdana;
   font-size: 13px;
   font-weight: bold;
  }
  @page {
     size: A4;
  }
  @page {
   margin: 0px;
  }
  @page :left {
   margin: 0px;
  }
  @page :right {
   margin: 0px;
  }
  @page :right {
   margin: 0px;
  }
  .page-break{
     page-break-after: always;
  }
  table{
     border-collapse: collapse;
  }
  table, td, th{
     border: 3px dotted black;
     width: auto
  }
  td{
     height: 5.75cm;
     width: 5.1cm;
  }
  tr{
     page-break-inside:avoid;
     page-break-after:auto;
  }
  .two-col{
   position:relative;
   float: left;
   width: 47%;
  }
  .two-col-pair-one{
   float: left;
   width: 100%;
   padding:5px;
  }
  .two-col-pair-one-qr{
   float: left;
   width: 100%;
   padding:5px;
  }
  .two-col-pair-two{
   float: left;
   width: 0%;
  }
  .two-col-pair-two-qr{
   float: left;
   width: 100%;
  }
  .row, .row-odd, .row-even, .row-default{
   width: 100%;
   display:block;
  }
  .container{
   display: inline-block;
   vertical-align: middle;
   width: 99%;
   max-height:100%
   margin-left: auto;
   margin-right: auto;
  }
  @media(max-width:800px){
    .thumbnails img {
    height: 50px;
    border: 1px solid #555;
    margin: 6px 6px 0 0;
    }
  }
  @media(max-width:480px){
    .thumbnails img {
    height: 30px;
    border: 1px solid #555;
    margin: 4px 4px 0 0;
    }
  }
  @media(orientation:landscape){
    .container{
    width:90%;
    }
    .thumbnails{
     position: fixed;
     top: 0;
     right:0;
     height: 100%;
    }
  };
      try {
          pdfFile = new File(outputDir.getAbsolutePath() + File.separator + String.format(Locale.ENGLISH, "%s_%s.pdf", "Packet_labels", "_" + job.getId()));
          pdfFile.getParentFile().mkdirs();
          document = new Document(PageSize.A4, 0, 0, 0, 0);
          PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(pdfFile));
          document.open();
          PdfPTable table = getTable(CSS, htmlStr);
          document.add(table);
          document.close();
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      } catch (Exception e) {
          Log.d("PDF Exception", "" + e);
          e.printStackTrace();
      }
      return pdfFile;
  }
  
  public static PdfPTable getTable(String CSS, String table) throws IOException {
      CSSResolver cssResolver = new StyleAttrCSSResolver();
      CssFile cssFile = XMLWorkerHelper.getCSS(new ByteArrayInputStream(CSS.getBytes()));
      cssResolver.addCss(cssFile);
  
      // HTML
      HtmlPipelineContext htmlContext = new HtmlPipelineContext(null);
      htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory());
      htmlContext.setImageProvider(new Base64ImageProvider());
  
      // Pipelines
      ElementList elements = new ElementList();
      ElementHandlerPipeline pdf = new ElementHandlerPipeline(elements, null);
      HtmlPipeline html = new HtmlPipeline(htmlContext, pdf);
      CssResolverPipeline css = new CssResolverPipeline(cssResolver, html);
  
      // XML Worker
      XMLWorker worker = new XMLWorker(css, true);
      XMLParser p = new XMLParser(worker);
      p.parse(new ByteArrayInputStream(table.getBytes()));
  
      return (PdfPTable)elements.get(0);
  }
  </code></pre>
  
  <p>Thanks in advance.</p>