[xwiki-users] PDF with UTF characters
I'm investigating issue http://jira.xwiki.org/jira/browse/XWIKI-4724 Now I can generate right PDF using separate FOP with additional configuration files and invocation parameters. Though I don't know, how to invoke it in such way from Xwiki. Do you have any suggestions/ideas? Valdis
On 02/01/2010 09:47 PM, Valdis Vītoliņš wrote:
I'm investigating issue http://jira.xwiki.org/jira/browse/XWIKI-4724 Now I can generate right PDF using separate FOP with additional configuration files and invocation parameters. Though I don't know, how to invoke it in such way from Xwiki.
Do you have any suggestions/ideas?
I gave a workaround in a comment on that issue, in case somebody else is interested in this problem and wants an answer. -- Sergiu Dumitriu http://purl.org/net/sergiu/
I learned how to add custom TTF font and metrics for FOP. Test project can be downloaded from http://odo.lv/ftp/temp/FOP.zip There are FOP jars and "Lucida Sans Unicode" TTF font with generated metrics file. Metrics can be created using generate_font_metrics.bat script. Test PDF can be generated with test1.bat script. Now questions are: How can I invoke customized FOP with additional parameter for my config file from Xwiki? Or how can I change default font From "Times-Roman" to "Lucida Sans Unicode"? Valdis
On 02/01/2010 09:47 PM, Valdis Vītoliņš wrote:
I'm investigating issue http://jira.xwiki.org/jira/browse/XWIKI-4724 Now I can generate right PDF using separate FOP with additional configuration files and invocation parameters. Though I don't know, how to invoke it in such way from Xwiki.
Do you have any suggestions/ideas?
I gave a workaround in a comment on that issue, in case somebody else is interested in this problem and wants an answer.
On 02/04/2010 01:32 PM, Valdis Vītoliņš wrote:
I learned how to add custom TTF font and metrics for FOP. Test project can be downloaded from http://odo.lv/ftp/temp/FOP.zip There are FOP jars and "Lucida Sans Unicode" TTF font with generated metrics file. Metrics can be created using generate_font_metrics.bat script. Test PDF can be generated with test1.bat script.
Even the FOP developers say that generating font metrics is not needed, and deprecated. FOP should correctly find and use system fonts, and should correctly work with TTF fonts. The problem is that FOP doesn't find the fonts provided by XWiki because Tomcat doesn't use an URI scheme that FOP understands. You can extract WEB-INF/lib/xwiki-core-XYZ.java#fop-config.xml into WEB-INF/classes and adjust the <fonts> settings so that you manually specify the path to the right font files. The syntax for the config xml should be on the FOP site.
Now questions are: How can I invoke customized FOP with additional parameter for my config file from Xwiki? Or how can I change default font From "Times-Roman" to "Lucida Sans Unicode"?
Extract xhtml2fo.xsl from WEB-INF/lib/xwiki-core-XYZ.jar into WEB-INF/classes and search for the line: <xsl:attribute name="font-family">FreeSerif,serif</xsl:attribute> Replace FreeSerif with what you want.
Valdis
On 02/01/2010 09:47 PM, Valdis Vītoliņš wrote:
I'm investigating issue http://jira.xwiki.org/jira/browse/XWIKI-4724 Now I can generate right PDF using separate FOP with additional configuration files and invocation parameters. Though I don't know, how to invoke it in such way from Xwiki.
Do you have any suggestions/ideas?
I gave a workaround in a comment on that issue, in case somebody else is interested in this problem and wants an answer.
-- Sergiu Dumitriu http://purl.org/net/sergiu/
Many thanks Sergiu! I solved this. My comments are inline.
Even the FOP developers say that generating font metrics is not needed, and deprecated. FOP should correctly find and use system fonts, and should correctly work with TTF fonts.
I checked this and that's correct.
The problem is that FOP doesn't find the fonts provided by XWiki because Tomcat doesn't use an URI scheme that FOP understands. You can extract WEB-INF/lib/xwiki-core-XYZ.java#fop-config.xml into WEB-INF/classes and adjust the <fonts> settings so that you manually specify the path to the right font files. The syntax for the config xml should be on the FOP site.
Copied Courier_New.ttf and Times_New_Roman.ttf into ../webapps/xwiki/WEB-INF/fonts Added following lines to the ../webapps/xwiki/WEB-INF/classes/fop-config.xml <fonts> ... <!-- /webapps is symlink to /var/lib/tomcat5.5/webapps/ --> <font kerning="yes" embed-url="/webapps/xwiki/WEB-INF/fonts/Courier_New.ttf"> <font-triplet name="Courier New" style="normal" weight="normal"/> </font> <font kerning="yes" embed-url="/webapps/xwiki/WEB-INF/fonts/Times_New_Roman.ttf"> <font-triplet name="Times New Roman" style="normal" weight="normal"/> </font> ... </fonts>
Extract xhtml2fo.xsl from WEB-INF/lib/xwiki-core-XYZ.jar into WEB-INF/classes and search for the line:
<xsl:attribute name="font-family">FreeSerif,serif</xsl:attribute>
Changed FreeSerif,serif to Times New Roman and FreeMono,monospace to Courier New Ran PDF export, got exception ... /usr/share/tomcat5.5/.fop/fop-fonts.cache (No such file or directory)... mkdir /usr/share/tomcat5.5/.fop/ chown tomcat5:root /usr/share/tomcat5.5/.fop/ chmod 775 /usr/share/tomcat5.5/.fop/ restarted tomcat and viola! It is working now! Valdis
participants (2)
-
Sergiu Dumitriu -
Valdis Vītoliņš