checkboxes of XSL-FO to PDF checkboxes in XSL-FO insert is easily possible Unicode. However, they are in the generation of PDF not automatically correct. The following XSL-FO provides for example the following PDF file:
\u0026lt;? Xml version = "1.0" encoding = "UTF-8"?>
\u0026lt;for: root xmlns: for = "http:// www.w3.org/1999/XSL/Format>
<fo:layout-master-set>
<fo:simple-page-master master-name="A4" page-width="210mm" page-height="297mm">
<fo:region-body region-name="region-body" margin="2cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<fo:flow flow-name="region-body">
<fo:block>
<fo:block>Boxes from XSL-FO to PDF</fo:block>
\u0026lt;fo:block> & # x2610; Box \u0026lt;/ for: block>
\u0026lt;fo:block> & # x2611; box checked \u0026lt;/ for: block>
\u0026lt;for: block > & # x2612; x-marked box \u0026lt;/ for: block>
\u0026lt;/ for: block>
\u0026lt;/ for: flow>
\u0026lt;/ for: page-sequence>
\u0026lt;/ for : root>
The check boxes are missing PDF document. Why? The PDF generation will make use of the standard fonts that are in PDF format. However, no Unicode support you and, therefore, the checkboxes substitute them with # dar. One can imagine the embedded fonts in the properties of the PDF document on the Fonts tab to display. to show (in the Adobe Reader under File> Properties ...)
To Unicode characters in PDF, you must have a Unicode font that is embedded in the PDF. This raises two questions: first
Question: How do I write in XSL-FO that a Unicode font to use?
second Question: How do I tell these FOP Font embedding into PDF?
answer to question 1: would spontaneously fall back to first, perhaps to "Arial Unicode MS standard." This font is available on many Windows operating systems because it comes with Microsoft Office. Then would the XSL-FO code look like to set this font:
\u0026lt;fo:block>
\u0026lt;fo:block> Boxes from XSL-FO to PDF \u0026lt;/ for: block>
\u0026lt;for: block font-family = "ArialUnicodeMS" > & # x2610; Box \u0026lt;/ for: block>
\u0026lt;for: block font-family = "ArialUnicodeMS" > & # x2611; box checked \u0026lt;/ for: block>
\u0026lt;fo:block font-family="ArialUnicodeMS" > & # x2612; x-box marked \u0026lt; ; / for: block>
\u0026lt;/ for: block>
ArialUnicodeMS Then, when the font in the PDF file is embedded with (see answer to question 2 below), provides the result in this:
This looks just fine but: The check boxes are there and the font is embedded. That was no big surprise, right? The surprise But come now, for Arial Unicode MS is under license of Agfa Monotype Corporation. and may not be freely copied (see http://www.fonts.com/FontServices/LicensingOptions.htm). In the file properties of ARIALUNI.TTF can read this license condition also
My understanding of the license agreement, is that you can not embed Arial Unicode MS pass into PDF documents. In order to avoid any such license problem, you should therefore find a free alternative to Arial Unicode MS.
A good alternative is the project "Free UCS Outline Fonts" (see
http://savannah.gnu.org/projects/freefont ). Under the
GNU General Public License v3 are different fonts available. If one uses the font free mono it would look like in XSL-FO by:
\u0026lt;fo:block>
\u0026lt;fo:block> Boxes from XSL-FO to PDF \u0026lt;/ for: block>
\u0026lt;for: block font-family = "mono free" > & # x2610; Box \u0026lt;/ for: block>
\u0026lt;fo:block font-family="FreeMono" > & # x2611; box checked \u0026lt;/ for: block>
\u0026lt;fo:block font-family="FreeMono" > & # x2612; X-marked box \u0026lt;/ for: block>
\u0026lt;/ for: block>
Then, when the free mono-font in the PDF file is embedded, the result looks like this:
The check boxes are now displayed in the PDF file and the free font free mono is embedded, so there should be no licensing issues as in the Arial Unicode MS. (That being said, it's time for the answer to question 2)
answer to question 2: To change the font free mono (or other) embedded in the PDF, the following three steps are necessary.
- Step 1 - Create a font metrics file from the TrueType font file FreeMono.ttf
- Step 2 - Create a FOP configuration file that controls the embedding of the font
- Step 3 - Calling FOP using the produced
from the TrueType font file must FreeMono.ttf a font metrics file: Configuration file
step 1. The following call creates the file freemono.xml:
java-cp% CLASSPATH% org.apache.fop.fonts.apps.TTFReader FreeMono.ttf freemono.xml
Step 2: The Font Metrics file must be included in a FOP configuration. This is the following example assumes that below. \\ Lib the fop.jar, the following configuration file, the True Type Font Metrics File FreeMono.ttf and file are freemono.xml. Here is an example of the fop-config.xml file:
\u0026lt;xml version = "1.0"?>
\u0026lt;fop version="1.0">
\u0026lt;base>. / lib \u0026lt;/ base>
\u0026lt;source-resolution> 72 \u0026lt;/ source-resolution>
\u0026lt;target-resolution> 72 \u0026lt;/ target-resolution>
\u0026lt;default-page-settings height="297mm" width="210mm"/>
\u0026lt;renderers>
; \u0026lt;renderer mime="application/pdf">
\u0026lt;filterList>
; \u0026lt;value> flate \u0026lt;/ value>
\u0026lt;filter / list> ;!
\u0026lt;- Here Free Unicode fonts of the project Free UCS outline fonts are used ( see
http://savannah.gnu.org/projects/freefont). -->
<font metrics-url="fop-freemono.xml" kerning="yes" embed-url="FreeMono.ttf">
<font-triplet name="FreeMono" style="normal" weight="normal"/>
</font>
</fonts>
\u0026lt;/ Renderer>
\u0026lt;/ renderers>
\u0026lt;/ fop>
says now is also from where came the answer to Question 1 the name of the font-family. He is the property of the specified font-triplet.
Step 3: Using To the FOP configuration file, it must be specified when calling FOP as parameters: java-jar
\\ lib \\ fop.jar-c \\ lib \\ fop-config.. . xml input-with-boxes.fo-pdf output-with-boxes.pdf
further details in answer to question 2 may
http://xmlgraphics.apache.org/fop/0.94/fonts.html be found.