我使用 FOP 2.2 在 Eclipse 中创建了一个项目。项目创建的 PDF 文件中需要条形码和二维码。Barcode4j 能够创建条形码,但是,只有在有 zxing 内核的情况下才会创建二维码,基于此,需要从 CVS 存储库下载具有 zxing 的 Apache FOP 1.1 QRCodes 。我做了这篇文章中所说的一切,但是当我尝试创建一个二维码时
<fo:block>
<fo:instream-foreign-object>
<barcode:barcode xmlns:barcode="http://barcode4j.krysalis.org/ns" message="test">
<barcode:qr/>
</barcode:barcode>
</fo:instream-foreign-object>
</fo:block>
我得到一个错误。
org.krysalis.barcode4j.BarcodeException: No barcode configuration element not found
at org.krysalis.barcode4j.BarcodeUtil.createBarcodeGenerator(BarcodeUtil.java:110)
at org.krysalis.barcode4j.BarcodeUtil.createBarcodeGenerator(BarcodeUtil.java:146)
at org.krysalis.barcode4j.fop.BarcodeElement.getDimension(BarcodeElement.java:76)
at org.apache.fop.fo.flow.InstreamForeignObject.prepareIntrinsicSize(InstreamForeignObject.java:112)
at org.apache.fop.fo.flow.InstreamForeignObject.getIntrinsicWidth(InstreamForeignObject.java:125)
at org.apache.fop.layoutmgr.inline.AbstractGraphicsLayoutManager.getInlineArea(AbstractGraphicsLayoutManager.java:60)
at org.apache.fop.layoutmgr.inline.AbstractGraphicsLayoutManager.getNextKnuthElements(AbstractGraphicsLayoutManager.java:116)
at org.apache.fop.layoutmgr.inline.LineLayoutManager.collectInlineKnuthElements(LineLayoutManager.java:698)
at org.apache.fop.layoutmgr.inline.LineLayoutManager.getNextKnuthElements(LineLayoutManager.java:627)
at org.apache.fop.layoutmgr.BlockLayoutManager.getNextChildElements(BlockLayoutManager.java:141)
at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextKnuthElements(BlockStackingLayoutManager.java:289)
at org.apache.fop.layoutmgr.BlockLayoutManager.getNextKnuthElements(BlockLayoutManager.java:113)
at org.apache.fop.layoutmgr.BlockLayoutManager.getNextKnuthElements(BlockLayoutManager.java:105)
at org.apache.fop.layoutmgr.table.TableCellLayoutManager.getNextKnuthElements(TableCellLayoutManager.java:191)
at org.apache.fop.layoutmgr.table.RowGroupLayoutManager.createElementsForRowGroup(RowGroupLayoutManager.java:120)
at org.apache.fop.layoutmgr.table.RowGroupLayoutManager.getNextKnuthElements(RowGroupLayoutManager.java:63)
at org.apache.fop.layoutmgr.table.TableContentLayoutManager.getKnuthElementsForRowIterator(TableContentLayoutManager.java:270)
at org.apache.fop.layoutmgr.table.TableContentLayoutManager.getNextKnuthElements(TableContentLayoutManager.java:212)
at org.apache.fop.layoutmgr.table.TableLayoutManager.getNextKnuthElements(TableLayoutManager.java:272)
at org.apache.fop.layoutmgr.FlowLayoutManager.getNextChildElements(FlowLayoutManager.java:223)
at org.apache.fop.layoutmgr.FlowLayoutManager.addChildElements(FlowLayoutManager.java:147)
at org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements(FlowLayoutManager.java:116)
at org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements(FlowLayoutManager.java:69)
at org.apache.fop.layoutmgr.PageBreaker.getNextKnuthElements(PageBreaker.java:251)
at org.apache.fop.layoutmgr.AbstractBreaker.getNextBlockList(AbstractBreaker.java:770)
at org.apache.fop.layoutmgr.PageBreaker.getNextBlockList(PageBreaker.java:178)
at org.apache.fop.layoutmgr.PageBreaker.getNextBlockList(PageBreaker.java:158)
at org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:389)
at org.apache.fop.layoutmgr.PageBreaker.doLayout(PageBreaker.java:112)
at org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:141)
at org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:267)
at org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:130)
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:360)
at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:190)
at org.apache.xml.serializer.ToXMLSAXHandler.endElement(ToXMLSAXHandler.java:263)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1401)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1376)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2402)
at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2272)
at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1358)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:711)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1275)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1253)
at embedding.ExampleXML2PDF.main(ExampleXML2PDF.java:99)
我想了解此错误的原因,并了解是否有其他方法可以使用 FOP 生成条形码和二维码。