14 Create RTF Templates

This topic describes the concepts of associating XML data to layout elements in an RTF report template. It describes basic and advanced techniques for creating complex and highly conditionalized report formats.

Use Barcode Fonts in Reports

Publisher includes several fonts that output barcodes.

Font files included with Publisher:

  • LibreBarcode128-Regular.TTF - Supports code128a, code128b, and code128c algorithms. Also supports code128auto to automatically switch between the three code128 algorithms.
  • LibreBarcode39-Regular.TTF - Supports code39 and code39mod43 algorithms.
  • LibreBarcodeEAN13Text-Regular.TTF - Supports upca and upce algorithms.

When you use one of these prepackaged fonts, Publisher executes the preprocessing on the data prior to applying the barcode font to the data in the output document. For example, to calculate checksum values or start and end bits for the data before formatting them.

At design time, you don't need to apply the barcode font to the field in Microsoft Word. Instead, you can map the font that you apply to the field using Publisher's font mapping. At runtime, Publisher applies the barcode font to any field using the base font you specified in the font mapping. Be sure to choose a font that isn't used elsewhere in the template.

If you want to use the font directly in Microsoft Word, then add the appropriate .TTF file to the C:\WINDOWS\Fonts directory. To use the Template Builder Preview function, map the font in the Template Builder configuration file.

To use the barcode fonts in the report output:

  1. Insert a field in the template where the barcode is to display in the report output.
  2. In the form field, enter the following command:
    <?format-barcode:data;'barcode_type'?>
    

    where

    data is the element from the XML data source to be encoded. For example: INVOICE_NO

    barcode_type is one of the supported algorithms listed above.

    Examples:

    <?format-barcode:INVOICE_NO;'code128a'?>
    
    <?format-barcode:INVOICE_NO;'code39mod43'?>
    
    <?format-barcode:INVOICE_NO;'upca'?> 
    
  3. In Microsoft Word, apply the font to the field. If you haven't installed the barcode fonts on your client machine, then select a font that isn't used elsewhere in the template, for example, Bookman.
  4. Configure the font in the Font Mapping page. For more information about the Font Mapping page.

Note the following:

  • Microsoft Word may not render the barcode fonts properly even when they're installed on your client. To work around this issue, apply a different font to the field and map the font as described above.

  • The upca algorithm accepts only UPC-A message string and encodes into UPC-A barcode.

  • A string of 12 characters is treated as UPC-A message with a check digit, 11 is without a check digit.

  • The upce algorithm accepts only UPC-E message strings and encodes into UPC-E barcode.

  • A string of 8 characters is treated as a UPC-E message with both a front and end guard bar; a string of 6 characters is without guard bars.

Implement Custom Barcode Formats

If you choose to use a custom barcode instead, use this procedure to implement a custom barcode.

Publisher offers the ability to execute preprocessing on the data prior to applying a barcode font to the data in the output document. For example, you might need to calculate checksum values or start and end bits for the data before formatting them.

The solution requires that you register a barcode encoding class with Publisher that can then be instantiated at runtime to apply the formatting in the template.

To enable the formatting feature in the template, you must use two commands in the template. The first command registers the barcode encoding class with Publisher. This must be declared somewhere in the template prior to the encoding command. The second is the encoding command to identify the data to be formatted.

Encode the Data

Use this syntax in a form field in the template to format the data.

<?format-barcode:data;'barcode_type'?>

where

data is the element from the XML data source to be encoded. For example: LABEL_ID

barcode_type is the method in the encoding Java class used to format the data. For example: code128a.

For example:

<?format-barcode:LABEL_ID;'code128a'?>

At runtime, the barcode_type method is called to format the data value and the barcode font is then applied to the data in the final output.

2D Barcode Functions

You can use the QR code or PDF417 2D barcode type in RTF templates. When you create an RTF template, use the qrcode or pdf417 functions to specify the barcode type. These functions don't require external fonts.

qrcode Syntax

<?qrcode: <DATA>; <SIZE>[; <CHARSET>[; <ECLEVEL>[; <GS1FORMAT>[; <MASKPATTERN>[; <QRVERSION>]]]]]?>

where

  • DATA – Data to be encoded in the QR code format.
  • SIZE – QR code size dimension in points(pt).
  • CHARSET – (Optional) Character set for encoding the data. Default is UTF8.
  • ECLEVEL – (Optional) QR code error correction level. Default is "M".

    Valid values are:

    • "H" (~30% correction)
    • "Q" (~25% correction)
    • "M" (~15% correction)
    • "L" (~7% correction)
  • GS1FORMAT – (Optional) Whether to encode data in GS1 format. Enter "true" to encode data using the GS1 standard.
  • MASKPATTERN – (Optional) QR code mask pattern to be used. Default is optimal mask pattern. Valid values are integers (or string representation of integers) from 1 to 7.
  • QRVERSION – (Optional) Exact version of the QR code to be encoded. Default is the version determined by the size of data to be encoded. Valid values are integers (or string representations of integers) from 1 to 40.
For example, the qrcode syntax to generate QR code with data of size 200pixel, high error correction level, GS1 format encoding, QR code version 4, and to use the default values of character set and mask patterns:
<?qrcode: ‘01049123451234591597033130128’; ‘200’;’’ ; ‘H’; ‘true’; ‘’; 4?>

Note the character set and mask patterns are left blank to use the default values.

pdf417 Syntax

<?pdf417: <DATA>[; <XSCALE>[; <COLUMNS>[; <ROWS>[; <CHARSET>]]]]?>

where

  • DATA – Data to be encoded in the PDF417 format.
  • XSCALE – Point(pt) per PDF417 module width. Default is 1 (1pt per module).
  • COLUMNS – The number of columns to be used in the generated PDF417 symbol. Default is -1.
  • ROWS – The number of rows to be used in the generated PDF417 symbol. Default is -1.
  • CHARSET – (Optional) Character set to be used to encode data with the Byte compaction mode. Specify CHARSET only if the data contains non-Latin-1(ISO-8859-1) characters.