Android PdfDocument file size

后端 未结 5 1550
予麋鹿
予麋鹿 2021-01-05 02:03

I want to generate a PDF File from a View using the PdfDocument android class introduced in KitKat. I managed to do it, and the file is so far generated ok, end

5条回答
  •  悲&欢浪女
    2021-01-05 02:39

    This seems to just be a bug in PdfDocument. The PDF file I created with PdfDocument was 5.6 megabytes. The same document generated through the iOS equivalent was 500K. If I take the Android PDF and run it through Adobe Acrobat's pdf optimization, without compressing any images, the 5.6MB file becomes 350K. They look identical, and I applied no compression in Adobe Acrobat.

    In the actual PDF code, the Android image object dictionary is this

    <>
    

    The PDF from iOS has this dict

    << /Length 8 0 R
    /Type /XObject
    /Subtype /Image
    /Width 1224
    /Height 1584
    /ColorSpace /DeviceRGB
    /SMask 9 0 R
    /BitsPerComponent 8
    /Filter /FlateDecode >>
    

    I think the problem is the lack of the FlateDecode filter in the Android version. When I run it through the Adobe Acrobat PDF optimizer, it gets the FlateDecode filter.

提交回复
热议问题