You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by al...@alice.it on 2009/08/26 18:02:09 UTC

Register font to generate PDF/A-1b file

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/fop-users@xmlgraphics.apache.org/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

R: R: Register font to generate PDF/A-1b file

Posted by al...@alice.it.
It turns out that there were a few lines in my class that are the cause of the problem. After removing them I'm able to generate the pdf file.
The following is the output of a diff between the working class and the class that throws the exception reported before:

~/fop$ diff ExampleXML2PDF.java ExampleXML2PDF.java.not_working
59c59,62
<
---
>
>                       PDFRenderer pdfrenderer = new PDFRenderer();
>                       pdfrenderer.setUserAgent(foUserAgent);
>                       foUserAgent.setRendererOverride(pdfrenderer);

Thanks a lot Jeremias for your support!

Regards,
Alessandro


-----Messaggio originale-----
Da: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
Inviato: ven 28/08/2009 9.25
A: fop-users@xmlgraphics.apache.org
Oggetto: Re: R: Register font to generate PDF/A-1b file
 
Hmm, I don't see any triplets for "Times New Roman" being registered.
Are you sure you're loading the right configuration file? Or maybe the
layout of your configuration file is wrong and it doesn't find any font
registrations. Can you show your complete config file?

On 27.08.2009 18:06:05 ale.marino78 wrote:
> Thanks a lot for your help Jeremias!
> 
> I'll post the xml and xsl files that I use:
>  - XSL -
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
>   <xsl:template match="/">
> 
> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Times New Roman">
> 
>   <fo:layout-master-set>
>     <fo:simple-page-master master-name="simple" page-height="29.7cm" page-width="21cm" margin-top="1cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
>       <fo:region-body margin-top="3cm"/>
>       <fo:region-before extent="3cm"/>
>       <fo:region-after extent="1.5cm"/>
>     </fo:simple-page-master>
>   </fo:layout-master-set>
>   <fo:page-sequence master-reference="simple">
>     <fo:flow flow-name="xsl-region-body">
> 
>       <fo:block font-size="12pt" font-family="Times New Roman" font-weight="normal" font-style="normal">
>         The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document.
>       </fo:block>
>     </fo:flow> <!-- closes the flow element-->
>   </fo:page-sequence> <!-- closes the page-sequence -->
> </fo:root>
>   </xsl:template>
> </xsl:stylesheet>
> 
>  - XML -
> <root />
> 
> Then with the command:
> ~/bin/fop-0.95/fop -c fop.xconf -xml fop.xml -xsl fop.xsl -pdfa1b fop.pdf
> 
> the pdf file is generated correctly (after removing the tag "filterList" in the config file) !! Watching the properties file from Acrobat I'm also able to see the embedded font as "TimesNewRomanPSMT".
> 
> Running the command-line tool with the switch "-at" generates an xml file which containt some "text" element with these attributes:
> 
> 	font-name="any" font-style="normal" font-weight="400" font-size="12000"
> 
> I get the following lines grepping the output of fop.sh:
> 
> $ ~/bin/fop-0.95/fop -c fop.xconf -xml fop.xml -xsl fop.xsl -at fop.out.xml | grep Time
> 2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,normal,400 under F5
> 2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,oblique,400 under F6
> 2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,italic,400 under F6
> 2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,normal,700 under F7
> 2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,oblique,700 under F8
> 2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,italic,700 under F8
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,normal,400 under F5
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,oblique,400 under F6
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,italic,400 under F6
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,normal,700 under F7
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,oblique,700 under F8
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,italic,700 under F8
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,normal,400 under F5
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,oblique,400 under F6
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,italic,400 under F6
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,normal,700 under F7
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,oblique,700 under F8
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,italic,700 under F8
> 2009-08-27 15:16:34,931 [main] DEBUG org.apache.fop.fonts.FontInfo - Font lookup: Times New Roman normal 400
> 2009-08-27 15:16:34,931 [main] WARN  org.apache.fop.fonts.FontInfo - Font 'Times New Roman,normal,400' not found. Substituting with 'any,normal,400'.
> 2009-08-27 15:16:34,948 [main] DEBUG org.apache.fop.fonts.FontInfo - Font lookup: Times New Roman normal 400
> 2009-08-27 15:16:34,951 [main] DEBUG org.apache.fop.fonts.FontInfo - Font lookup: Times New Roman normal 400
> 
> Anyway running the Java class produces the same exception reported yesterday (I also added more triplets in the config file as you've suggested):
> 
> 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)
> 
> Do you have any idea about this issue ?
> 
> Thanks and regards,
> Alessandro
> 
> 
> -----Messaggio originale-----
> Da: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
> Inviato: gio 27/08/2009 8.16
> A: fop-users@xmlgraphics.apache.org
> Oggetto: Re: Register font to generate PDF/A-1b file
>  
> "Times-Roman" is clearly the base 14 font which seems to be triggered
> somewhere for some reason. On first sight (and with the information
> available) I'd say you did everything right. Have you tried to do the
> same on the command-line just for comparison? On the command-line you
> can also run the "-at out.at.xml" option (instead of "-pdf out.pdf") to
> generate the area tree XML file which could give you some indication
> where FOP doesn't use the TrueType font. Using SVG files inside the FO
> document could also be a source of the problem.
> 
> Another possibility is to add additional font-triplet elements to the
> font configuration to override the defaults:
> 
> <font metrics-url="tnr.xml" kerning="yes" embed-url="Times_New_Roman.ttf">
>   <font-triplet name="Times New Roman" style="normal" weight="normal"/>
>   <font-triplet name="Times" style="normal" weight="normal"/>
>   <font-triplet name="serif" style="normal" weight="normal"/>
>   <font-triplet name="any" style="normal" weight="normal"/>
> </font>
> 
> BTW, if you use FOP 0.95 you don't need to do the TTFReader step and can
> skip the metrics-url attribute in the configuration.
> 
> HTH
> 
> On 26.08.2009 18:02:09 ale.marino78 wrote:
> > 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/fop-users@xmlgraphics.apache.org/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
> 




Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org




Re: R: Register font to generate PDF/A-1b file

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Hmm, I don't see any triplets for "Times New Roman" being registered.
Are you sure you're loading the right configuration file? Or maybe the
layout of your configuration file is wrong and it doesn't find any font
registrations. Can you show your complete config file?

On 27.08.2009 18:06:05 ale.marino78 wrote:
> Thanks a lot for your help Jeremias!
> 
> I'll post the xml and xsl files that I use:
>  - XSL -
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
>   <xsl:template match="/">
> 
> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Times New Roman">
> 
>   <fo:layout-master-set>
>     <fo:simple-page-master master-name="simple" page-height="29.7cm" page-width="21cm" margin-top="1cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
>       <fo:region-body margin-top="3cm"/>
>       <fo:region-before extent="3cm"/>
>       <fo:region-after extent="1.5cm"/>
>     </fo:simple-page-master>
>   </fo:layout-master-set>
>   <fo:page-sequence master-reference="simple">
>     <fo:flow flow-name="xsl-region-body">
> 
>       <fo:block font-size="12pt" font-family="Times New Roman" font-weight="normal" font-style="normal">
>         The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document.
>       </fo:block>
>     </fo:flow> <!-- closes the flow element-->
>   </fo:page-sequence> <!-- closes the page-sequence -->
> </fo:root>
>   </xsl:template>
> </xsl:stylesheet>
> 
>  - XML -
> <root />
> 
> Then with the command:
> ~/bin/fop-0.95/fop -c fop.xconf -xml fop.xml -xsl fop.xsl -pdfa1b fop.pdf
> 
> the pdf file is generated correctly (after removing the tag "filterList" in the config file) !! Watching the properties file from Acrobat I'm also able to see the embedded font as "TimesNewRomanPSMT".
> 
> Running the command-line tool with the switch "-at" generates an xml file which containt some "text" element with these attributes:
> 
> 	font-name="any" font-style="normal" font-weight="400" font-size="12000"
> 
> I get the following lines grepping the output of fop.sh:
> 
> $ ~/bin/fop-0.95/fop -c fop.xconf -xml fop.xml -xsl fop.xsl -at fop.out.xml | grep Time
> 2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,normal,400 under F5
> 2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,oblique,400 under F6
> 2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,italic,400 under F6
> 2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,normal,700 under F7
> 2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,oblique,700 under F8
> 2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,italic,700 under F8
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,normal,400 under F5
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,oblique,400 under F6
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,italic,400 under F6
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,normal,700 under F7
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,oblique,700 under F8
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,italic,700 under F8
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,normal,400 under F5
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,oblique,400 under F6
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,italic,400 under F6
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,normal,700 under F7
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,oblique,700 under F8
> 2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,italic,700 under F8
> 2009-08-27 15:16:34,931 [main] DEBUG org.apache.fop.fonts.FontInfo - Font lookup: Times New Roman normal 400
> 2009-08-27 15:16:34,931 [main] WARN  org.apache.fop.fonts.FontInfo - Font 'Times New Roman,normal,400' not found. Substituting with 'any,normal,400'.
> 2009-08-27 15:16:34,948 [main] DEBUG org.apache.fop.fonts.FontInfo - Font lookup: Times New Roman normal 400
> 2009-08-27 15:16:34,951 [main] DEBUG org.apache.fop.fonts.FontInfo - Font lookup: Times New Roman normal 400
> 
> Anyway running the Java class produces the same exception reported yesterday (I also added more triplets in the config file as you've suggested):
> 
> 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)
> 
> Do you have any idea about this issue ?
> 
> Thanks and regards,
> Alessandro
> 
> 
> -----Messaggio originale-----
> Da: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
> Inviato: gio 27/08/2009 8.16
> A: fop-users@xmlgraphics.apache.org
> Oggetto: Re: Register font to generate PDF/A-1b file
>  
> "Times-Roman" is clearly the base 14 font which seems to be triggered
> somewhere for some reason. On first sight (and with the information
> available) I'd say you did everything right. Have you tried to do the
> same on the command-line just for comparison? On the command-line you
> can also run the "-at out.at.xml" option (instead of "-pdf out.pdf") to
> generate the area tree XML file which could give you some indication
> where FOP doesn't use the TrueType font. Using SVG files inside the FO
> document could also be a source of the problem.
> 
> Another possibility is to add additional font-triplet elements to the
> font configuration to override the defaults:
> 
> <font metrics-url="tnr.xml" kerning="yes" embed-url="Times_New_Roman.ttf">
>   <font-triplet name="Times New Roman" style="normal" weight="normal"/>
>   <font-triplet name="Times" style="normal" weight="normal"/>
>   <font-triplet name="serif" style="normal" weight="normal"/>
>   <font-triplet name="any" style="normal" weight="normal"/>
> </font>
> 
> BTW, if you use FOP 0.95 you don't need to do the TTFReader step and can
> skip the metrics-url attribute in the configuration.
> 
> HTH
> 
> On 26.08.2009 18:02:09 ale.marino78 wrote:
> > 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/fop-users@xmlgraphics.apache.org/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
> 




Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


R: Register font to generate PDF/A-1b file

Posted by al...@alice.it.
Thanks a lot for your help Jeremias!

I'll post the xml and xsl files that I use:
 - XSL -
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
  <xsl:template match="/">

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Times New Roman">

  <fo:layout-master-set>
    <fo:simple-page-master master-name="simple" page-height="29.7cm" page-width="21cm" margin-top="1cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
      <fo:region-body margin-top="3cm"/>
      <fo:region-before extent="3cm"/>
      <fo:region-after extent="1.5cm"/>
    </fo:simple-page-master>
  </fo:layout-master-set>
  <fo:page-sequence master-reference="simple">
    <fo:flow flow-name="xsl-region-body">

      <fo:block font-size="12pt" font-family="Times New Roman" font-weight="normal" font-style="normal">
        The Extensible Markup Language (XML) is a subset of SGML that is completely described in this document.
      </fo:block>
    </fo:flow> <!-- closes the flow element-->
  </fo:page-sequence> <!-- closes the page-sequence -->
</fo:root>
  </xsl:template>
</xsl:stylesheet>

 - XML -
<root />

Then with the command:
~/bin/fop-0.95/fop -c fop.xconf -xml fop.xml -xsl fop.xsl -pdfa1b fop.pdf

the pdf file is generated correctly (after removing the tag "filterList" in the config file) !! Watching the properties file from Acrobat I'm also able to see the embedded font as "TimesNewRomanPSMT".

Running the command-line tool with the switch "-at" generates an xml file which containt some "text" element with these attributes:

	font-name="any" font-style="normal" font-weight="400" font-size="12000"

I get the following lines grepping the output of fop.sh:

$ ~/bin/fop-0.95/fop -c fop.xconf -xml fop.xml -xsl fop.xsl -at fop.out.xml | grep Time
2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,normal,400 under F5
2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,oblique,400 under F6
2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,italic,400 under F6
2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,normal,700 under F7
2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,oblique,700 under F8
2009-08-27 15:16:34,399 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times,italic,700 under F8
2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,normal,400 under F5
2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,oblique,400 under F6
2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,italic,400 under F6
2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,normal,700 under F7
2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,oblique,700 under F8
2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times-Roman,italic,700 under F8
2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,normal,400 under F5
2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,oblique,400 under F6
2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,italic,400 under F6
2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,normal,700 under F7
2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,oblique,700 under F8
2009-08-27 15:16:34,400 [main] DEBUG org.apache.fop.fonts.FontInfo - Registering: Times Roman,italic,700 under F8
2009-08-27 15:16:34,931 [main] DEBUG org.apache.fop.fonts.FontInfo - Font lookup: Times New Roman normal 400
2009-08-27 15:16:34,931 [main] WARN  org.apache.fop.fonts.FontInfo - Font 'Times New Roman,normal,400' not found. Substituting with 'any,normal,400'.
2009-08-27 15:16:34,948 [main] DEBUG org.apache.fop.fonts.FontInfo - Font lookup: Times New Roman normal 400
2009-08-27 15:16:34,951 [main] DEBUG org.apache.fop.fonts.FontInfo - Font lookup: Times New Roman normal 400

Anyway running the Java class produces the same exception reported yesterday (I also added more triplets in the config file as you've suggested):

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)

Do you have any idea about this issue ?

Thanks and regards,
Alessandro


-----Messaggio originale-----
Da: Jeremias Maerki [mailto:dev@jeremias-maerki.ch]
Inviato: gio 27/08/2009 8.16
A: fop-users@xmlgraphics.apache.org
Oggetto: Re: Register font to generate PDF/A-1b file
 
"Times-Roman" is clearly the base 14 font which seems to be triggered
somewhere for some reason. On first sight (and with the information
available) I'd say you did everything right. Have you tried to do the
same on the command-line just for comparison? On the command-line you
can also run the "-at out.at.xml" option (instead of "-pdf out.pdf") to
generate the area tree XML file which could give you some indication
where FOP doesn't use the TrueType font. Using SVG files inside the FO
document could also be a source of the problem.

Another possibility is to add additional font-triplet elements to the
font configuration to override the defaults:

<font metrics-url="tnr.xml" kerning="yes" embed-url="Times_New_Roman.ttf">
  <font-triplet name="Times New Roman" style="normal" weight="normal"/>
  <font-triplet name="Times" style="normal" weight="normal"/>
  <font-triplet name="serif" style="normal" weight="normal"/>
  <font-triplet name="any" style="normal" weight="normal"/>
</font>

BTW, if you use FOP 0.95 you don't need to do the TTFReader step and can
skip the metrics-url attribute in the configuration.

HTH

On 26.08.2009 18:02:09 ale.marino78 wrote:
> 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/fop-users@xmlgraphics.apache.org/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




Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org



Re: Register font to generate PDF/A-1b file

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
"Times-Roman" is clearly the base 14 font which seems to be triggered
somewhere for some reason. On first sight (and with the information
available) I'd say you did everything right. Have you tried to do the
same on the command-line just for comparison? On the command-line you
can also run the "-at out.at.xml" option (instead of "-pdf out.pdf") to
generate the area tree XML file which could give you some indication
where FOP doesn't use the TrueType font. Using SVG files inside the FO
document could also be a source of the problem.

Another possibility is to add additional font-triplet elements to the
font configuration to override the defaults:

<font metrics-url="tnr.xml" kerning="yes" embed-url="Times_New_Roman.ttf">
  <font-triplet name="Times New Roman" style="normal" weight="normal"/>
  <font-triplet name="Times" style="normal" weight="normal"/>
  <font-triplet name="serif" style="normal" weight="normal"/>
  <font-triplet name="any" style="normal" weight="normal"/>
</font>

BTW, if you use FOP 0.95 you don't need to do the TTFReader step and can
skip the metrics-url attribute in the configuration.

HTH

On 26.08.2009 18:02:09 ale.marino78 wrote:
> 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/fop-users@xmlgraphics.apache.org/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




Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org