本文介绍了Apache FOP 1.1 QR码与zxing的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧我在使用条形码4j-2.1和zxing-0.1.2在FOP 1.1中生成QR码时遇到问题。我目前正在通过将< prefer-renderer> true< / prefer-renderer> 添加到fop配置文件中,使FOP 1.0实现正常工作。

OK I am having an issue producing QR Codes in FOP 1.1 using barcode4j-2.1 and zxing-0.1.2. I currently have a FOP 1.0 implementation working correctly, by adding <prefer-renderer>true</prefer-renderer> to the fop configuration file.

barcode4j条形码正常工作,无论是否设置了渲染器,在barcode4j-2.1中修复。

barcode4j barcodes are working regardless if prefer renderer is set or not, fixed in barcode4j-2.1.

我有所有必要的依赖:


  • fop-zxing-0.1.2-jar-with-dependencies.jar

  • barcode4j-fop -ext-complete.jar

  • saxon9he.jar - 用于xslt 2.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似乎没有效果时,我收到错误:

When trying to convert prefer-renderer seems to have no effect, I am receiving the error:

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)

提前感谢您的任何帮助

推荐答案

你'重新使用xmlns:qr =http://hobbut.ru/fop/qr-code/与Ba无关rcode4J。看起来你计划使用其他一些FOP插件而不是Barcode4J,但你最终将Barcode4J放在了类路径而不是正确的插件中。 BTW,Barcode4J在其CVS存储库的HEAD分支中集成了ZXing用于QR码生成。

You're using xmlns:qr="http://hobbut.ru/fop/qr-code/" which has nothing to do with Barcode4J. Seems like you planned to use some other FOP plug-in than Barcode4J but you ultimately placed Barcode4J in the classpath instead of the right plug-in. BTW, Barcode4J has an integration of ZXing for QR Code production in the HEAD branch of its CVS repository.

这篇关于Apache FOP 1.1 QR码与zxing的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-07 21:13