The converter automatically compresses the images in the generated PDF document using the JPEG compression algorithm to highly reduce the size of the generated PDF document. The reverse side of the JPEG compression is that it also reduces the quality of the images in the generated PDF document. When the JPEG compression level is increased the quality of the images in the PDF decreases.
The PdfDocumentOptions..::..JpegCompressionLevel property of the PdfConverter..::..PdfDocumentOptions object defines the current level used for JPEG compression on a scale from 0 to 100. When the compression level is 0 the compression is the worst and the image quality is the best. The default JPEG compression level used by the converter should offer a good balance between the images quality and the size of the generated PDF document.
The best image quality is obtained when the JpegCompressionLevel is set to 0. It is also possible to completely disable the JPEG compression of the images by setting the JpegCompressionEnabled to false. However, this is not recommended because it has negative implications on conversion speed and the generated PDF document can become very large.
The Document class has the similar Document..::..JpegCompressionLevel and Document..::..JpegCompressionEnabled properties.
Code Sample - Setting JPEG Compression for Best Image Quality
| C# | |
|---|---|
// create the PDF converter PdfConverter pdfConverter = new PdfConverter(); // setup the best image quality and the worst compression pdfConverter.PdfDocumentOptions.JpegCompressionLevel = 0; //create a PDF document Document document = new Document(); document.JpegCompressionLevel = 0; | |