Q: There seems to be some pixelation or resolution issue when rendering specific images in a PDF brochure. Is there anything that can be done to render these images more smoothly?

A: Qoppa’s PDF libraries and components uses our own interpolation algorithm that works much better than the built-in Java algorithm well both when up-sampling and when down-sampling images. When the images are rotated however, we revert to the Java interpolation engine which by default uses the RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR.

Here is the difference between using Bilinear versus Nearest Neighbor with Java interpolation.

Interpolation Nearest Neighbor
Interpolation Nearest Neighbor

interpolation_bilinear
Interpolation Bilinear

It is possible to change the rendering hints to use the bi-linear interpolation algorithm instead of the nearest neighbor algorithm by making the following static call before loading a PDF document:

PDFRenderHints.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);

Unfortunately, this will also mean that, when the images contain text, you might obtain blurry text instead of sharp text. This will happen even when the images are not rotated. And you might see some performance hit when rendering PDF documents since the bi-linear algorithm is more CPU intensive than the nearest neighbor.

Nearest Neighbor Non Blurry Text in Images
Nearest Neighbor Algorithm Produces Non Blurry Text in Resized Images
Bilinear Blurry Text in Images
Bilinear Algorithm Produces Blurry Text in Resized Images

We’re looking at resolving this issue for a future release, by also implementing our own algorithm when images are rotated or making sure that the Java bi-linear interpolation does not affect images that are not rotated.