Set image resolution
Leave feedback
On this page
If the output PDF file contains images, you can reduce its resolution.
To allow changing the image resolution, set the compress_images and resize_images properties to True. The GroupDocs.Viewer compresses all images in the file. The max_resolution property determines the maximum resolution.
The following code snippet shows how to reduce image resolution in the file:
from groupdocs.viewer import Viewer
from groupdocs.viewer.options import PdfViewOptions, PdfOptimizationOptions
def set_max_resolution():
# Load document
with Viewer("sample.docx") as viewer:
viewOptions = PdfViewOptions("set_max_resolution/optimized_resolution.pdf")
viewOptions.pdf_optimization_options = PdfOptimizationOptions()
viewOptions.pdf_optimization_options.compress_images = True
viewOptions.pdf_optimization_options.image_quality = 50
viewOptions.pdf_optimization_options.resize_images = True
viewOptions.pdf_optimization_options.max_resolution = 100
viewer.view(viewOptions)
if __name__ == "__main__":
set_max_resolution()
sample.docx is the sample file used in this example. Click here to download it.
The following image demonstrates the result:

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.