Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Global property settings
    • idcards.generateMin
      • The lower bound number used when "Printing Empty Id Cards"
    • idcards.generateMax
      • The upper bound number used when "Printing Empty Id Cards"
    • idcards.enableIdentifierGeneration
      • Hides / displays all UI elements which do identifier generation in the idcards module
    • idcards.enablePrintingUploadedIdentifiers
      • Hides / displays a new form for printing identifiers that are uploaded from a file
    • idcards.fopConfigFilePath ( as of 1.3.2)
      • The absolute file path for the Apache FOP configuration file. 

Examples

An AMPATH generated card:

...

A archive:python script for generating large sql insert files for the idcards_generated_identifier table.

Printing with Custom Fonts

ID Cards uses the Apache FOP library version 1.0 to create the PDF.  PDF tools have a few fonts available by default.  These aren't sufficient to print all languages.

To make additional fonts available, you must do the following:

1)  Install the font on the OpenMRS server, in whatever way necessary for your operating system.  (This is not part of OpenMRS.)

Example: I want to print Cambodian characters. I've found the Kh Battambang font. I follow the instructions to download and install it on my Mac, which is where I run OpenMRS. The fonts are installed to /Library/Fonts/Kh-Battambang.ttf  and /Library/Fonts/Kh-Battambangb.ttf on my Mac.

2) Create an Apache FOP configuration file.  Add the new fonts to the renderer section for pdfs. (This is not part of OpenMRS.)

The fastest method is to use the example config file included in  Apache FOP 1.0, which may be downloaded here.  The example config file is located in conf/fop.xconf . Copy it to conf/openmrs_fop.conf , or whatever filename you prefer.

Find the <fonts> section inside  <renderer mime="application/pdf"> .    Add your custom fonts, following the directions at http://xmlgraphics.apache.org/fop/1.0/fonts.html .

Note that there were major differences between Apache FOP versions 0.9x and 1.0 . Be sure to follow the 1.0 style of configuration.

Example:  I create font metrics files following the Apache FOP documentation.  In my fop config file, I add entries for normal and bold Kh Battambang fonts. The font might not be installed on the desktop machine at the registration desk, so I include the embed-url, so the font information is included in the PDF file.

No Format

        <font metrics-file="file:///Library/Fonts/Kh-Battambang-metrics.xml" embed-url="file:///Library/Fonts/Kh-Battambang.ttf" kerning="no" encoding-mode>
           <font-triplet name="Kh Battambang" style="normal" weight="normal"/>
         </font>
         <font metrics-file="file:///Library/Fonts/Kh-Battambangb-metrics.xml" embed-url="file:///Library/Fonts/Kh-Battambangb.ttf" kerning="no">
           <font-triplet name="Kh Battambangb" style="normal" weight="bold"/>
         </font>

3) Set the OpenMRS global property idcards.fopConfigFilePath  with the absolute filepath to your new FOP config file.

Example:  I saved my config file at /usr/local/apache-fop/conf/openmrs_fop.conf .

4)  In your XSLT,  mark the fields containing the custom characters with the font-family attribute.

Example:  I want the patient's name to be printed in Cambodian characters.  In Admin > Id Cards > Manage Templates, the xslt says

No Format

<fo:block font-family="Kh Battambang" font-weight="normal">
<xsl:value-of select="name"/>
 </fo:block>

Troubleshooting

If the PDF doesn't render correctly, check the following:

  • If it doesn't render at all, is the XSLT correct?  Make a very simple test xslt with Western characters. If that renders correctly, add in your custom characters.
  • Check the logs.  There will be an error message if the config file couldn't be found (wrong location or no read permissions), or if the config file couldn't be parsed. If it couldn't be parsed, you can work directly with Apache FOP and the example files it came with, directing it to use your config file.  This removes OpenMRS from the equation and gives you better feedback about what's wrong with the config file. If it doesn't work from the command line, it won't work for Id Cards.
  • There are no errors in the log, but the PDF shows ####  where the custom characters should be.  This means FOP wasn't able to find that character in the font family it was using.  Did you specify the font-family attribute, exactly as it appears in your config file?   Has this custom font ever worked on this machine?  Confirm that the font is correctly installed by adding a few custom characters to a FOP example file and run FOP from the command line. 

Release Notes

  • 1.3.2 (pending)
    The PDF generator (Apache FOP) will read the config file specified in global property idcards.fopConfigFilePath . PDFs can include non-default fonts.
  • 1.3.1
    Added ability to integrate with an external identifier generation facility. This adds two new global properties
    • idcards.enableIdentifierGeneration:  Hides / displays all UI elements which do identifier generation in the idcards module
    • idcards.enablePrintingUploadedIdentifiers: Hides / displays a new form for printing identifiers that are uploaded from a file
  • 1.3
  • Added checkdigit generation back into Print New Id Cards process
  • 1.2.2
  • Added ability to generate random identifiers on the fly instead of having to pregenerate the entire spectrum of identifiers
  • 1.2.1
  • Made log of printed identifiers an optional step to speed up page load
  • 1.2
  • Initial release

...