This article explains how to use the ImageQuality enumeration to change the export of images in RadPdfProcessing and how it reflects the images in different scenarios.
The ImageQuality enumeration allows you to control the quality of the images when exporting to PDF. Possible values for this property are High, Medium, and Low. Since Q1 2016, the default value of ImageQuality is High.
The quality of the images reflects the size of the PDF document. The higher the quality, the bigger the document size. This property can be set both in PdfExportSettings and in the constructor of ImageSource.
You can download a runnable project, which demonstrates different approaches for working with images in RadPdfProcessing from our SDK repository.
In order to specify the default ImageQuality value when exporting to PDF, you should use the PdfExportSettings.
Example 1: Set a default value for all images in a document
PdfExportSettings settings = new PdfExportSettings(); settings.ImageQuality = ImageQuality.Medium;
PdfExportSettings.ImageQualityproperty doesn't affect the quality of the images imported from a PDF document. Such images are preserved using
EncodedImageData(see ImageQuality and EncodedImageData Class).
PdfExportSettings.ImageQualityonly affects the export quality of images created using an image stream or a
If you need some particular image to be exported with a different ImageQuality value, you should specify this value in the constructor of ImageSource in order to override the default one.
Example 2: Set the image quality of an image
ImageSource imageSource = new ImageSource(bitmap, ImageQuality.Medium);
When you construct an ImageSource object with EncodedImageData, the image is inserted in the PDF file as it is, without decoding and re-encoding the image data. As RadPdfProcessing does not process the image data in this case, the PdfExportSettings.ImageQuality property is not used for this specific image and setting a value won’t take effect.
When ImageQuality of an image is set to High, RadPdfProcessing internally checks the image stream before processing it. If the image is JPEG or JPEG2000, it is inserted in the PDF file as it is, without processing the image pixels. This way, RadPdfProcessing provides fast and lossless quality export of JPEG and JPEG2000 files, which guarantees maximum quality in the exported document.
JPEG2000 images in RadPdfProcessing can be inserted only with ImageQuality.High. Exporting them with lower ImageQuality value requires decoding JPEG2000 files, which is currently unsupported by the library.