带有 zxing 的 Apache FOP 1.1 QRCodes
Posted
技术标签:
【中文标题】带有 zxing 的 Apache FOP 1.1 QRCodes【英文标题】:Apache FOP 1.1 QRCodes with zxing 【发布时间】:2012-10-28 21:11:22 【问题描述】:好的,我在使用barcode4j-2.1 和zxing-0.1.2 在FOP 1.1 中生成二维码时遇到问题。通过将<prefer-renderer>true</prefer-renderer>
添加到 fop 配置文件,我目前有一个 FOP 1.0 实现正常工作。
barcode4j 条形码无论是否设置了首选渲染器都可以工作,在barcode4j-2.1 中已修复。
我有所有必要的依赖:
fop-zxing-0.1.2-jar-with-dependencies.jar barcode4j-fop-ext-complete.jar saxon9he.jar - 用于 xslt 2.0 ...这里是条码sn-p:
<fo:block>
<fo:instream-foreign-object>
<qr:qr-code xmlns:qr="http://hobbut.ru/fop/qr-code/"
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)
提前感谢您的帮助
【问题讨论】:
【参考方案1】:您正在使用与 Barcode4J 无关的 xmlns:qr="http://hobbut.ru/fop/qr-code/"。似乎您计划使用除 Barcode4J 之外的其他 FOP 插件,但您最终将 Barcode4J 放置在类路径中而不是正确的插件中。顺便说一句,Barcode4J 在其 CVS 存储库的 HEAD 分支中集成了 ZXing 以生成二维码。
【讨论】:
是的,我使用barcode4j 处理其他条码,使用zxing 插件处理qrcodes;如他们网站上所述。哦,所以barcode4j 在头部CVS 存储库中有zxing 构建。所以我只需要从HEAD CVS下载,编译使用?您能否提供一个 xsl-fo 示例用法,因为我找不到一个。我想我只是在寻找使其正常工作的一般步骤;我不需要详细的步骤……我可以弄清楚。提前致谢。 差不多。可以在 Barcode4J 发行版的 examples/xsl-fo/fop-extension-demo.fo 中找到一个示例。最简单的情况就是:以上是关于带有 zxing 的 Apache FOP 1.1 QRCodes的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 Freemarker 和 Apache FOP 将项目列表呈现为 4 个块?