com.aspose.words

Class PdfImageCompression

  • java.lang.Object
    • com.aspose.words.PdfImageCompression
public class PdfImageCompression 
extends java.lang.Object

Utility class containing constants. Specifies the type of compression applied to images in the PDF file.

Example:

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

PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setImageCompression(PdfImageCompression.JPEG);
pdfSaveOptions.getDownsampleOptions().setDownsampleImages(false);

doc.save(getArtifactsDir() + "PdfSaveOptions.ImageCompression.pdf", pdfSaveOptions);

PdfSaveOptions pdfSaveOptionsA1B = new PdfSaveOptions();
pdfSaveOptionsA1B.setCompliance(PdfCompliance.PDF_A_1_B);
pdfSaveOptionsA1B.setImageCompression(PdfImageCompression.JPEG);
pdfSaveOptionsA1B.getDownsampleOptions().setDownsampleImages(false);
// Use JPEG compression at 50% quality to reduce file size
pdfSaveOptionsA1B.setJpegQuality(100);
pdfSaveOptionsA1B.setImageColorSpaceExportMode(PdfImageColorSpaceExportMode.SIMPLE_CMYK);

doc.save(getArtifactsDir() + "PdfSaveOptions.ImageCompression.PDF_A_1_B.pdf", pdfSaveOptionsA1B);

PdfSaveOptions pdfSaveOptionsA1A = new PdfSaveOptions();
pdfSaveOptionsA1A.setCompliance(PdfCompliance.PDF_A_1_A);
pdfSaveOptionsA1A.setExportDocumentStructure(true);
pdfSaveOptionsA1A.setImageCompression(PdfImageCompression.JPEG);
pdfSaveOptionsA1A.getDownsampleOptions().setDownsampleImages(false);

doc.save(getArtifactsDir() + "PdfSaveOptions.ImageCompression.PDF_A_1_A.pdf", pdfSaveOptionsA1A);

Field Summary
static final intAUTO = 0
Automatically selects the most appropriate compression for each image.
static final intJPEG = 1
Jpeg compression. Does not support transparency.
 

    • Field Detail

      • AUTO = 0

        public static final int AUTO
        Automatically selects the most appropriate compression for each image.
      • JPEG = 1

        public static final int JPEG
        Jpeg compression. Does not support transparency.