PdfImageCompression enumeration
PdfImageCompression enumeration
Specifies the type of compression applied to images in the PDF file.
Members
Name | Description |
---|---|
AUTO | Automatically selects the most appropriate compression for each image. |
JPEG | Jpeg compression. Does not support transparency. |
Examples
Shows how to specify a compression type for all images in a document that we are converting to PDF.
doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
builder.writeln('Jpeg image:')
builder.insert_image(file_name=IMAGE_DIR + 'Logo.jpg')
builder.insert_paragraph()
builder.writeln('Png image:')
builder.insert_image(file_name=IMAGE_DIR + 'Transparent background logo.png')
# Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
# to modify how that method converts the document to .PDF.
pdf_save_options = aw.saving.PdfSaveOptions()
# Set the "ImageCompression" property to "PdfImageCompression.Auto" to use the
# "ImageCompression" property to control the quality of the Jpeg images that end up in the output PDF.
# Set the "ImageCompression" property to "PdfImageCompression.Jpeg" to use the
# "ImageCompression" property to control the quality of all images that end up in the output PDF.
pdf_save_options.image_compression = pdf_image_compression
# Set the "JpegQuality" property to "10" to strengthen compression at the cost of image quality.
pdf_save_options.jpeg_quality = 10
doc.save(file_name=ARTIFACTS_DIR + 'PdfSaveOptions.ImageCompression.pdf', save_options=pdf_save_options)
See Also
- module aspose.words.saving