The Java Report Generator by Big Faceless Organization (BFO) is a commercial java library that converts XML into PDF documents. I have been using it for several months now and here are some quirks that I have came across so far:

  • XML is not HTML, some characters and tags are not compatible and here are the workarounds I use.
  • HTML XML
       
    <br> <br/>
    <font face=”Helvetica size=”12pt”>text</font> use <span style=”font: normal 12pt Helvetica;”>text</span>
    bgcolor attribute use CSS background-color
    TABLE border attribute use TABLE cellborder attrbute
    tags can overlap e.g. <b><i>text</b></i> tags can not overlap e.g. <b><i>text</i></b>
  • First element in a DIV must be a tag and not a text.
  • <pdf>
        <body>
             <div>text</div> <!-- this throws an error -->
        </body>
    </pdf>
    

    must be

    <pdf>
        <body>
             <div><span/>text</div> <!-- workaround: place an empty span -->
        </body>
    </pdf>
    

  • If you are using page-break-after:avoid in succession, you need to put something in between the container elements to avoid clustering the containers together.
  • <p style="page-break-after:avoid;">
         <!-- some text here -->
    </p>
    <p style="page-break-after:avoid;">     <!-- the two p tags will be clustered together! -->
         <!-- some text here -->
    </p>
    

    must be

    <p style="page-break-after:avoid;">
         <!-- some text here -->
    </p>
    <span/> <!-- workaround: put empty span to separate the two p tags -->
    <p style="page-break-after:avoid;">
         <!-- some text here -->
    </p>
    

  • BODY tag must not be empty, if you want to output an empty PDF, put in a space using &#160; in the BODY tag.
  • In order for a table to repeat its headers across pages, it must use the thead and tbody tags and the table tag must be first level and not be enclosed in another containing tag.
Advertisement