I want to create a PDF report in my application and share it. I want to avoid third-party libraries. Tried to use PdfDocument.
https://developer.android.com/reference/android/graphics/pdf/PdfDocument.html
Works great, but the size of PDFs is huge. This is a maximum of 32 MB for a file with 5 images. I tried to add a small paragraph of text (text only, no images). The size was another 40k.
I tried to reduce the resolution in PrintAttributes, passed in the constructor of PdfDocument.
PrintAttributes printAttrs = new PrintAttributes.Builder().
setColorMode(PrintAttributes.COLOR_MODE_COLOR).
setMediaSize(PrintAttributes.MediaSize.NA_LETTER).
setResolution(new Resolution("RId", PRINT_SERVICE, 50, 50)).
setMinMargins(Margins.NO_MARGINS).
build();
Does not work. Is there a way to reduce the size of PDF documents, and if not, is it advisable to try any other format? (Like a word, etc.)
source
share