Click or drag to resize

PdfImageCompression Enumeration

Specifies the type of compression applied to images in the PDF file.

Namespace:  Aspose.Words.Saving
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.7.0

Syntax

public enum PdfImageCompression

Members

  Member nameValueDescription
Auto0 Automatically selects the most appropriate compression for each image.
Jpeg1 Jpeg compression. Does not support transparency.

Examples

Shows how to save images to PDF using JPEG encoding to decrease file size.
Document doc = new Document(MyDir + "Images.docx");

PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.ImageCompression = PdfImageCompression.Jpeg;
pdfSaveOptions.DownsampleOptions.DownsampleImages = false;

doc.Save(ArtifactsDir + "PdfSaveOptions.ImageCompression.pdf", pdfSaveOptions);

PdfSaveOptions pdfSaveOptionsA1B = new PdfSaveOptions();
pdfSaveOptionsA1B.Compliance = PdfCompliance.PdfA1b;
pdfSaveOptionsA1B.ImageCompression = PdfImageCompression.Jpeg;
pdfSaveOptionsA1B.DownsampleOptions.DownsampleImages = false;
// Use JPEG compression at 50% quality to reduce file size
pdfSaveOptionsA1B.JpegQuality = 100;
pdfSaveOptionsA1B.ImageColorSpaceExportMode = PdfImageColorSpaceExportMode.SimpleCmyk;

doc.Save(ArtifactsDir + "PdfSaveOptions.ImageCompression.PDF_A_1_B.pdf", pdfSaveOptionsA1B);

PdfSaveOptions pdfSaveOptionsA1A = new PdfSaveOptions();
pdfSaveOptionsA1A.Compliance = PdfCompliance.PdfA1a;
pdfSaveOptionsA1A.ExportDocumentStructure = true;
pdfSaveOptionsA1A.ImageCompression = PdfImageCompression.Jpeg;
pdfSaveOptionsA1A.DownsampleOptions.DownsampleImages = false;

doc.Save(ArtifactsDir + "PdfSaveOptions.ImageCompression.PDF_A_1_A.pdf", pdfSaveOptionsA1A);

See Also