Converting PDF to SVG using PDFTron

Q: I'm interested for include PDFTron pdf to svg conversion in our
app.

1- is it possible to extract .jpg for embedded images and not .png ?
2- is it possible to set the resolution of the extracted images (like
72 dpi) ?
3- is it possible to preserve the grey level of the extracted images
which are in grey level in the PDF ?

I found no information about these features in PDF to SVG
documentation.

For example, i use this syntaxe with pdf2svg :
$ pdf2svg --nofonts --noannots --nothumbs --noxmldoc --verb 0 /Users/g/
Destop/myfile.pdf -o /Users/g/Destop/test
---------------------------
A: At the moment PDF2SVG does not have extra controls to convert all
embedded images to JPEG although it will preserve JPEG if PDF contains
RGB JPEG.

If this is important for you, as a quick workaround, you could convert
PNG to JPEG as a post-processing step (not sure if it is even
necessary to modify SVG if the file extension stays the same - i.e.
png). If there is a big advantage in having JPEG we may add an extra
option to PDF2SVG to force JPEG output for embedded images.

An alternative way to generate SVG from PDF is using PDFNet SDK
(http://www.pdftron.com/pdfnet) and shown in Convert sample project:
http://www.pdftron.com/pdfnet/samplecode.html#Convert

PDFNet also offers a PDF optimization option that can be used to
convert PNG to JPEG as well as to down-sample the images. For example
using the following snippet can significantly reduce the file size of
some documents:

-----
// Assuming C++ (C#, JAVA, etc would be along the same lines).

PDFNet::Initialize();

PDFDoc pdfdoc("my.pdf");
Optimizer::ImageSettings image_settings;

// low quality jpeg compression
image_settings.SetCompressionMode(Optimizer::ImageSettings::e_jpeg);
image_settings.SetQuality(1);

// Set the output dpi to be standard screen resolution
image_settings.SetImageDPI(72,72);

// this option will recompress images not compressed with
// jpeg compression and use the result if the new image is smaller.
image_settings.ForceRecompression(true);

// use the same settings for both color and grayscale images
Optimizer::Optimize(pdfdoc, image_settings,image_settings);

pdfdoc.Save("optimized.pdf", SDF::SDFDoc::e_linearized, NULL);

// Convert the optimized PDF to SVG
pdftron::PDF::Convert::ToSvg(pdfdoc, "svgout");

//-----------------

➢ 1- is it possible to extract .jpg for embedded images and not .png ?

Yes. As a post-processing step or by adding extra option to PDF to SVG
converter.

➢ 2- is it possible to set the resolution of the extracted images
(like 72 dpi) ?

Yes. Using PDFNet Optimizer Add-on (http://www.pdftron.com/pdfnet/
samplecode.html#Optimizer).

➢ 3- is it possible to preserve the grey level of the extracted images
which are in grey level in the PDF ?

Yes, to some extent.