androidpdf-generationandroid-droidtext

Inserting image in pdf android


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();

Solution

  • solved...

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