0

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.

Deva
  • 3,919
  • 1
  • 27
  • 38

2 Answers2

1

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

  • Hi Markus, We faced this issue again this time for a jpeg image (lib version 0.4). I have attached the image in the same issue mentioned above. It would be great if you could have a look at it once. Thanks! – Deva Jun 13 '13 at 06:38
  • I can't reproduce any error with the attached image. Reading it into a byte array and then creating the pdf image by using Image.getInstance() works for me. Can you please attach some sample code to the Google Code issue to reproduce the problem. –  Jun 18 '13 at 18:01
0

I had a similar issue, and I solved this way:

Check if your png image has some weird color profile. If you use photoshop to design png images, use "Convert to Profile..." and choose "sRGB IEC61966", and then when "Saving for Web" check the "Convert to sRGB" option.

For more info about color profiles, read: https://imageoptim.com/color-profiles.html and http://viget.com/inspire/the-mysterious-save-for-web-color-shift