Converted PDF is large in size

Hi Team,
We have a docx approx 4mb wich when converted using Groupdocs conversion to pdf The size grows to 30mb. We understood, it is becuase the groupdocs might be re-encoding images with max quality insgtead of using original and leading to high size of file. Can you please check and help us to optimise it.
Some how file greater than 4mb cannot be attached in here. Uploading the files here

@pankajgupta,

Thanks for sharing the files, that made it easy to look into.

Your guess is right. The pictures in your DOCX are JPEG photos that are already heavily compressed. During the conversion to PDF they are decoded and written again at full JPEG quality instead of being embedded as they are. A low-quality JPEG saved again at maximum quality becomes several times larger without looking any better, and in your PDF almost the whole 22 MB is image data. The 9 copies of the same picture are stored only once, so it isn’t the number of images. It’s how each one is re-encoded.

You can turn on image compression in the PDF options and set a lower quality. That re-compresses the pictures and should bring the file size down a lot:

PdfOptimizationOptions optimization = new PdfOptimizationOptions();
optimization.setCompressImages(true);
optimization.setImageQuality(75);

PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setOptimizationOptions(optimization);

PdfConvertOptions options = new PdfConvertOptions();
options.setPdfOptions(pdfOptions);

try (Converter converter = new Converter("Test12.docx")) {
    converter.convert("Test12.pdf", options);
}

With your file this brought the PDF from about 22 MB down to about 9 MB at quality 75, and about 7.4 MB at 50. You can go lower if the image quality is still fine for you. Please give it a try and let us know the size you get.

Hey @nikola.yankov : thanks for responding. We may not have knowledge of image and it’s quality and cannot default to a single number for all documents by all customer.
Why can’t groupdocs use the same image instead of encoding to max quality. In that case the file size could be comparable.
Also, if needed you can provide configuration to use original or reencode it to max quality as per consumer choice, right?

@pankajgupta,

Thanks for the follow-up, and you have a fair point. A fixed quality value isn’t a real solution when you don’t know what images your customers’ documents contain. The JPEGs should be embedded in the PDF as they are, without being re-encoded.

We have logged this issue in our tracking system under the ID CONVERSIONJAVA-3337, and our development team will take care of it. We’ll update this thread as soon as we have news.

hey @nikola.yankov , Thanks for taking it. Can you also confirm with which build/release this would be available?

@pankajgupta,

We can’t name a release yet. Once we have decided on the approach and the fix is ready, we’ll let you know here which version it will be included in.