Click or drag to resize

JPEG Compression of Images in PDF

The converter compresses the images of the generated PDF with the JPEG algorithm to reduce the size of the document. JPEG compression lowers the quality of the images: the higher the compression level, the smaller the images and the lower their quality.

The JpegCompressionLevel property sets the compression level on a scale from 0 to 100. At 0 the compression is the lowest and the image quality the best. The default level is 10, a good balance between the quality of the images and the size of the document.

For the best image quality, turn the JPEG compression off by setting JpegCompressionEnabled to false. The converter then does not re-encode the images.

PdfConverter pdfConverter = new PdfConverter();
pdfConverter.PdfDocumentOptions.JpegCompressionEnabled = true;
pdfConverter.PdfDocumentOptions.JpegCompressionLevel = 20;
pdfConverter.SavePdfFromUrlToFile("https://www.example.com", "compressed.pdf");

Pages with large photos can also be made smaller with ImagesMaxResolution, which resamples an image drawn at a higher resolution than the one you set (for example 150 pixels per inch for screen reading, 300 for print). The compression of the rest of the document - page content and fonts - is set with PdfCompressionLevel.

See Also