I'm trying to do generate a PDF/A-1b from xml and xsl.
To do that first I creted a font metrics file with
org.apache.fop.fonts.apps.TTFReader as described in
http://xmlgraphics.apache.org/fop/0.94/fonts.html#register.
Then I copied both the font file and the metrics file in the directory from
which I'm running the program. I'm using the font
/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf provided by the
Ubuntu package msttcorefonts.
In the config file there are the following entries:
...
<base>/home/alexyz/workspace</base>
...
<font metrics-url="tnr.xml" kerning="yes" embed-url="Times_New_Roman.ttf">
<font-triplet name="Times New Roman" style="normal" weight="normal"/>
</font>
I put the attribute font-family="Times New Roman" in the tag fo:root to be sure
to set Times New Roman as default font, then in the xsl there's always the
triplet:
font-family="Times New Roman" font-weight="normal" font-style="normal"
I took the Java code from
http://www.mail-archive.com/[email protected]/msg08341.html for
the program that generates the pdf file. Unfortunately I get the exception:
WARNING: Font 'Times New Roman,normal,400' not found. Substituting with
'any,normal,400'.
ERROR: 'For PDF/A-1b, all fonts, even the base 14 fonts, have to be embedded!
Offending font: /Times-Roman'
javax.xml.transform.TransformerException:
org.apache.fop.pdf.PDFConformanceException: For PDF/A-1b, all fonts, even the
base 14 fonts, have to be embedded! Offending font: /Times-Roman
at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:718)
at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)
at it.alessandro.pdf.ExampleXML2PDF.main(ExampleXML2PDF.java:89)
Caused by: org.apache.fop.pdf.PDFConformanceException: For PDF/A-1b, all fonts,
even the base 14 fonts, have to be embedded! Offending font: /Times-Roman
at org.apache.fop.pdf.PDFFont.validate(PDFFont.java:161)
at org.apache.fop.pdf.PDFFont.output(PDFFont.java:170)
at org.apache.fop.pdf.PDFDocument.output(PDFDocument.java:937)
at org.apache.fop.pdf.PDFDocument.outputTrailer(PDFDocument.java:1010)
at
org.apache.fop.render.pdf.PDFRenderer.stopRenderer(PDFRenderer.java:516)
at
org.apache.fop.area.RenderPagesModel.endDocument(RenderPagesModel.java:240)
at
org.apache.fop.area.AreaTreeHandler.endDocument(AreaTreeHandler.java:305)
at org.apache.fop.fo.FOTreeBuilder.endDocument(FOTreeBuilder.java:156)
at
com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.endDocument(ToXMLSAXHandler.java:181)
It seems that the font is correctly registered. Am I doing something wrong ?
Why is there "/Times-Roman" instead of "/Times New Roman" ?
The file tnr.xml contains:
<font-name>TimesNewRomanPSMT</font-name>
<full-name>Times New Roman</full-name>
<family-name>Times New Roman</family-name>
Thanks and regards,
Alessandro