com.aspose.words
Class DownsampleOptions

java.lang.Object
    extended by com.aspose.words.DownsampleOptions

public class DownsampleOptions 
extends java.lang.Object

Allows to specify downsample options.

Example:

Shows how to change the resolution of images in the PDF document.
Document doc = new Document(getMyDir() + "Images.docx");

// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions options = new PdfSaveOptions();

// By default, Aspose.Words downsample all images in a document that we save to PDF to 220 ppi.
Assert.assertTrue(options.getDownsampleOptions().getDownsampleImages());
Assert.assertEquals(220, options.getDownsampleOptions().getResolution());
Assert.assertEquals(0, options.getDownsampleOptions().getResolutionThreshold());

doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.Default.pdf", options);

// Set the "Resolution" property to "36" to downsample all images to 36 ppi.
options.getDownsampleOptions().setResolution(36);

// Set the "ResolutionThreshold" property to only apply the downsampling to
// images with a resolution that is above 128 ppi.
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
DownsampleOptions()
          
 
Property Getters/Setters Summary
booleangetDownsampleImages()
voidsetDownsampleImages(boolean value)
           Specifies whether images should be downsampled.
intgetResolution()
voidsetResolution(int value)
           Specifies the resolution in pixels per inch which the images should be downsampled to.
intgetResolutionThreshold()
voidsetResolutionThreshold(int value)
           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.
 

Constructor Detail

DownsampleOptions

public DownsampleOptions()

Property Getters/Setters Detail

getDownsampleImages/setDownsampleImages

public boolean getDownsampleImages() / public void setDownsampleImages(boolean value)
Specifies whether images should be downsampled. The default value is true.

Example:

Shows how to change the resolution of images in the PDF document.
Document doc = new Document(getMyDir() + "Images.docx");

// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions options = new PdfSaveOptions();

// By default, Aspose.Words downsample all images in a document that we save to PDF to 220 ppi.
Assert.assertTrue(options.getDownsampleOptions().getDownsampleImages());
Assert.assertEquals(220, options.getDownsampleOptions().getResolution());
Assert.assertEquals(0, options.getDownsampleOptions().getResolutionThreshold());

doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.Default.pdf", options);

// Set the "Resolution" property to "36" to downsample all images to 36 ppi.
options.getDownsampleOptions().setResolution(36);

// Set the "ResolutionThreshold" property to only apply the downsampling to
// images with a resolution that is above 128 ppi.
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);

getResolution/setResolution

public int getResolution() / public void setResolution(int value)
Specifies the resolution in pixels per inch which the images should be downsampled to. The default value is 220 ppi.

Example:

Shows how to change the resolution of images in the PDF document.
Document doc = new Document(getMyDir() + "Images.docx");

// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions options = new PdfSaveOptions();

// By default, Aspose.Words downsample all images in a document that we save to PDF to 220 ppi.
Assert.assertTrue(options.getDownsampleOptions().getDownsampleImages());
Assert.assertEquals(220, options.getDownsampleOptions().getResolution());
Assert.assertEquals(0, options.getDownsampleOptions().getResolutionThreshold());

doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.Default.pdf", options);

// Set the "Resolution" property to "36" to downsample all images to 36 ppi.
options.getDownsampleOptions().setResolution(36);

// Set the "ResolutionThreshold" property to only apply the downsampling to
// images with a resolution that is above 128 ppi.
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);

getResolutionThreshold/setResolutionThreshold

public int getResolutionThreshold() / public void setResolutionThreshold(int value)
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. The default value is 0.

Example:

Shows how to change the resolution of images in the PDF document.
Document doc = new Document(getMyDir() + "Images.docx");

// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions options = new PdfSaveOptions();

// By default, Aspose.Words downsample all images in a document that we save to PDF to 220 ppi.
Assert.assertTrue(options.getDownsampleOptions().getDownsampleImages());
Assert.assertEquals(220, options.getDownsampleOptions().getResolution());
Assert.assertEquals(0, options.getDownsampleOptions().getResolutionThreshold());

doc.save(getArtifactsDir() + "PdfSaveOptions.DownsampleOptions.Default.pdf", options);

// Set the "Resolution" property to "36" to downsample all images to 36 ppi.
options.getDownsampleOptions().setResolution(36);

// Set the "ResolutionThreshold" property to only apply the downsampling to
// images with a resolution that is above 128 ppi.
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);

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.