I want to generate a PDF report in my app and share it. I want to avoid 3rd party libraries. Tried using PdfDocument.
https://developer.android.com/reference/android/graphics/pdf/PdfDocument.html
Works fine, but the size of pdf documents is huge. It's as high as 32MB for a file with 5 images. Tried adding just a small paragraph of Text (only the text, no images). The size was still 40KB.
Tried reducing 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();
Didn'y work. Is there any method to reduce the size of the PDF documents, and if not, is it advisable to try any other format? (Like word, etc..)
0 comments:
Post a Comment