PDF to SVG Conversion: Why some SVGs won't display on iPad?

Q:

We discovered that some PDFs that are converted to SVG (using pdftron.PDF.Convert.ToSvg()) with the trial convertor are not displaying in iPad safari browser. The header and footer within the svg display but the graphic itself does not display. The same svgs display fine in IE10 and Google Chrome. Any ideas whats wrong with SVG & Safari?

A:

The problem seems to be that the generated SVG files contains PNG images equal and/or larger than 5M pixels. Apparently, iPad’s Safari does not support PNG images of this size.

In order to make the SVG display these images, you can run an optimzer prior to converting the PDF to SVG. Below is a small code snippet that can help you do the optimization:

Optimizer::ImageSettings is;
is.SetImageDPI(144, 96);
Optimizer::MonoImageSettings mis;
mis.SetImageDPI(144, 96);
Optimizer::OptimizerSettings s;
s.SetColorImageSettings(is);
s.SetGrayscaleImageSettings(is);
s.SetMonoImageSettings(mis);
PDFDoc doc(“sample.pdf”);

Optimizer::Optimize(doc, s);
Convert::SVGOutputOptions soo;
soo.SetEmbedImages(true);
Convert::ToSvg(doc, “sample.svg”, soo);

The sample snippet above reduces the DPI of the images to produce lower resolution PNG images which iPad’s Safari can display.