public class DownsampleOptions
Example:
Document doc = new Document(getMyDir() + "Rendering.docx");
// Create a SaveOptions object, verify its default image downsampling settings,
// and then convert the document to .pdf with it.
PdfSaveOptions options = new PdfSaveOptions();
Assert.assertTrue(options.getDownsampleOptions().getDownsampleImages());
Assert.assertEquals(220, options.getDownsampleOptions().getResolution());
doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.Default.pdf", options);
// Set the output resolution to a lower value, then set a downsampling resolution threshold
// which will prevent any images with a resolution of less than 128 from being downsampled.
options.getDownsampleOptions().setResolution(36);
options.getDownsampleOptions().setResolutionThreshold(128);
// Only the first two images from the document will be downsampled at this stage.
doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.LowerResolution.pdf", options);
Constructor Summary |
---|
Property Getters/Setters Summary | ||
---|---|---|
boolean | getDownsampleImages() | |
void | setDownsampleImages(booleanvalue) | |
Specifies whether images should be downsampled. | ||
int | getResolution() | |
void | setResolution(intvalue) | |
Specifies the resolution in pixels per inch which the images should be downsampled to. | ||
int | getResolutionThreshold() | |
void | setResolutionThreshold(intvalue) | |
Specifies the threshold resolution in pixels per inch. If resolution of an image in the document is less than threshold value, the downsampling algorithm will not be applied. A value of 0 means the threshold check is not used and all images that can be reduced in size are downsampled. |
public boolean getDownsampleImages() / public void setDownsampleImages(boolean value)
true
.
Example:
Shows how to change the resolution of images in output pdf documents.Document doc = new Document(getMyDir() + "Rendering.docx"); // Create a SaveOptions object, verify its default image downsampling settings, // and then convert the document to .pdf with it. PdfSaveOptions options = new PdfSaveOptions(); Assert.assertTrue(options.getDownsampleOptions().getDownsampleImages()); Assert.assertEquals(220, options.getDownsampleOptions().getResolution()); doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.Default.pdf", options); // Set the output resolution to a lower value, then set a downsampling resolution threshold // which will prevent any images with a resolution of less than 128 from being downsampled. options.getDownsampleOptions().setResolution(36); options.getDownsampleOptions().setResolutionThreshold(128); // Only the first two images from the document will be downsampled at this stage. doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.LowerResolution.pdf", options);
public int getResolution() / public void setResolution(int value)
Example:
Shows how to change the resolution of images in output pdf documents.Document doc = new Document(getMyDir() + "Rendering.docx"); // Create a SaveOptions object, verify its default image downsampling settings, // and then convert the document to .pdf with it. PdfSaveOptions options = new PdfSaveOptions(); Assert.assertTrue(options.getDownsampleOptions().getDownsampleImages()); Assert.assertEquals(220, options.getDownsampleOptions().getResolution()); doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.Default.pdf", options); // Set the output resolution to a lower value, then set a downsampling resolution threshold // which will prevent any images with a resolution of less than 128 from being downsampled. options.getDownsampleOptions().setResolution(36); options.getDownsampleOptions().setResolutionThreshold(128); // Only the first two images from the document will be downsampled at this stage. doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.LowerResolution.pdf", options);
public int getResolutionThreshold() / public void setResolutionThreshold(int value)
Example:
Shows how to change the resolution of images in output pdf documents.Document doc = new Document(getMyDir() + "Rendering.docx"); // Create a SaveOptions object, verify its default image downsampling settings, // and then convert the document to .pdf with it. PdfSaveOptions options = new PdfSaveOptions(); Assert.assertTrue(options.getDownsampleOptions().getDownsampleImages()); Assert.assertEquals(220, options.getDownsampleOptions().getResolution()); doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.Default.pdf", options); // Set the output resolution to a lower value, then set a downsampling resolution threshold // which will prevent any images with a resolution of less than 128 from being downsampled. options.getDownsampleOptions().setResolution(36); options.getDownsampleOptions().setResolutionThreshold(128); // Only the first two images from the document will be downsampled at this stage. doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.LowerResolution.pdf", options);