How do I add an image on a PDF page in Android?
I tried this code
Image img = Image.create(doc.getSDFDoc(), (
"com.pdftron.pdfnet.demo.pdfviewctrl:raw/" + "background.png"));
And I get an exception. The raw folder is inside the res folder.
Not sure how to load the image from the local resources in an Android app.
You can not access files in the raw/assets folder using an absolute path
because the files are stored inside the apk (see *
One way to access them is to use the *Resources*<http://developer.android.com/reference/android/content/res/Resources.html>class, method openRawResource(), but then you only have either an
InputStream or a file descriptor. And since there is no support for ImageIO
in Android, there is no easy way to get a java.awt.Image object from a
You can store the image in the sdcard and then use something like this:
String path = Environment.getExternalStorageDirectory().toString() +
Image img = Image.create(doc, path);