问题描述
我试图用说这样做,但它并没有改变任何东西。
请帮助我解决我的嵌入字体错误。主题。
$ b
:
这是整个错误信息:
FOP ExampleFO2PDF
准备...
输入:XSL-FO(.\xml\fo\helloworld.fo)
输出:PDF (.\\\\\\\\\\\\\')
转换...
août07,2017 11:26:49 AM org.apache.fop.events.LoggingEventListener processEvent
INFOS:渲染页面#1。
org.apache.fop.pdf.PDFConformanceException:对于PDF / A-1b,所有的字体,甚至是底部14种字体,必须嵌入!违规字体:/ Helvetica
at org.apache.fop.pdf.PDFFont.validate(PDFFont.java:170)
at org.apache.fop.pdf.PDFFont.output(PDFFont.java:179 )
at org.apache.fop.pdf.PDFDocument.outputIndirectObject(PDFDocument.java:1053)
at org.apache.fop.pdf.PDFDocument.streamIndirectObject(PDFDocument.java:1018)
在org.apache.fop.pdf.PDFDocument.output(PDFDocument.java:994)
at org.apache.fop.pdf.PDFDocument.outputTrailer(PDFDocument.java:1097)
at org。 apache.fop.render.pdf.PDFDocumentHandler.endDocument(PDFDocumentHandler.java:191)
at org.apache.fop.render.intermediate.util.IFDocumentHandlerProxy.endDocument(IFDocumentHandlerProxy.java:187)
at org.apache.fop.render.intermediate.IFRenderer.stopRenderer(IFRenderer.java:295)
at org.apache.fop.area.RenderPagesModel.endDocument(RenderPagesModel.java:265)
at org。 apache.fop.area.AreaTreeHandler.endDocument(AreaTreeHandler.java:342)
在org.apache.fop.fo.FOT reeBuilder.endDocument(FOTreeBuilder.java:170)
at org.apache.xalan.transformer.TransformerIdentityImpl.endDocument(TransformerIdentityImpl.java:963)
at org.apache.xerces.parsers.AbstractSAXParser.endDocument(未知来源)
在org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(未知来源)
在org.apache.xerces.impl.XMLEntityManager.endEntity(未知来源)
org。 apache.xerces.impl.XMLEntityScanner.load(未知源)
在org.apache.xerces.impl.XMLEntityScanner.skipSpaces(未知源)
在org.apache.xerces.impl.XMLDocumentScannerImpl $ TrailingMiscDispatcher。 (Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(未知来源)
at org.apache.xerces.parsers.XMLParser.parse(未知来源)
at org .apache.xerces.parsers.AbstractSAXParser.parse(未知源)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:485)
ConverterFO2PDFa.convertFO2PDF(ConverterFO2PDFa.java: 104)
ConverterFO2PDFa.main(ConverterFO2PDFa.java:154)
-
我可以使用相同的示例文件创建一个PDF / A输出>在输入FO文件中,我明确地在一个位置添加了
font-family =Helvetica
所有的文本
没有这个,即使FOP默认使用Helvetica时没有
font-family
是显然无法找到配置。 配置文件中的 -
Helvetica字体系列转换为现有字体,例如Arial
-
在 Java代码中,我配置了FOP来使用我的配置文件和用户代理来启用可访问性
$ $ p $ $ $ $ $ import org.apache.avalon.framework.configuration.Configuration;
导入org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
导入org.apache.fop.apps.FopFactoryBuilder;
...
DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
Configuration cfg = cfgBuilder.buildFromFile(new File(/ Users / lfurini / fop.xconf));
FopFactoryBuilder fopFactoryBuilder = new FopFactoryBuilder(new File(。)。toURI())。setConfiguration(cfg);
FopFactory fopFactory = fopFactoryBuilder.build();
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
//根据需要配置foUserAgent
foUserAgent.setAccessibility(true);
foUserAgent.getRendererOptions()。put(pdf-a-mode,PDF / A-1b);
...
< font kerning =yesembed-url =/ Library / Fonts / arial.ttf>
< font-triplet name =Helveticastyle =normalweight =normal/>
< / font>
I'm trying to convert .fo
files to PDF/a with Apache FOP 2.1
with the exemple code given in the documentation. I managed to convert the helloworld.fo
file into PDF but, when I tried to convert it into PDF/a file I get this error:
org.apache.fop.pdf.PDFConformanceException: For PDF/A-1a, all fonts, even the base 14 fonts, have to be embedded! Offending font: /Helvetica
That's why I tried to embedded fonts in the fop.xconf
file:
<fonts>
<font kerning="yes" embed-url="C:/Users/thinkpad/workspace/FopConverter/Fonts/arial.ttf" name="Arial">
<font-triplet name="Arial" style="normal" weight="700"/>
</font>
<font kerning="yes" embed-url="C:/Users/thinkpad/workspace/FopConverter/Fonts/arialbd.ttf" name="Arial Bold">
<font-triplet name="Arial" style="normal" weight="bold"/>
</font>
<font kerning="yes" embed-url="C:/Users/thinkpad/workspace/FopConverter/Fonts/ariali.ttf" name="Arial Italique">
<font-triplet name="Arial" style="italic" weight="700"/>
</font>
<font kerning="yes" embed-url="C:/Users/thinkpad/workspace/FopConverter/Fonts/arialbi.ttf" name="Helvetica Bold Italique">
<font-triplet name="Arial" style="italic" weight="bold"/>
</font>
<directory>C:\Users\thinkpad\workspace\FopConverter\Fonts</directory>
<directory>C:\Users\thinkpad\workspace\FopConverter\Fonts\ghostFonts</directory>
<substitutions>
<substitution>
<from font-family="Helvetica" font-weight="700..900"/>
<to font-family="Arial"/>
</substitution>
</substitutions>
<auto-detect/>
</fonts>
But even after doing so I still have the same error: org.apache.fop.pdf.PDFConformanceException: For PDF/A-1a, all fonts, even the base 14 fonts, have to be embedded! Offending font: /Helvetica
I also tried to modify the helloworld.fo
by adding font-family="Helvetica" font-weight="normal" font-style="normal"
in the <fo:root">
because some forum topic said to do so but it didn't changed anything.
Please, help me in solving my embedding font error. Thank for reading this topic.
[EDIT]:Here is the entire error message:
FOP ExampleFO2PDF
Preparing...
Input: XSL-FO (.\xml\fo\helloworld.fo)
Output: PDF (.\out\ResultFO2PDF.pdf)
Transforming...
août 07, 2017 11:26:49 AM org.apache.fop.events.LoggingEventListener processEvent
INFOS: Rendered page #1.
org.apache.fop.pdf.PDFConformanceException: For PDF/A-1b, all fonts, even the base 14 fonts, have to be embedded! Offending font: /Helvetica
at org.apache.fop.pdf.PDFFont.validate(PDFFont.java:170)
at org.apache.fop.pdf.PDFFont.output(PDFFont.java:179)
at org.apache.fop.pdf.PDFDocument.outputIndirectObject(PDFDocument.java:1053)
at org.apache.fop.pdf.PDFDocument.streamIndirectObject(PDFDocument.java:1018)
at org.apache.fop.pdf.PDFDocument.output(PDFDocument.java:994)
at org.apache.fop.pdf.PDFDocument.outputTrailer(PDFDocument.java:1097)
at org.apache.fop.render.pdf.PDFDocumentHandler.endDocument(PDFDocumentHandler.java:191)
at org.apache.fop.render.intermediate.util.IFDocumentHandlerProxy.endDocument(IFDocumentHandlerProxy.java:187)
at org.apache.fop.render.intermediate.IFRenderer.stopRenderer(IFRenderer.java:295)
at org.apache.fop.area.RenderPagesModel.endDocument(RenderPagesModel.java:265)
at org.apache.fop.area.AreaTreeHandler.endDocument(AreaTreeHandler.java:342)
at org.apache.fop.fo.FOTreeBuilder.endDocument(FOTreeBuilder.java:170)
at org.apache.xalan.transformer.TransformerIdentityImpl.endDocument(TransformerIdentityImpl.java:963)
at org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:485)
at ConverterFO2PDFa.convertFO2PDF(ConverterFO2PDFa.java:104)
at ConverterFO2PDFa.main(ConverterFO2PDFa.java:154)
I was able to create a PDF/A output using the same example files after a few changes:
in the input FO file, I explicitly added
font-family="Helvetica"
(or your favourite font family) in a position where it effected all the textWithout this, even if FOP defaults to using Helvetica when no
font-family
is set, it apparently is not able to find a configuration for it.in the configuration file, I mapped the Helvetica font family to an existing font, for example Arial
<font kerning="yes" embed-url="/Library/Fonts/arial.ttf"> <font-triplet name="Helvetica" style="normal" weight="normal"/> </font>
in the Java code, I configured FOP to use my configuration file, and the user agent to enable accessibility
import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; import org.apache.fop.apps.FopFactoryBuilder; ... DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder(); Configuration cfg = cfgBuilder.buildFromFile(new File("/Users/lfurini/fop.xconf")); FopFactoryBuilder fopFactoryBuilder = new FopFactoryBuilder(new File(".").toURI()).setConfiguration(cfg); FopFactory fopFactory = fopFactoryBuilder.build(); FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); // configure foUserAgent as desired foUserAgent.setAccessibility(true); foUserAgent.getRendererOptions().put("pdf-a-mode", "PDF/A-1b"); ...
这篇关于FO到PDF / a转换与Apache FOP Java库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!