Barcode4j不起作用(在Unix上]

问题描述 投票:0回答:2

对于我的项目,我需要为PDF生成条形码。

我已经能够在本地Windows Server上,在生产UNIX服务器上成功生成条形码,但是生成失败。

我使用条形码4j,需要生成代码39。

我的模板:

<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:fo="http://www.w3.org/1999/XSL/Format" 
    xmlns:bc="http://barcode4j.krysalis.org/ns" 
    xmlns:barcode="org.krysalis.barcode4j.xalan.BarcodeExt" 
    extension-element-prefixes="barcode"
    exclude-result-prefixes="fo">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="no" indent="yes"/>
    <xsl:param name="versionParam" select="'1.0'"/> 

    <xsl:template match="anforderung">
        <xsl:call-template name="barcode">
        <xsl:with-param name="code" select="barcode/code" />
        <xsl:with-param name="codeoriginal" select="barcode/codeoriginal" />
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="barcode">
        <xsl:param name="code" />
        <xsl:param name="codeoriginal" />
        <fo:block keep-together="always">
            <!-- message für barcode -->
            <xsl:variable name="barcode-cfg">
            <barcode>
                <code39>
                    <height>16mm</height>
                    <module-width>0.3mm</module-width>
                    <human-readable>
                        <placement>none</placement>
                    </human-readable>
                </code39>
            </barcode>
            </xsl:variable>

            <fo:block font-weight="bold" margin-left="0.3in">
                <fo:table table-layout='fixed' width="100%">
                    <fo:table-column column-width="8.2cm" />
                    <fo:table-column column-width="12cm" />
                    <fo:table-body>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block>
                                    <fo:instream-foreign-object>
                                        <xsl:variable name="bc" select="barcode:generate($barcode-cfg, barcode/code)" />
                                        <xsl:copy-of select="$bc" />
                                        <!--xsl:copy-of select="barcode:generate(barcode-cfg, msg)"/-->
                                    </fo:instream-foreign-object>
                                </fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block text-align="justify" font-size="32pt">
                                    <xsl:value-of select="$codeoriginal" />
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-body>
                </fo:table>
            </fo:block>
        </fo:block>
    </xsl:template>

我的图书馆:

  • barcode4j-fop-ext-complete-2.0
  • xalan
  • xercesImpl
  • xml-apis
  • xml-apis-ext
java barcode xsl-fo apache-fop xalan
2个回答
1
投票

也许检查您正在运行的Java版本(java -version)。

例如,如果使用GJC,某些程序将无法正常运行。在这种情况下,请获取OpenJDK或Oracle JDK,然后重试。


1
投票
Avalon Framework类DefaultConfiguration中的

NoSuchMethodError表示您在类路径中可能具有较旧的Avalon Framework。请确保您具有Avalon Framework 4.2.0或更高版本。您可以在Barcode4J的lib目录中找到它。


0
投票

在我的情况下,tomcat没有临时文件夹权限,这就是为什么不生成条形码并且库也没有给我任何错误的原因。所以我只给tomcat临时文件夹权限,然后开始工作。

© www.soinside.com 2019 - 2024. All rights reserved.