Class DownsampleOptions

Class DownsampleOptions

Namespace: Aspose.Words.Saving
Assembly: Aspose.Words.dll (25.12.0)

Allows to specify downsample options.

To learn more, visit the Save a Document documentation article.

public class DownsampleOptions

Inheritance

object DownsampleOptions

Inherited Members

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Shows how to change the resolution of images in the PDF document.

Document doc = new Document(MyDir + "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.That(options.DownsampleOptions.DownsampleImages, Is.True);
                                                                            Assert.That(options.DownsampleOptions.Resolution, Is.EqualTo(220));
                                                                            Assert.That(options.DownsampleOptions.ResolutionThreshold, Is.EqualTo(0));

                                                                            doc.Save(ArtifactsDir + "PdfSaveOptions.DownsampleOptions.Default.pdf", options);

                                                                            // Set the "Resolution" property to "36" to downsample all images to 36 ppi.
                                                                            options.DownsampleOptions.Resolution = 36;

                                                                            // Set the "ResolutionThreshold" property to only apply the downsampling to
                                                                            // images with a resolution that is above 128 ppi.
                                                                            options.DownsampleOptions.ResolutionThreshold = 128;

                                                                            // Only the first two images from the document will be downsampled at this stage.
                                                                            doc.Save(ArtifactsDir + "PdfSaveOptions.DownsampleOptions.LowerResolution.pdf", options);

Constructors

DownsampleOptions()

public DownsampleOptions()

Properties

DownsampleImages

Specifies whether images should be downsampled.

public bool DownsampleImages { get; set; }

Property Value

bool

Examples

Shows how to change the resolution of images in the PDF document.

Document doc = new Document(MyDir + "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.That(options.DownsampleOptions.DownsampleImages, Is.True);
                                                                            Assert.That(options.DownsampleOptions.Resolution, Is.EqualTo(220));
                                                                            Assert.That(options.DownsampleOptions.ResolutionThreshold, Is.EqualTo(0));

                                                                            doc.Save(ArtifactsDir + "PdfSaveOptions.DownsampleOptions.Default.pdf", options);

                                                                            // Set the "Resolution" property to "36" to downsample all images to 36 ppi.
                                                                            options.DownsampleOptions.Resolution = 36;

                                                                            // Set the "ResolutionThreshold" property to only apply the downsampling to
                                                                            // images with a resolution that is above 128 ppi.
                                                                            options.DownsampleOptions.ResolutionThreshold = 128;

                                                                            // Only the first two images from the document will be downsampled at this stage.
                                                                            doc.Save(ArtifactsDir + "PdfSaveOptions.DownsampleOptions.LowerResolution.pdf", options);

Remarks

The default value is true.

Resolution

Specifies the resolution in pixels per inch which the images should be downsampled to.

public int Resolution { get; set; }

Property Value

int

Examples

Shows how to change the resolution of images in the PDF document.

Document doc = new Document(MyDir + "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.That(options.DownsampleOptions.DownsampleImages, Is.True);
                                                                            Assert.That(options.DownsampleOptions.Resolution, Is.EqualTo(220));
                                                                            Assert.That(options.DownsampleOptions.ResolutionThreshold, Is.EqualTo(0));

                                                                            doc.Save(ArtifactsDir + "PdfSaveOptions.DownsampleOptions.Default.pdf", options);

                                                                            // Set the "Resolution" property to "36" to downsample all images to 36 ppi.
                                                                            options.DownsampleOptions.Resolution = 36;

                                                                            // Set the "ResolutionThreshold" property to only apply the downsampling to
                                                                            // images with a resolution that is above 128 ppi.
                                                                            options.DownsampleOptions.ResolutionThreshold = 128;

                                                                            // Only the first two images from the document will be downsampled at this stage.
                                                                            doc.Save(ArtifactsDir + "PdfSaveOptions.DownsampleOptions.LowerResolution.pdf", options);

Remarks

The default value is 220 ppi.

ResolutionThreshold

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 int ResolutionThreshold { get; set; }

Property Value

int

Examples

Shows how to change the resolution of images in the PDF document.

Document doc = new Document(MyDir + "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.That(options.DownsampleOptions.DownsampleImages, Is.True);
                                                                            Assert.That(options.DownsampleOptions.Resolution, Is.EqualTo(220));
                                                                            Assert.That(options.DownsampleOptions.ResolutionThreshold, Is.EqualTo(0));

                                                                            doc.Save(ArtifactsDir + "PdfSaveOptions.DownsampleOptions.Default.pdf", options);

                                                                            // Set the "Resolution" property to "36" to downsample all images to 36 ppi.
                                                                            options.DownsampleOptions.Resolution = 36;

                                                                            // Set the "ResolutionThreshold" property to only apply the downsampling to
                                                                            // images with a resolution that is above 128 ppi.
                                                                            options.DownsampleOptions.ResolutionThreshold = 128;

                                                                            // Only the first two images from the document will be downsampled at this stage.
                                                                            doc.Save(ArtifactsDir + "PdfSaveOptions.DownsampleOptions.LowerResolution.pdf", options);

Remarks

The default value is 0.

 English