好吧我在使用条形码4j-2.1和zxing-0.1.2在FOP 1.1中生成QR码时遇到问题。通过将<prefer-renderer>true</prefer-renderer>
添加到fop配置文件,我目前正在使用FOP 1.0实现。
我有所有必要的依赖:
这是条形码片段:
<fo:block>
<fo:instream-foreign-object>
<qr:qr-code xmlns:qr="http://hobbut.ru/fop/qr-code/"
width="5cm"
message="TEST DATA"
correction="m"
encoding="UTF-8">
</qr:qr-code>
</fo:instream-foreign-object>
</fo:block>
当尝试转换prefer-renderer似乎没有效果时,我收到错误:
SEVERE: Image not available. URI: (instream-object). Reason: org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for null (No context info available)
org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found for null
at org.apache.xmlgraphics.image.loader.ImageManager.preloadImage(ImageManager.java:180)
at org.apache.fop.render.intermediate.AbstractIFPainter.drawImageUsingDocument(AbstractIFPainter.java:296)
at org.apache.fop.render.pdf.PDFPainter.drawImage(PDFPainter.java:203)
at org.apache.fop.render.intermediate.IFRenderer.renderForeignObject(IFRenderer.java:1290)
at org.apache.fop.render.AbstractRenderer.renderInlineViewport(AbstractRenderer.java:820)
at org.apache.fop.render.AbstractPathOrientedRenderer.renderInlineViewport(AbstractPathOrientedRenderer.java:785)
at org.apache.fop.render.intermediate.IFRenderer.renderInlineViewport(IFRenderer.java:866)
at org.apache.fop.render.AbstractRenderer.renderInlineArea(AbstractRenderer.java:678)
at org.apache.fop.render.intermediate.IFRenderer.renderInlineArea(IFRenderer.java:913)
at org.apache.fop.render.AbstractRenderer.renderLineArea(AbstractRenderer.java:643)
at org.apache.fop.render.AbstractRenderer.renderBlocks(AbstractRenderer.java:561)
at org.apache.fop.render.AbstractRenderer.renderBlock(AbstractRenderer.java:598)
at org.apache.fop.render.intermediate.IFRenderer.renderBlock(IFRenderer.java:980)
at org.apache.fop.render.AbstractRenderer.renderBlocks(AbstractRenderer.java:546)
at org.apache.fop.render.AbstractRenderer.renderFlow(AbstractRenderer.java:451)
at org.apache.fop.render.AbstractPathOrientedRenderer.renderFlow(AbstractPathOrientedRenderer.java:738)
at org.apache.fop.render.AbstractRenderer.renderMainReference(AbstractRenderer.java:428)
at org.apache.fop.render.AbstractRenderer.renderBodyRegion(AbstractRenderer.java:352)
at org.apache.fop.render.AbstractRenderer.renderRegionViewport(AbstractRenderer.java:299)
at org.apache.fop.render.intermediate.IFRenderer.renderRegionViewport(IFRenderer.java:748)
at org.apache.fop.render.AbstractRenderer.renderPageAreas(AbstractRenderer.java:273)
at org.apache.fop.render.AbstractRenderer.renderPage(AbstractRenderer.java:238)
at org.apache.fop.render.intermediate.IFRenderer.renderPage(IFRenderer.java:597)
at org.apache.fop.area.RenderPagesModel.renderPage(RenderPagesModel.java:193)
at org.apache.fop.area.RenderPagesModel.checkPreparedPages(RenderPagesModel.java:174)
at org.apache.fop.area.RenderPagesModel.addPage(RenderPagesModel.java:146)
at org.apache.fop.layoutmgr.AbstractPageSequenceLayoutManager.finishPage(AbstractPageSequenceLayoutManager.java:312)
at org.apache.fop.layoutmgr.PageSequenceLayoutManager.finishPage(PageSequenceLayoutManager.java:191)
at org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:115)
at org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:267)
at org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:128)
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:347)
at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:181)
at net.sf.saxon.event.ContentHandlerProxy.endElement(ContentHandlerProxy.java:395)
at net.sf.saxon.event.NamespaceReducer.endElement(NamespaceReducer.java:208)
at net.sf.saxon.event.ComplexContentOutputter.endElement(ComplexContentOutputter.java:459)
at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:304)
at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:254)
at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:615)
at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:131)
at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:301)
at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:254)
at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:212)
at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1034)
at net.sf.saxon.Controller.transformDocument(Controller.java:1959)
at net.sf.saxon.Controller.transform(Controller.java:1805)
at cwc.fop.util.templates.FOPConvert.translate(FOPConvert.java:116)
at cwc.fop.util.conversion.XML2PDF.translate(XML2PDF.java:151)
at cwc.fop.util.conversion.XML2PDF.translate(XML2PDF.java:114)
at cwc.fop.util.conversion.XML2PDF.translate(XML2PDF.java:65)
at cwc.fop.server.work.WorkerRunnable.run(WorkerRunnable.java:144)
at cwc.util.threading.WorkQueue$PoolWorker.run(WorkQueue.java:59)
提前感谢您提供任何帮助
答案 0 :(得分:3)
您使用的是xmlns:qr =“http://hobbut.ru/fop/qr-code/”与Barcode4J无关。看起来你计划使用其他一些FOP插件而不是Barcode4J,但你最终将Barcode4J放在了类路径而不是正确的插件中。 BTW,Barcode4J在其CVS存储库的HEAD分支中集成了ZXing用于QR码生成。