BarCode is not displaying on pdf using Apache fop - java

We are facing one issue in barcode generation. Barcode is not showing on pdf and throwing exception
Please find below code
<fo:instream-foreign-object>
<barcode:barcode xmlns:barcode="http://barcode4j.krysalis.org/ns"
message="HELLO WORLD">
<barcode:code128>
<barcode:height>15mm</barcode:height>
</barcode:code128>
</barcode:barcode>
</fo:instream-foreign-object>
pom.xml:
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j-fop-ext-complete</artifactId>
<version>2.0</version>
</dependency>
Error:
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).
Please help me, what is causing issue.
Thanks in Advance
Best Regards
RKG

You can find the discussion over it here
http://comments.gmane.org/gmane.text.xml.fop.user/36178
You must be using barcode4j-fop-ext-complete.jar which is missing barcode-xgc.jar files.
You can download the updated fop barcode4j jar files here :
http://sourceforge.net/projects/barcode4j/files/

I had same issue.
Upgrading version solved my problem
<dependency>
<groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j-fop-ext</artifactId>
<version>2.1</version>
</dependency>

Related

Probably got a version mismatch on `xmlbeans` in pom.xml when accessing Excel File

I got this error:
java.lang.NoSuchMethodError: 'org.apache.xmlbeans.XmlOptions org.apache.xmlbeans.XmlOptions.setUseDefaultNamespace(boolean)'
when using the following xmlbeans Version in pom.xml:
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>5.0.3</version>
</dependency>
I have excluded the xmlbeans from the dependency of poi, poi-ooxml and poi-ooxml-schema.
How to get rid of the error message?
I expect to load Excel file via fileInputStream as follows:
workbook= WorkbookFactory.create(fileInputStream);

DeepLearning4j throwing "Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll." error

Recently i started to learn DeepLearning4j library , so i cloned a dl4j project and executed in eclipse.
After executing , it showed following error:
Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll.
I checked my windows path variables and i could not find any variable of name MKL.
Following are the dependency that i used in the pom.xml :
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native-platform</artifactId>
<version>0.8.0</version>
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-core</artifactId>
<version>0.8.0</version>
</dependency>
You're using a version of dl4j that's more than a year old. Please update to something we support and try again. Our website does not even mention this version. Please use the quickstart docs for the latest version: https://deeplearning4j.org/docs/latest/deeplearning4j-quickstart
Thanks!

How do I solve this below exception I get when converting docx to pdf using Documents4j library?

I am using the below code to convert docx to pdf.
public static void main(String[] args) {
File inputdocxfile = new File(System.getProperty("user.dir") + "/src/test/resources/files/output/");
File outputpdffile = new File(System.getProperty("user.dir") + "/src/test/resources/files/output/"
+ "CustomerOutputdocx.pdf");
IConverter converter = LocalConverter.builder().baseFolder(inputdocxfile)
.workerPool(20, 25, 2, TimeUnit.SECONDS).processTimeout(5, TimeUnit.SECONDS).build();
Future<Boolean> conversion = converter.convert(inputdocxfile).as(DocumentType.MS_WORD).to(outputpdffile)
.as(DocumentType.PDF).prioritizeWith(1000).schedule();
}
and I am getting this below exception. I am using the same code as mentioned in the documents4j official website.
Exception in thread "main" java.lang.IllegalStateException: The application was started without any registered or class-path discovered converters.
at com.documents4j.conversion.ExternalConverterDiscovery.validate(ExternalConverterDiscovery.java:68)
at com.documents4j.conversion.ExternalConverterDiscovery.loadConfiguration(ExternalConverterDiscovery.java:85)
at com.documents4j.conversion.DefaultConversionManager.<init>(DefaultConversionManager.java:22)
at com.documents4j.job.LocalConverter.makeConversionManager(LocalConverter.java:74)
at com.documents4j.job.LocalConverter.<init>(LocalConverter.java:47)
at com.documents4j.job.LocalConverter$Builder.build(LocalConverter.java:162)
at com.apakgroup.docgen.converters.ConvertToPdf.main(ConvertToPdf.java:19)
Exception in thread "Shutdown hook: com.documents4j.job.LocalConverter" java.lang.NullPointerException
at com.documents4j.job.LocalConverter.shutDown(LocalConverter.java:95)
at com.documents4j.job.ConverterAdapter$ConverterShutdownHook.run(ConverterAdapter.java:125)
I had missed few dependencies and I also had to use a newer version of commons-io. I previously used commons-io 1.3 but later I came to know that Documents4J uses commons-io 1.4 or later and when commons-io version was changed it worked. And If anyone wants to know the dependencies I used to convert docx file to pdf in java. These are the ones.
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-local</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-transformer-msoffice-word</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
And let me remind you. This library works only on machines which have MS Office installed in it; as the library uses the application itself to convert docx to pdf. If someone is hosting this code on a server there is also a remote converter which you can use instead of the Local converter as shown here.

Getting java.lang.NoClassDefFoundError: org/bouncycastle/asn1/DEREncodable during PDF Encryption [duplicate]

I'm trying to use iText Java.
When you run the example "how to sign" the following error occurs:
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.tsp.TimeStampTokenInfo
According "Getting Started with iText - How to sign a PDF using iText", I have to use the BouncyCastle.
I downloaded the file: bcprov-jdk15on-147.jar from BouncyCastle download page.
And added to the project: Java Build Path/Libraries/Add External JARs...
I added the following line:
Security.addProvider(new BouncyCastleProvider());
When you run the example the same error occurs.
So I downloaded another file: bcpkix-jdk15on-147.jar entitled "PKIX/CMS/EAC/PKCS/OCSP/TSP/OPENSSL"
And added to the project: Java Build Path/Libraries/Add External JARs...
Now I have two Jars.
When you run the example the following error occurs:
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.asn1.DEREncodable
I tried downloading the file "bcprov-ext-jdk15on-147.jar" but did not solve the problem.
I am using iText 5.2.1 and eclipse on Windows 7 64 bits.
iText marks bouncycastle dependencies as optional. If you require them, you need to add the dependencies in your own pom file.
To find out which dependency to include in your project, open the itextpdf pom.xml file of the version you are using (for example 5.3.2, here) and search for the 2 bouncycastle dependencies.
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.47</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk15on</artifactId>
<version>1.47</version>
<optional>true</optional>
</dependency>
Copy them into your pom file and remove the optional option.
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.3.2</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.47</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk15on</artifactId>
<version>1.47</version>
</dependency>
BouncyCastle libs are undergoing heavy API changes that broke the compatibility with other libs like iText.
Either
use a previous version of BouncyCastle libs. Old versions can be found here. However, you'll have to find the right version of iText that was compatible with this particular version of BC.
make your own build of iText (the SVN trunk has been fixed). iText can be build with Maven (there's a short readme file at the root of the SVN). Please note that it's at your own risk, there may be bugs in trunk.
wait for the next version of iText. From my experience, iText releases come every couple of months, sometime more often, sometimes less. I'm not an iText committer though, so I can't give you any ETA.
More information can be found in this thread
With itextpdf version 5.5.4 org.bouncycastle dependencies are marked as <optional>true</optional>. This means you MUST include those dependencies in your own pom, or you can run into classnotfound exceptions.
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.4</version>
</dependency>
<!-- Bouncycastle dependencies necessary as they are optional = true
in itextpdf ... but they're not-so-optional in reality -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.49</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.49</version>
</dependency>
from version of bcprov-jdk15on-147, class of DEREncodable is no longer exist under the path of org.bouncycastle.asn1. You can use version before 146 (including 146) to resolve this question.
It's strange that the jars available at bouncycastle.org don't seem to contain this class. Perhaps, you may want to use one from the locations listed in this page (link).
i have the same problem, but a fix it when i download the libreria and update those files on /WEBINF/LIB
Luckily, the dependency jars are being delivered along with the iText now.
Please check the repository link below and download extrajars.zip file
http://sourceforge.net/projects/itext/files/
For jruby-ers with the same failure, I updated to jruby-complete-9.1.13.0.jar from jruby-complete-1.6.6.jar and the problem seemed to resolve...FWIW...

Android: error including/repacking dependencies which reference javax core classes

I'm working on an Android app using Maven as the build tool. I managed to set evertyhing up correctly (maven dependencies are exported to the apk etc.), however I have one remaining problem which is driving me crazy.
I want to include a dependency on simpleframework's xml parser defined as follows in my POM file:
<dependency>
<groupId>org.simpleframework</groupId>
<artifactId>simple-xml</artifactId>
<version>2.5.3</version>
</dependency>
When I issue mvn install on the project, I get the following error (truncated):
trouble processing "javax/xml/namespace/NameSpaceContext.class" ...
I know the error results from the simple xml parser referencing these javax-classes, however I haven't found a solution yet (setting the --core-library flag is of no use).
I'm currently trying to repack the dependency with the maven-jarjar-pluging but this doesn't seem to work either.
Can anyone help me out with this? Many, many thanks in advance!
Define your simple-xml depedency like this :
<dependency>
<groupId>org.simpleframework</groupId>
<artifactId>simple-xml</artifactId>
<version>2.6.1</version>
<exclusions>
<!-- StAX is not available on Android -->
<exclusion>
<artifactId>stax</artifactId>
<groupId>stax</groupId>
</exclusion>
<exclusion>
<artifactId>stax-api</artifactId>
<groupId>stax</groupId>
</exclusion>
<!-- Provided by Android -->
<exclusion>
<artifactId>xpp3</artifactId>
<groupId>xpp3</groupId>
</exclusion>
</exclusions>
</dependency>
I use android-maven-plugin, and adding <coreLibrary>true</coreLibrary> to the <configuration> tag of the plugin in the POM works for me. However, there's a bug: https://github.com/jayway/maven-android-plugin/pull/34, that you need to include to fix the plugin you are using, since the bug won't be fixed until 3.0. Here's how I got it working for me using 2.9.0-SNAPSHOT.
add a pluginRepository pointing to http:// oss.sonatype.org/content/repositories/jayway-snapshots/ to get 2.9.0-SNAPSHOT
update your plugin version to use 2.9.0-SNAPSHOT and add <coreLibrary>true</coreLibrary> to pom.xml
get the fix: git clone https://github.com/kevinpotgieter/maven-android-plugin.git
remove src/test/java/com: so the test won't fail
mvn package
copy it and overwrite your local maven cache in .m2 (You may need to remove your plugin repository yours gets overwritten every time.)
Step 3-6 won't be necessary after the fix gets into 2.9.0-SNAPSHOT.
Update July 2010: 2.9.0-beta-4 has the fix, so you don't need the above workaround if you use 2.9.0-beta-4 or later. I tested 2.9.0-beta-5 which worked just fine.
Spring Android uses Maven to integrate Simple. Take a look at the following URL, it should provide pointers on how to get Maven working with Simple.
http://static.springsource.org/spring-android/docs/1.0.x/reference/html/rest-template.html

Categories

Resources