How to set/change resolution of images in XOD file.


we use PDFTron viewer to view XOD files which were converted from PDF files. Conversion can be performed by two different ways. In one scenario PDFNetDotNet4 library is used. In that case it doesn’t matter what value we set for options.SetDPI() function - for all values we get equal XOD files. In another scenario PDFNetC library is used. In that case results are different for different dpi values, but it’s file dependent. I have rather big jpg file (about 20000x15000), for it I get really different XOD files for different DPI. And there is another (smaller - about 4000x3000) file for which XOD files are different until DPI value less 300. Starting with that level it doesn’t matter what dpi is set - resulting XOD will be equal.
In this forum I saw discussions related this problem - XOD images resolution. I don’t understand the meaning of option SetMaximumImagePixels - what does it mean?

As I can see the resulting XOD consists of set of small images.Is there a way to control the size of these tiles? Then XOD file is viewed these tiles caused redundant lines on the image…
Andrey Konovalov.

That is strange that you see a difference between PDFNetDotNet4 and PDFNetC. They are just thin wrappers around the exact same code. My hunch is that you are running different versions of PDFNet.

Regardless, the following settings influence how images are generated for XOD.

First, its important to clarify the two cases that the following apply.

  1. Image data in a PDF.
  2. Vector/text content that needs to be converted to an image, since XOD does not support all the graphics types possible with PDF format.

SetDPI : Sets the desired DPI of generated images. Higher value means higher quality, but larger file size. Also, browsers have bad (fast) down sampling algorithms, so there is often not much benefit in going to a DPI higher than 300, at least at low WebViewer zoom levels.

SetMaximumImagePixels : Some devices/platforms have max image values (e.g. 2MP on older iOS devices). PDFNet will break up images into slices. The exact size of the slices depends on the width, the DPI setting, and this setting. The downside of striping is that JPG/PNG compression is not as effective, so XOD file size can increase. That is, a single image will compress much smaller, then an image sliced up, even if both are at the same DPI. In otherwords, you want this setting as high as possible, with breaking any target platforms that your app targets.

SetPreferJPG : By default images are JPG, which gives great compression, but can result in compression artifacts if the images contain straight lines (like text). Setting this to false, will trigger PNG generation, and most likely a small increase in file size. However, browsers are much more optimized at JPG decompression, so PNG will be slower.
JPEG : faster render, but possible compression artifacts
PNG : slower render, always look good

SetJPGQuality : Assuming above setting is true (default) you can get smaller XOD files by turning this down. If the above setting is false, then this does nothing.

Is there a way to control the size of these tiles?

Yes, SetDPI and SetMaximumImagePixels combine to dictate the output of tiles. You could set SetMaximumImagePixels to the maximum value allowed (so no maximum) and that would essentially disable slicing.

Then XOD file is viewed these tiles caused redundant lines on the image…

Sounds like you are describing another issue.

If the above does not help, then first, I would recommend updating to the latest version of PDFNet.

If that does not help, please submit, either here publicly, or from our support page privately, the following information.

  1. Source PDF
  2. Generated XOD
  3. Screenshot of what you see in browser, clearly indicating browser and OS
  4. Clearly show (in screenshot) what you expected to see.
  5. Code+settings used to create the XOD