androidpdf-generationandroid-droidtext

droidText unstaisfiedLink error while creating Image instance


I keep on getting unstaisfied link error while creating a pdf using droidText lib.Its on random basis and doesnt happen everytime

The line which throws it is:

Image image = Image.getInstance(url);

stacktrace

02-19 12:09:02.534: E/AndroidRuntime(14477): FATAL EXCEPTION: Thread-10
02-19 12:09:02.534: E/AndroidRuntime(14477): java.lang.UnsatisfiedLinkError: cmmOpenProfile
02-19 12:09:02.534: E/AndroidRuntime(14477):    at org.apache.harmony.awt.gl.color.NativeCMM.cmmOpenProfile(Native Method)
02-19 12:09:02.534: E/AndroidRuntime(14477):    at harmony.java.awt.color.ICC_Profile.<init>(ICC_Profile.java:324)
02-19 12:09:02.534: E/AndroidRuntime(14477):    at harmony.java.awt.color.ICC_Profile.getInstance(ICC_Profile.java:645)
02-19 12:09:02.534: E/AndroidRuntime(14477):    at com.lowagie.text.pdf.codec.PngImage.readPng(PngImage.java:425)
02-19 12:09:02.534: E/AndroidRuntime(14477):    at com.lowagie.text.pdf.codec.PngImage.getImage(PngImage.java:515)
02-19 12:09:02.534: E/AndroidRuntime(14477):    at com.lowagie.text.pdf.codec.PngImage.getImage(PngImage.java:230)
02-19 12:09:02.534: E/AndroidRuntime(14477):    at com.lowagie.text.pdf.codec.PngImage.getImage(PngImage.java:212)
02-19 12:09:02.534: E/AndroidRuntime(14477):    at com.lowagie.text.Image.getInstance(Image.java:275)
02-19 12:09:02.534: E/AndroidRuntime(14477):    at com.test.view.pdf.PdfCreation.getLogo(PdfCreation.java:1094)

Any pointers on what am i doing wrong or how i can resolve this.


Solution

  • droidtext uses parts of Apache Harmony for the awt dependencies. The ICC_Profile implementation of Harmony which gets used when a png image has a iCCP chunk (http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.iCCP) is dependent on a native library. This native code isn't part of droidtext right now.

    I opened an issue for it here: http://code.google.com/p/droidtext/issues/detail?id=6 and will look into it. Would be great if you could attach a png where this issue occurs to the bug.

    As a workaround you can remove the color profile from the png or prevent droidText from applying it by uncommenting line 424-429 in PngImage.java