Inserting image in pdf android

5.1k Views Asked by At

How to add image in a pdf using DroidText I have tried the following code -

Document document = new Document();
File f=new File(Environment.getExternalStorageDirectory(), "SimpleImages.pdf");
PdfWriter.getInstance(document,new FileOutputStream(f));
document.open();
document.add(new Paragraph("Simple Image"));

Image image =Image.getInstance("file:///mnt/sdcard/img.png");
document.add(image);
document.close();
2

There are 2 best solutions below

0
On BEST ANSWER

solved...

Image image =Image.getInstance("sdcard/img.png");
0
On

You Can Do It Like this.It is working

Image image = Image.getInstance ("file:///mnt/sdcard/Wallpapers/i_love_you.jpg"); document.add(image);