Skip to first unread message

Ryan

unread,
Mar 22, 2016, 12:33:07 PM3/22/16
to PDFTron PDFNet SDK
Question:

On iOS we find pages are blurry for some time, before they look correct. Is there a suggested setting in the PDF or optimisation to avoid this 'bluriness'?

Answer:

The blurry images that you see are low res place holder images, that are replaced by high res ones afterwards. The time to go from low to high res image is dependent on the page complexity, and hardware. So on mobile it is expected that this low resolution placeholder will be on screen longer then would be the case on desktop.

Is there a suggested setting in the PDF or optimisation to avoid this 'bluriness'?

If you are able to pre-process the PDF files, then you can add high resolution thumbnails to the document, and set PDFViewCtrl to use the ones in the document. This will give a better user experience, though the files will be larger. If this is something you would like to persue then let me know and I can advise further.

To generate the thumbnails, and use them in the PDF, you can simply call PDFDoc.GenerateThumbnails passing in the max dimension, say 512, or 1024, to start with. Then you would save as e_linearized or e_remove_unused.

Then to at runtime you call the following after instantiating your PDFViewCtrl object, PDFViewCtrl.SetupThumbnails(true, true, true, 250, /* current_default_is_256MB_on_mobile_and_512MB_desktop */,  0.1);

Above could will use your embedded ones if present, and since the second boolean is true, it will also auto generate for any files that do not have embedded. Though, if a file has a bad/incorrect embedded thumbnails those would be used. There isn't a way to differentiate between thumbs you generated and pre-existing ones.

Beyond that, the default settings of PDFNet and PDFViewCtrl are setup to maximize performance.


Ryan

unread,
Mar 23, 2016, 6:30:50 PM3/23/16
to PDFTron PDFNet SDK
If you cannot pre-process the PDF files, and embed the higher resolution thumbnails, then simply adjusting the parameters for PDFViewCtrl.SetupThumbnails would be best.

[self.pdfViewCtrl SetupThumbnails:NO generate_at_runtime:YES use_disk_cache:YES thumb_max_side_length:1024 max_abs_cache_size:500*1024*1024 max_perc_cache_size:0.1];

 As of this writing the thumb_max_side_length default is 250, so setting of 1024 will result in noticeably better quality thumbs, though you can of course go as high as you like.

To understand what SetupThumbnails does, consider what happens when PDFViewCtrl displays a page.

1. Blank page is displayed. 
2. Two background tasks are launched:
 i) One background task begins rendering at the required zoom level 
ii) Other background task begins rendering a fixed resolution thumbnail
3. Lower resolution thumbnail appears first (this is the "blurry" image you are seeing), replacing the blank page
4. Full resolution image appears, replacing the low res thumbnail

Later, if the user zooms in, the thumbnail immediately replaces the old image, and remains until the new image at the current zoom is generated. Instead of being blank (which often appears as a flickering)

Also, since disk caching is enabled, if the user closes the PDF, and re-opens, then we jump immediately to #3 above.

This thumbnail cache is stored outside of the PDF file, so it does not need to be modified (making it compatible with digitally signed PDF's for instance). Thumbnails are stored compressed, and can be from any number of documents. The cache simply stores as many as it can. Once out of space, it begins replacing the oldest ones.

Note, that the higher the thumbnail size (default is 250) the longer it will take to generate, meaning a blank page is displayed longer the very first time. Also, less page thumbnails can be cached. But once generated and cached, future page viewing will instantly get the benefit of this nicer looking thumbnail when the user is zooming and panning the page.
Reply all
Reply to author
Forward
0 new messages