ImageQuality
The ImageQuality enumeration controls how images are exported in RadPdfProcessing and how they appear in different scenarios.
Overview
The ImageQuality enumeration allows you to control the quality of images when exporting to PDF. Possible values for this property are High, Medium, and Low. Starting with Q1 2016, the default value of ImageQuality is High.
Using ImageQuality
The quality of the images affects the size of the PDF document. The higher the quality, the bigger the document size. You can set this property both in PdfExportSettings and in the constructor of ImageSource.
You can download a runnable project that demonstrates different approaches for working with images in RadPdfProcessing from the SDK repository.
Set a Default Value for All Images in a Document
To specify the default ImageQuality value when exporting to PDF, use the PdfExportSettings.
Example 1: Set a default value for all images in a document
PdfExportSettings settings = new PdfExportSettings();
settings.ImageQuality = ImageQuality.Medium;
The
PdfExportSettings.ImageQualityproperty does not affect the quality of images imported from a PDF document. Such images are preserved usingEncodedImageData(see ImageQuality and EncodedImageData Class).PdfExportSettings.ImageQualityonly affects the export quality of images created using an image stream or aBitmapSource.
Specify the Image Quality of an Image
If you need a particular image to be exported with a different ImageQuality value, specify this value in the constructor of ImageSource to override the default one.
Example 2: Set the image quality of an image
ImageSource imageSource = new ImageSource(File.OpenRead("image_path"), ImageQuality.Medium);
ImageQuality and EncodedImageData Class
When you construct an ImageSource object with EncodedImageData, the image is inserted in the PDF file as-is, without decoding and re-encoding the image data. Because 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 has no effect.
ImageQuality.High with JPEG and JPEG2000 Images
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-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 a lowerImageQualityvalue requires decoding JPEG2000 files, which is not supported by the library.
ImageQuality in .NET Standard
The .NET Standard specification does not define APIs for converting images or scaling their quality. To allow the library to export images different than JPEG and JPEG2000 or ImageQuality different than High, you must provide an implementation of the JpegImageConverterBase abstract class. Pass this implementation to the JpegImageConverter property of FixedExtensibilityManager. For more information, see the Cross-Platform Support article.