New to Telerik Document Processing? Download free 30-day trial

Optimizing and Reducing the Size of PDF Files with RadPdfProcessing

Environment

Version Product Author
2024.2.426 RadPdfProcessing Desislava Yordanova

Description

When handling PDF files, it's often necessary to optimize and reduce their size without compromising the content quality. This involves applying better compression to stream objects and adjusting image quality settings. This KB article shows how to:

  • Compress the content inside a PDF document?
  • Fine-tune the settings to lower the image quality in a PDF for size optimization
  • Optimize the fonts' embedding in RadPdfProcessing

Solution

To optimize and reduce the size of existing PDF files with RadPdfProcessing, follow these steps:

  1. Adjust Image Quality: Set the ImageQuality to a lower setting to reduce the size of images within the PDF. Lower image quality results in smaller file sizes.

    pdfFormatProvider.ExportSettings.ImageQuality = ImageQuality.Low;
    

    Additional information on setting image quality can be found in the official ImageQuality documentation.

  2. Apply Image Compression: Specify the types of ImageCompression to use. FlateDecode is recommended for effective compression.

    pdfFormatProvider.ExportSettings.ImageCompression = new ImageFilterTypes[] { ImageFilterTypes.FlateDecode };
    

    Learn more about image compression settings in the ImageCompression documentation.

  3. Enable Stream Compression: Similar to image compression, stream compression can be applied to reduce the size of non-image content.

    pdfFormatProvider.ExportSettings.StreamCompression = new StreamFilterTypes[] { StreamFilterTypes.FlateDecode };
    

    For more details on stream compression, visit the StreamCompression documentation.

  4. Optimize Font Embedding: Starting from Q2 2024, you can use FontEmbeddingType.Subset to export only the necessary parts of True Type Fonts (TTF), which reduces the PDF file size.

    pdfFormatProvider.ExportSettings.FontEmbeddingType = FontEmbeddingType.Subset;
    

    Further information on font embedding types can be found in the FontEmbeddingType documentation.

Notes

  • Optimize and reduce the size of PDF files judiciously. Lowering image quality and applying aggressive compression can affect the visual fidelity of the document.
  • Always test the output PDF to ensure the optimizations meet your requirements.

See Also

In this article