PdfSaveOptionsJpegQuality Property

Gets or sets a value determining the quality of the JPEG images inside PDF document.

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


public int JpegQuality { get; set; }

Property Value

Type: Int32


The default value is 100.

This property is used in conjunction with the ImageCompression option.

Has effect only when a document contains JPEG images.

Use this property to get or set the quality of the images inside a document when saving in PDF format. The value may vary from 0 to 100 where 0 means worst quality but maximum compression and 100 means best quality but minimum compression. If quality is 100 and source image is JPEG, it means no compression - original bytes will be saved.


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