Problem with barcode extension - XSLT XSLFO

398 Views Asked by At

While trying to create barcode with: barcode4j-fop-ext-complete.jar, locally on my computer with command ..\fop-2.5-bin\fop-2.5\fop\fop.bat -c config1.xml -xml 6314587.xml -xsl stylesheet.xsl output.pdf, I get this error:

Exception in thread "main" java.lang.IncompatibleClassChangeError: class 
org.krysalis.barcode4j.fop0205.BarcodeElementMapping can not implement 
org.apache.fop.fo.ElementMapping, 
because it is not an interface (org.apache.fop.fo.ElementMapping is in unnamed module of loader 'app')

Did anyone encounter this problem? How can I fix it?

Is the stylesheet I have barcode implementation as below:

                        <fo:block-container>
                            <fo:block>
                                <fo:block>
                                    <fo:instream-foreign-object>
                                        <barcode:barcode xmlns:barcode="http://barcode4j.krysalis.org/ns" message="123" orientation="90">
                                            <barcode:code128>
                                                <barcode:height>8mm</barcode:height>
                                            </barcode:code128>
                                        </barcode:barcode>
                                    </fo:instream-foreign-object>
                                </fo:block>
                            </fo:block>
                        </fo:block-container>
1

There are 1 best solutions below

0
samael On

Use a maintained barcode4j fork: https://github.com/SingingBush/barcode4j (the barcode4j-cli jar is built when you clone and do a mvn build)

And then do something like:

<fo:instream-foreign-object>
  <barcode:barcode message="123456789" orientation="90">
    <barcode:code128>
      <barcode:height>15mm</barcode:height>
      <barcode:module-width>0.21mm</barcode:module-width>
      <barcode:codesets>ABC</barcode:codesets>
      <barcode:quiet-zone enabled="true">10mw</barcode:quiet-zone>
    </barcode:code128>
  </barcode:barcode>
</fo:instream-foreign-object>