Specify the JPEG image quality
Leave feedback
Decreasing the JPG images quality reduces the size of the output file.
To adjust images quality, set the JpgQuality property of the PdfViewOptions class. The value must be between 1 (minimum quality) and 100. The default value is 90.
To set the image quality, follow these steps:
- Instantiate the Viewer class. Specify the source document path as a constructor parameter.
- Instantiate the PdfViewOptions object.
- Set the PdfViewOptions.JpgQuality value.
- Call the View method of the Viewer object. Specify the PdfViewOptions object as the parameter.
The following code snippet shows how to adjust JPG image quality in the output PDF document:
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// ...
using (Viewer viewer = new Viewer("sample.docx"))
{
// Create view options.
PdfViewOptions viewOptions = new PdfViewOptions();
// Specify the JPG image quality.
viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions();
viewOptions.PdfOptimizationOptions.ImageQuality = 50;
viewer.View(viewOptions);
}
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...
Module Program
Sub Main(args As String())
Using viewer As Viewer = New Viewer("sample.docx")
' Create view options.
Dim viewOptions As PdfViewOptions = New PdfViewOptions()
' Specify the JPG image quality.
viewOptions.PdfOptimizationOptions = New PdfOptimizationOptions()
viewOptions.PdfOptimizationOptions.ImageQuality = 50
viewer.View(viewOptions)
End Using
End Sub
End Module
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.