public class PdfImageCompression
Example:
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 int | AUTO | |
Automatically selects the most appropriate compression for each image.
|
||
static final int | JPEG | |
Jpeg compression.
Does not support transparency.
|