Optimize PDF for Mobile Rendering
Rendering PDF documents is quite complex. PSPDFKit has to parse and travese the whole render tree for every page and zoom operation. There are certain aspects that are supported within the PDF spec but come at great cost to implement them. Mobile devices are limited when it comes to resources and processing power, so optimizing your PDF documents can be very beneficial for both performance and battery.
Here are some tips that may help:
Reduce image size
Unnecessarily large images take up precious memory, even when they are not able to be displayed in their full resolution on the smaller screens available on phones and tablets. That's why it's always a good idea to down sample those images. Adobe Acrobat provides an easy way to do it:
Open your document in Adobe Acrobat, go to
File -> Save as Other -> Optimized PDF.. and under the 'Settings' select 'Mobile' as a preset. It already contains settings optimized for displaying PDFs on mobile devices.
Avoid using JPEG 2000 for image compression
JPEG 2000 is an image format similar to JPEG, but has slightly better image quality when two files of the same size are compared. However, this little improvement comes with massive downside, as decompressing such images are much more complex. Often such image compression is the root cause for pages taking a very long time to render.
Checking if the document contains JPEG 2000 images
In order to check if your document contains JPEG 2000 images, open it with Adobe Acrobat and select
Edit -> Preflight.. -> PDF/A compliance -> Verify compliance with PDF/A-1a. If your document contains the JPEG2000 compressed images, they will show up.
Recompressing images to JPEG
To recompress JPEG 2000 images to JPEG in your PDF document, open it with Adobe Acrobat and select
File -> Save as Other -> Optimized PDF.. When setting the image settings, make sure you turn off downsampling and change the compression to JPEG from JPEG 2000.
Alternative solution: open it with Adobe Acrobat and select
Edit -> Preflight.. Then under 'PDF fixups', double-click on 'Recompresses color and grayscale images to JPEG (high quality)' to select the fixed document destination and perform the recompression.