Using PDFDocument, be sure to reduce your images to drawing them on canvas.
When drawing on the screen, this is enough to scale the bitmap:
canvas.drawBitmap(bmp, src, dst, paint);
However, when using the canvas from PdfDocument.Page.getCanvas this canvas will not reduce the bitmap, it simply compresses it into a smaller area. Instead, you should do something like this:
// Scale bitmap : filter = false since we are always downSampling Bitmap scaledBitmap = Bitmap.createScaledBitmap(bmp, dstWidth, dstHeight, false); // filter=false if downscaling, true if upscaling canvas.drawBitmap(scaledBitmap, null, dst, paint); scaledBitmap.recycle();
It is built into Android, so it is much simpler than using a third-party library. (Above was tested on the Marshmallow platform)
source share