Customize the rendering resolution in our Android viewer

To achieve quick and fluid page browsing in a document, PdfFragment will first render and draw low-resolution images for each page that is about to be displayed before switching to a high-resolution rendering for visible pages. The render settings (i.e. the resolution of low-resolution images) are chosen using a smart low-resolution strategy based on Device Year Class(opens in a new tab), balancing page render times, quality, and memory performance.

The default behavior relies on optimized resolutions to allow a better match with a device’s specifications, but if your use case requires a specific low resolution, you can override our automatic low-resolution strategy.

Optimized resolution

With Nutrient Android SDK 4.3, we introduced the optimized resolution strategy by default. With Nutrient Android SDK 6.6, we removed the DeviceYearClass(opens in a new tab) dependency, which was deprecated, and we opted for an in-house implementation that doesn’t require a third-party library, in order to optimize the default configuration. For more information on this, have a look at our migration guide.

Fixed resolution

To exclude our optimized resolution algorithm, PdfConfiguration.Builder#setFixedLowResRenderPixelCount() and PdfConfiguration#getFixedLowResRenderPixelCount() can be used to set and retrieve a fixed low-resolution render pixel count:

val configuration = PdfConfiguration.Builder()
.setFixedLowResRenderPixelCount(1280 * 1280)
.build()

In this way, the same value (1280 * 1280) will be used for all devices.

⚠️ Important: Misuse of the low-resolution render pixel count may lead to poor performance and/or out-of-memory exceptions on older devices. Make sure to test the new value on a wide range of devices.