strife's devLog

Tag: XML

javaDynamic variables FOP / XSLT – font changing problem (switching font languages)

I’ve been working on the PDFs once again and I’ve spotted that I have a problem with changing languages depending on the variables. In other words if somebody speaks Asian languages font should be different than Arial.ttf which is as defualt.

To solve this problem we need to change our XML file which is used for populating all fields in the PDF to add to them another option indicates language parameter. Below you’ll find my quick solution for this problem. I assume that you’ve already configurated your envirovement and FOP / PDF thing.

In Java, first I’m getting XML and parse it putting the value indicates language in the XML. Something like this

In my XML file the first node within the root is tag.

So I’m dynamically changing language node to the language parameter and in XSL file I am just choosing in using the structure that I’ve written above. And that’s all.