Posted 21 April 2026, 7:20 am EST
How can i Optimize Images on pdf file to reduce file size ?
Forums Home / Document Solutions / Document Solutions for PDF
Posted by: moshek on 21 April 2026, 7:20 am EST
Posted 21 April 2026, 7:20 am EST
How can i Optimize Images on pdf file to reduce file size ?
Posted 22 April 2026, 1:14 am EST
Hi Moshe,
To reduce the size of a PDF in DsPdf, particularly for image-heavy documents, you can apply a combination of image deduplication and optimized compression during the save process.
Recommended approach:
This approach typically provides a significant reduction in file size without affecting visual fidelity.
For maximum size reduction: You can use the unified optimization method, which applies all available optimizations (including image deduplication, font cleanup, and stream compression). However, this method may remove non-essential elements such as embedded thumbnails or scripts. It is recommended to retain embedded fonts to avoid potential rendering issues.
Important note: DsPdf does not perform image downscaling or quality reduction. If further size reduction is required for image-heavy PDFs, preprocessing images (e.g., resizing or lowering quality before embedding into the PDF) should be considered.
Please let us know if you require any further assistance.
Best regards,
Chirag
References:
Posted 23 April 2026, 4:22 am EST
Check the file in https://drive.google.com/open?id=1B8wTc9XbDCjk_fONhnR4fxFTlYtcdzQ5
I try to reduce the file size using then optimization method but it reduce it from 15M to 14.8M
When i use some of the onlin website for example https://www.ilovepdf.com/compress_pdf the file reduce to 3.7M
How can i Achive same result ?
Posted 23 April 2026, 5:23 am EST
Hi Moshe,
We can replicate the behavior you mentioned on our end. We have escalated this matter with the concerned development team for further review and will update you as soon as we get any information from their end.
Internal Tracking ID: DOC-7499
Kind Regards,
Chirag
Posted 30 April 2026, 12:46 am EST
Hi Moshe,
We appreciate your patience while we discussed this with our development team.
The difference in compression is expected. Tools like iLovePDF apply in-place image compression, which significantly reduces file size. In contrast, DsPdf optimization is lossless - it removes duplicate resources and compresses streams but does not recompress existing images, so the reduction is minimal for image-heavy PDFs.
Currently, in-place image compression is not supported. This functionality is planned for a future release, but there is no ETA at this time.
As a workaround, images can be extracted and compressed externally before being added to the PDF. For existing PDFs, achieving similar results would require rebuilding the document with optimized images.
Please let us know if you require any further assistance.
Kind Regards,
Chirag
Posted 30 April 2026, 1:47 am EST
Can you give me an example of how to do this with an existing PDF file?
I know how to extract the images from the file but I don’t know how to update the file back .
Posted 30 April 2026, 6:15 am EST
Hi Moshe,
You can extract images using the GetImages method of GcPdfDocument, remove them using RemoveImages, compress the extracted images, and then draw them back using DrawImage.
Please refer to the attached sample, which demonstrates this workflow using DsPdf.
Note that this approach just shows the optimization pipeline without actually compressing the images, which is required since DsPdf does not currently support in-place image recompression.
Kind Regards,
Chirag
Attachment: CompressPDF.zip