public class DownsampleOptions
Example:
// Open a document that contains images
Document doc = new Document(getMyDir() + "Rendering.doc");
// If we want to convert the document to .pdf, we can use a SaveOptions implementation to customize the saving process
PdfSaveOptions options = new PdfSaveOptions();
// This conversion will downsample images by default
Assert.assertTrue(options.getDownsampleOptions().getDownsampleImages());
Assert.assertEquals(options.getDownsampleOptions().getResolution(), 220);
// We can set the output resolution to a different value
// The first two images in the input document will be affected by this
options.getDownsampleOptions().setResolution(36);
// We can set a minimum threshold for downsampling
// This value will prevent the second image in the input document from being downsampled
options.getDownsampleOptions().setResolutionThreshold(128);
doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.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.// Open a document that contains images Document doc = new Document(getMyDir() + "Rendering.doc"); // If we want to convert the document to .pdf, we can use a SaveOptions implementation to customize the saving process PdfSaveOptions options = new PdfSaveOptions(); // This conversion will downsample images by default Assert.assertTrue(options.getDownsampleOptions().getDownsampleImages()); Assert.assertEquals(options.getDownsampleOptions().getResolution(), 220); // We can set the output resolution to a different value // The first two images in the input document will be affected by this options.getDownsampleOptions().setResolution(36); // We can set a minimum threshold for downsampling // This value will prevent the second image in the input document from being downsampled options.getDownsampleOptions().setResolutionThreshold(128); doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.pdf", options);
public int getResolution() / public void setResolution(int value)
Example:
Shows how to change the resolution of images in output pdf documents.// Open a document that contains images Document doc = new Document(getMyDir() + "Rendering.doc"); // If we want to convert the document to .pdf, we can use a SaveOptions implementation to customize the saving process PdfSaveOptions options = new PdfSaveOptions(); // This conversion will downsample images by default Assert.assertTrue(options.getDownsampleOptions().getDownsampleImages()); Assert.assertEquals(options.getDownsampleOptions().getResolution(), 220); // We can set the output resolution to a different value // The first two images in the input document will be affected by this options.getDownsampleOptions().setResolution(36); // We can set a minimum threshold for downsampling // This value will prevent the second image in the input document from being downsampled options.getDownsampleOptions().setResolutionThreshold(128); doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.pdf", options);
public int getResolutionThreshold() / public void setResolutionThreshold(int value)
Example:
Shows how to change the resolution of images in output pdf documents.// Open a document that contains images Document doc = new Document(getMyDir() + "Rendering.doc"); // If we want to convert the document to .pdf, we can use a SaveOptions implementation to customize the saving process PdfSaveOptions options = new PdfSaveOptions(); // This conversion will downsample images by default Assert.assertTrue(options.getDownsampleOptions().getDownsampleImages()); Assert.assertEquals(options.getDownsampleOptions().getResolution(), 220); // We can set the output resolution to a different value // The first two images in the input document will be affected by this options.getDownsampleOptions().setResolution(36); // We can set a minimum threshold for downsampling // This value will prevent the second image in the input document from being downsampled options.getDownsampleOptions().setResolutionThreshold(128); doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.pdf", options);