IronPDF How-Tos PDF Compression How to Compress PDFs Chaknith Bin Updated:July 28, 2025 PDF compression refers to the process of reducing the file size of a PDF (Portable Document Format) document. This compression is applied to make the PDF file more manageable for storage, sharing, and transmission, especially when dealing with large or image-rich documents. Images typically occupy a significant portion of PDF file sizes because they are generally larger in size compared to text and other content. IronPdf offers PDF compression features that compress the embedded images and reduce the tree structure that often accompanies table data in PDFs. Get started with IronPDF Start using IronPDF in your project today with a free trial. First Step: Start for Free How to Compress PDFs Download the C# library for PDF compression from NuGet Import an existing PDF or render a new PDF Use the CompressImages method to reduce image sizes in the PDF Utilize the CompressStructTree method to minimize the PDF's tree structure Export the compressed PDF document Compress Images Example The way resizing JPEGs works, 100% quality has almost no loss, and 1% is a very low-quality output image. 90% and above: considered high-quality 80%-90%: considered medium-quality 70%-80%: considered low-quality Feel free to explore various values to understand the trade-off between quality and file size. It's important to note that the quality reduction will vary based on the type of input image, and certain images may experience more noticeable clarity reduction than others. :path=/static-assets/pdf/content-code-examples/how-to/pdf-compression-image.cs using IronPdf; ChromePdfRenderer renderer = new ChromePdfRenderer(); PdfDocument pdf = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page"); // Compress images in the PDF pdf.CompressImages(40); pdf.SaveAs("compressed.pdf"); Imports IronPdf Private renderer As New ChromePdfRenderer() Private pdf As PdfDocument = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page") ' Compress images in the PDF pdf.CompressImages(40) pdf.SaveAs("compressed.pdf") $vbLabelText $csharpLabel Compress Images - Size Comparison Reduced by 39.24%!! Understanding Image Compression Options Let's delve into the details of our image compression options: ShrinkImage: This feature scales down the image resolution based on its visible size in the PDF document. By doing so, it significantly reduces the size and quality of the images, optimizing them for efficient storage and transmission. HighQualitySubsampling: This setting determines the chroma subsampling method used for image compression. Selecting "True" utilizes 4:4:4 chroma subsampling, ensuring a higher quality image with full color detail. Conversely, choosing "False" employs 4:1:1 chroma subsampling, which sacrifices some color detail to further reduce the image size. Chroma subsampling is a crucial technique in digital image compression, aimed at reducing the data required to represent an image while preserving its visual quality. It achieves this by selectively reducing the resolution of color information (chrominance) while maintaining the full resolution of brightness information (luminance). In "4:4:4" chroma subsampling, each pixel retains its own color information, resulting in no loss of color detail. Conversely, in "4:1:1" chroma subsampling, the color information is subsampled at a lower resolution, reducing color detail but also reducing file size. Compress Tree Structure Example This feature is used to reduce the size of the PDF by minimizing the tree structure created by the Chrome Engine. It works well with PDFs generated by the Chrome Engine from HTML containing extensive table data. Some PDF rendering engines might output PDFs without this tree structure, making the feature not effective. The downside of removing all this tree structure is that for some PDFs, highlighting text or extracting may not work as effectively. Let's use the PDF with table data to test the CompressStructTree method. :path=/static-assets/pdf/content-code-examples/how-to/pdf-compression-tree-structure.cs using IronPdf; PdfDocument pdf = PdfDocument.FromFile("table.pdf"); // Compress tree structure in PDF pdf.CompressStructTree(); pdf.SaveAs("compressedTable.pdf"); Imports IronPdf Private pdf As PdfDocument = PdfDocument.FromFile("table.pdf") ' Compress tree structure in PDF pdf.CompressStructTree() pdf.SaveAs("compressedTable.pdf") $vbLabelText $csharpLabel Compress Tree Structure - Size Comparison Reduced by 67.90%!! This percentage increases with larger table PDFs. Advanced Compression Methods IronPdf also has a Compress method that can be used to configure both image compression and tree structure compression, making compressing documents easier than ever. :path=/static-assets/pdf/content-code-examples/how-to/pdf-compression-compress.cs using IronPdf; PdfDocument pdf = PdfDocument.FromFile("sample.pdf"); CompressionOptions compressionOptions = new CompressionOptions(); // Configure image compression compressionOptions.CompressImages = true; compressionOptions.JpegQuality = 80; compressionOptions.HighQualityImageSubsampling = true; compressionOptions.ShrinkImages = true; // Configure tree structure compression compressionOptions.RemoveStructureTree = true; pdf.Compress(compressionOptions); pdf.SaveAs("compressed.pdf"); Imports IronPdf Private pdf As PdfDocument = PdfDocument.FromFile("sample.pdf") Private compressionOptions As New CompressionOptions() ' Configure image compression compressionOptions.CompressImages = True compressionOptions.JpegQuality = 80 compressionOptions.HighQualityImageSubsampling = True compressionOptions.ShrinkImages = True ' Configure tree structure compression compressionOptions.RemoveStructureTree = True pdf.Compress(compressionOptions) pdf.SaveAs("compressed.pdf") $vbLabelText $csharpLabel Explore Available Options CompressImages: Controls whether existing images in the document are compressed using JPG encoding. It defaults to false. RemoveStructureTree: Removing the structure tree can significantly reduce the disk space used by the document. However, it may negatively impact text selection, particularly in complicated documents. JpegQuality: Specifies the JPEG quality (ranging from 1 to 100) to be used during image compression. It defaults to 42. HighQualityImageSubsampling: This property determines whether to use 4:4:4 chroma subsampling for higher image quality (true) or 4:1:1 chroma subsampling to further reduce image size (false). ShrinkImages: Scaling down the image resolution can drastically reduce the size and quality of the images in the document. Ready to see what else you can do? Check out our tutorial page here: Addtional Features Frequently Asked Questions How can I compress PDF images in .NET C#? You can use IronPDF to compress PDF images in .NET C#. The library provides a method called CompressImages, which allows you to adjust the JPEG quality and choose between different chroma subsampling options to reduce image sizes effectively. What is the benefit of using a .NET library for PDF compression? Using a .NET library like IronPDF for PDF compression enables you to integrate PDF size reduction directly into your C# applications, enhancing document management by reducing file sizes for easier storage and sharing. How do I reduce the size of PDFs with extensive table data? To reduce the size of PDFs with extensive table data, you can use IronPDF's CompressStructTree method. This method minimizes the PDF's tree structure, significantly reducing the file size while maintaining the document's integrity. What options are available for image quality adjustment in PDF compression? IronPDF provides options to adjust image quality during compression, such as the JpegQuality parameter, which ranges from 1 to 100. Higher values maintain more image detail, while lower values increase compression. Can I control chroma subsampling during PDF image compression? Yes, IronPDF allows you to control chroma subsampling during PDF image compression with the HighQualitySubsampling setting. This lets you choose between higher image quality (4:4:4) or greater size reduction (4:1:1). What are the potential downsides of removing the structure tree in PDFs? While removing the structure tree in PDFs using IronPDF's compression features can significantly reduce file size, it may impact text selection and extraction in complex documents, so it's important to consider this trade-off. How do I configure both image and tree structure compression in PDFs? IronPDF offers a Compress method that allows you to configure both image and tree structure compression in PDFs. This method provides flexibility in adjusting settings to achieve the desired balance between quality and file size. What steps should I take to start compressing PDFs in .NET C#? To start compressing PDFs in .NET C#, download the IronPDF library from NuGet, import an existing PDF or render a new one, and use methods like CompressImages and CompressStructTree to effectively reduce file size. Chaknith Bin Chat with engineering team now Software Engineer Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience. Reviewed by Jeffrey T. Fritz Principal Program Manager - .NET Community Team Jeff is also a Principal Program Manager for the .NET and Visual Studio teams. He is the executive producer of the .NET Conf virtual conference series and hosts 'Fritz and Friends' a live stream for developers that airs twice weekly where he talks tech and writes code together with viewers. Jeff writes workshops, presentations, and plans content for the largest Microsoft developer events including Microsoft Build, Microsoft Ignite, .NET Conf, and the Microsoft MVP Summit Ready to Get Started? Free NuGet Download Total downloads: 15,080,714 View Licenses