Skip to content Skip to sidebar Skip to footer

Add An Image To Itext Pdf In Android

I have an String containing images like 'My string [img src=image_from_drawable/] blablabla'. I'm able to parse this string as Spannable to show that drawable on my TextView, with

Solution 1:

Creating a Chunk with an image is indeed the way to go. Please take a look at this chapter of the ZUGFeRD tutorial: Creating PDF/A files with iText

It has an example that creates text with images that look like this:

enter image description here

This is how it's done:

Paragraph p =new Paragraph();
Chunk c =new Chunk("The quick brown ");
p.add(c);
Image i = Image.getInstance("resources/images/fox.bmp"");
c = new Chunk(i, 0, -24);
p.add(c);
c = new Chunk(" jumps over the lazy ");
p.add(c);
i = Image.getInstance("resources/images/dog.bmp"");
c =new Chunk(i, 0, -24);
p.add(c);
document.add(p);

I hope this helps.

Post a Comment for "Add An Image To Itext Pdf In Android"