XSL-FO Designer for Apache FOP

bcl_716964462.htm

16. Long texts and HTML fields

You can create mail merge letters with the FO Designer as you do in Microsoft Word. For this you need:
  • An XML file with, for example, addresses and names.
  • An a XML field which contains the letter text.

At runtime the designer will add the names and addresses by replacing placeholders in the letter text. There are 5 placeholders which are identified by using the text $1,$2,$3,$4 and $5.

We deliver 3 examples:
  • Letter.xre: uses plain text for the letter contents
  • LetterHTML.xre and LetterHTML2.xre: use HTML code within the XML file which provides rich text formatting features. Note however this will work at runtime only if you use the J4L FOP Printer server (or the WAR file in your own server).

The Letter example

As all 3 letter example the format is



A report header with the addressee data, note the new page flag to make sure each letter will be printer in as separate page:


And a detail area which contain one very large field which has been associated with the XML element /InteresetLetter/Memo




Note here the Preserve LF setting:



This setting is required, since the line feeds within the XML element need to be preserved. See XML element below:



Note the placeholders $1 and $2 in the XML file. At runtime these will be replaced by the content of the variables defined below:




This will be the output in the first page (note the placeholder replacements)


The HTML fields

Warning: the HTML conversion is only available if you use the J4L FOP printer server.

The two Letter HTML example work in the same was as the plain text example with 2 minor differences, the content of the XML file and the flags in the designer. A use case for this is the Oracle APEX Rich Text editor. A business user can utilize the editor to enter text, this will save the HTML data in a Oracle table. Later on a XSL-FO can be created based on the stored HTML field.

The LetterHTML example takes an input field an CDATA element which contain HTML code.


In this case you only need to set this flag:


The LetterHTML2.xre example has a different input element, there is no CDATA type therefore the HTML data has been escaped otherwise the XML file would be invalid


if this is the case you need to select these 2 flags



This is for example what happens if you use Oracle APEX Rich Text Editor and generate a the XML file for the field.


Please note only the following HTML tags are supported in the HTML conversion:
  • <h1>, <h2>, <h3>, <h4> , <h5> headers
  • <p> paragraph
  • <span>
  • <strong> or <b> bold text
  • <em> or <i> italic text
  • <u> underlined text
  • <big> or <small> text size
  • <br> line feed
  • <ol>/<il> bullets
  • color , font-size, font-style, font-family ,text-align attributes (for <p> and <span>)