Android: Embedding a compressed image inside a PDF document

801 Views Asked by At

How to embed a compressed image (e.g. PNG, JPEG, etc.) in an Android PdfDocument?

When writing the image into the Page's canvas, it is encoded as a bitmap, instead I'd like to embed the image compressed as it is.

1

There are 1 best solutions below

0
On

I've just realised I can do this with iText: itext images tutorial

Unfortunately, it does not allow to draw views in a canvas like the native PdfDocument class. So I need to create a PDF without images with PdfDocument and put a placeholder for such images. Then I need to open the pdf file with iText and append the images at the placeholders' location.