XSF-FO intellisense and national languages with Apache FOP
Posted
by Lukasz Kurylo
on Geeks with Blogs
See other posts from Geeks with Blogs
or by Lukasz Kurylo
Published on Mon, 15 Oct 2012 19:23:05 GMT
Indexed on
2012/10/15
21:38 UTC
Read the original article
Hit count: 309
Some time ago I showed how to get an intellisense and how to configure the FO.NET to acquire national characters inside the generated pdf files.
Due to the limitations that I mensioned in my previous post, I started playing with the Apache FOP. In this post I want to show, how to acquire the same result as I showed in the two posts related to FO.NET.
Intellisense
To get the intellisense from the XSL-FO templates set the xsi:schemaLocation the same way I showed it in this post.
The only diffrence to FO.NET is that, during generating the document by the code I showed last time we will get an exception:
org.apache.fop.fo.ValidationException: Invalid property encountered on "fo:root": xsi:schemaLocation (See position 6:11)
Fortunatelly there is a very easy way to resolve this without removing the entire attribute along with the intellisense.
Add to the FopFactory the ignoreNamespace by:
FopFactory fopFactory = FopFactory.newInstance();
fopFactory.ignoreNamespace(http://www.w3.org/2001/XMLSchema-instance);
Notice that, the url specified in this method this is a namespace for the xmlns:xsi namespace, not xsi.schemaLocation.
Fonts / national characters
This point is a little dfferent to acquire, but not more complicated that it was with FO.NET.
To set the fonts in Apache FOP 1.0, we need a configuration file. A sample one can be get from the directory where we unpacked the fop binaries, from conf subdirectory. There is a file called fop.xconf. We must copy this file to our solution.
In the simplest way, in the <fonts> tag we can add <auto-detect/>. Thanks to this, FOP will index all fonts available on the installed operating system. There probably should be no problem, if we have a http handler or a WCF Service on the server that serves the generated pdf documents. In this situation we can use all available fonts on this server.
To use this config file, we must set a path to it:
FopFactory fopFactory = FopFactory.newInstance();
fopFactory.setUserConfig(new File("fop.xconf"));
© Geeks with Blogs or respective owner