Aspose::Words::Saving::ImageSaveOptions Class Reference

Detailed Description

Allows to specify additional options when rendering document pages or shapes to images.

Examples

Renders a page of a Word document into a PNG image at a specific resolution.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Png);
options->set_Resolution(300);
options->set_PageCount(1);
doc->Save(ArtifactsDir + u"Rendering.SaveToImageResolution.png", options);

Converts a page of a Word document into JPEG images of different qualities.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto saveOptions = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Jpeg);
// Try worst quality
saveOptions->set_JpegQuality(0);
doc->Save(ArtifactsDir + u"Rendering.SaveToImageJpegQuality.0.jpeg", saveOptions);
// Try best quality
saveOptions->set_JpegQuality(100);
doc->Save(ArtifactsDir + u"Rendering.SaveToImageJpegQuality.100.jpeg", saveOptions);

Renders a page of a Word document into an image with transparent or colored background.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto imgOptions = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Png);
imgOptions->set_PaperColor(System::Drawing::Color::get_Transparent());
doc->Save(ArtifactsDir + u"Rendering.SaveToImagePaperColor.Transparent.png", imgOptions);
imgOptions->set_PaperColor(System::Drawing::Color::get_LightCoral());
doc->Save(ArtifactsDir + u"Rendering.SaveToImagePaperColor.Coral.png", imgOptions);

#include <Aspose.Words.Cpp/Model/Saving/ImageSaveOptions.h>

+ Inheritance diagram for Aspose::Words::Saving::ImageSaveOptions:

Public Member Functions

 ImageSaveOptions (SaveFormat saveFormat)
 Initializes a new instance of this class that can be used to save rendered images in the Tiff, Png, Bmp, Emf, Jpeg or Svg format. Png, Bmp, Jpeg or Svg format. More...
 
SharedPtr< ImageSaveOptionsClone ()
 Creates a deep clone of this object. More...
 
float get_HorizontalResolution () const
 Gets or sets the horizontal resolution for the generated images, in dots per inch. More...
 
float get_ImageBrightness () const
 Gets or sets the brightness for the generated images. More...
 
ImageColorMode get_ImageColorMode () const
 Gets or sets the color mode for the generated images. More...
 
float get_ImageContrast () const
 Gets or sets the contrast for the generated images. More...
 
int32_t get_JpegQuality ()
 Gets or sets a value determining the quality of the generated JPEG images. More...
 
SharedPtr< MetafileRenderingOptionsget_MetafileRenderingOptions ()
 Allows to specify how metafiles are treated in the rendered output. More...
 
int32_t get_PageCount ()
 Gets or sets the number of pages to render when saving to a multipage TIFF or SVG file (for other formats only the first page of the range is saved). Default is MaxValue which means all pages of the document will be rendered. More...
 
int32_t get_PageIndex ()
 Gets or sets the 0-based index of the first page to render. Default is 0. More...
 
SharedPtr< PageSetget_PageSet ()
 Gets or sets the pages to render. Default is all the pages in the document. More...
 
Color get_PaperColor ()
 Gets or sets the background (paper) color for the generated images. The default value is White. More...
 
ImagePixelFormat get_PixelFormat () const
 Gets or sets the pixel format for the generated images. More...
 
SaveFormat get_SaveFormat () override
 Specifies the format in which the rendered document pages or shapes will be saved if this save options object is used. Can be a raster Tiff, Png, Bmp, Jpeg or vector Emf, Svg. More...
 
float get_Scale () const
 Gets or sets the zoom factor for the generated images. More...
 
uint8_t get_ThresholdForFloydSteinbergDithering () const
 Gets or sets the threshold that determines the value of the binarization error in the Floyd-Steinberg method. when ImageBinarizationMethod is ImageBinarizationMethod.FloydSteinbergDithering. More...
 
ImageBinarizationMethod get_TiffBinarizationMethod () const
 Gets or sets method used while converting images to 1 bpp format when SaveFormat is SaveFormat.Tiff and TiffCompression is equal to TiffCompression.Ccitt3 or TiffCompression.Ccitt4. More...
 
TiffCompression get_TiffCompression () const
 Gets or sets the type of compression to apply when saving generated images to the TIFF format. More...
 
bool get_UseGdiEmfRenderer () const
 Gets or sets a value determining whether to use GDI+ or Aspose.Words metafile renderer when saving to EMF. More...
 
float get_VerticalResolution () const
 Gets or sets the vertical resolution for the generated images, in dots per inch. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_HorizontalResolution (float value)
 Setter for get_HorizontalResolution. More...
 
void set_ImageBrightness (float value)
 Setter for get_ImageBrightness. More...
 
void set_ImageColorMode (ImageColorMode value)
 Setter for get_ImageColorMode. More...
 
void set_ImageContrast (float value)
 Setter for get_ImageContrast. More...
 
void set_JpegQuality (int32_t value)
 Setter for get_JpegQuality. More...
 
void set_PageCount (int32_t value)
 Setter for get_PageCount. More...
 
void set_PageIndex (int32_t value)
 Setter for get_PageIndex. More...
 
void set_PageSet (SharedPtr< PageSet > value)
 Setter for get_PageSet. More...
 
void set_PaperColor (Color value)
 Setter for get_PaperColor. More...
 
void set_PixelFormat (ImagePixelFormat value)
 Setter for get_PixelFormat. More...
 
void set_Resolution (float value)
 Sets both horizontal and vertical resolution for the generated images, in dots per inch. More...
 
void set_SaveFormat (SaveFormat value) override
 Setter for get_SaveFormat. More...
 
void set_Scale (float value)
 Setter for get_Scale. More...
 
void set_ThresholdForFloydSteinbergDithering (uint8_t value)
 Setter for get_ThresholdForFloydSteinbergDithering. More...
 
void set_TiffBinarizationMethod (ImageBinarizationMethod value)
 Setter for get_TiffBinarizationMethod. More...
 
void set_TiffCompression (TiffCompression value)
 Setter for get_TiffCompression. More...
 
void set_UseGdiEmfRenderer (bool value)
 Setter for get_UseGdiEmfRenderer. More...
 
void set_VerticalResolution (float value)
 Setter for get_VerticalResolution. More...
 
- Public Member Functions inherited from FixedPageSaveOptions
bool Equals (SharedPtr< Object > obj) override
 Determines whether the specified object is equal in value to the current object. More...
 
ColorMode get_ColorMode () const
 Gets or sets a value determining how colors are rendered. More...
 
int32_t get_JpegQuality () const
 Gets or sets a value determining the quality of the JPEG images inside Html document. More...
 
SharedPtr< MetafileRenderingOptionsget_MetafileRenderingOptions () const
 Allows to specify metafile rendering options. More...
 
NumeralFormat get_NumeralFormat () const
 Gets or sets NumeralFormat used for rendering of numerals. European numerals are used by default. More...
 
virtual bool get_OptimizeOutput ()
 Flag indicates whether it is required to optimize output. If this flag is set redundant nested canvases and empty canvases are removed, also neighbor glyphs with the same formatting are concatenated. Note: The accuracy of the content display may be affected if this property is set to true. Default is false. More...
 
int32_t get_PageCount () const
 Gets or sets the number of pages to save. Default is MaxValue which means all pages of the document will be rendered. More...
 
int32_t get_PageIndex () const
 Gets or sets the 0-based index of the first page to save. Default is 0. More...
 
SharedPtr< IPageSavingCallbackget_PageSavingCallback () const
 Allows to control how separate pages are saved when a document is exported to fixed page format. More...
 
SharedPtr< PageSetget_PageSet () const
 Gets the pages to render. Default is all the pages in the document. More...
 
void set_ColorMode (ColorMode value)
 Setter for get_ColorMode. More...
 
void set_JpegQuality (int32_t value)
 Setter for get_JpegQuality. More...
 
void set_MetafileRenderingOptions (SharedPtr< MetafileRenderingOptions > value)
 Allows to specify metafile rendering options. More...
 
void set_NumeralFormat (NumeralFormat value)
 Setter for get_NumeralFormat. More...
 
virtual void set_OptimizeOutput (bool value)
 Setter for get_OptimizeOutput. More...
 
void set_PageCount (int32_t value)
 Setter for get_PageCount. More...
 
void set_PageIndex (int32_t value)
 Setter for get_PageIndex. More...
 
void set_PageSavingCallback (SharedPtr< IPageSavingCallback > value)
 Allows to control how separate pages are saved when a document is exported to fixed page format. More...
 
void set_PageSet (SharedPtr< PageSet > value)
 Sets the pages to render. Default is all the pages in the document. More...
 
- Public Member Functions inherited from SaveOptions
String get_DefaultTemplate () const
 Gets or sets path to default template (including filename). Default value for this property is empty string (Empty). More...
 
Dml3DEffectsRenderingMode get_Dml3DEffectsRenderingMode () const
 Gets a value determining how 3D effects are rendered. More...
 
virtual DmlEffectsRenderingMode get_DmlEffectsRenderingMode ()
 Gets or sets a value determining how DrawingML effects are rendered. More...
 
DmlRenderingMode get_DmlRenderingMode () const
 Gets or sets a value determining how DrawingML shapes are rendered. More...
 
bool get_MemoryOptimization () const
 Gets or sets value determining if memory optimization should be performed before saving the document. Default value for this property is false. More...
 
bool get_PrettyFormat () const
 When true, pretty formats output where applicable. Default value is false. More...
 
String get_TempFolder () const
 Specifies the folder for temporary files used when saving to a DOC or DOCX file. By default this property is null and no temporary files are used. More...
 
bool get_UpdateFields () const
 Gets or sets a value determining if fields of certain types should be updated before saving the document to a fixed page format. Default value for this property is true. More...
 
bool get_UpdateLastPrintedProperty () const
 Gets or sets a value determining whether the LastPrinted property is updated before saving. More...
 
bool get_UpdateLastSavedTimeProperty () const
 Gets or sets a value determining whether the LastSavedTime property is updated before saving. More...
 
bool get_UpdateSdtContent () const
 Gets or sets value determining whether content of StructuredDocumentTag is updated before saving. More...
 
bool get_UseAntiAliasing () const
 Gets or sets a value determining whether or not to use anti-aliasing for rendering. More...
 
bool get_UseHighQualityRendering () const
 Gets or sets a value determining whether or not to use high quality (i.e. slow) rendering algorithms. More...
 
void set_DefaultTemplate (String value)
 Setter for get_DefaultTemplate. More...
 
void set_Dml3DEffectsRenderingMode (Dml3DEffectsRenderingMode value)
 Sets a value determining how 3D effects are rendered. More...
 
virtual void set_DmlEffectsRenderingMode (DmlEffectsRenderingMode value)
 Setter for get_DmlEffectsRenderingMode. More...
 
void set_DmlRenderingMode (DmlRenderingMode value)
 Setter for get_DmlRenderingMode. More...
 
void set_MemoryOptimization (bool value)
 Setter for get_MemoryOptimization. More...
 
void set_PrettyFormat (bool value)
 Setter for get_PrettyFormat. More...
 
void set_TempFolder (String value)
 Setter for get_TempFolder. More...
 
void set_UpdateFields (bool value)
 Setter for get_UpdateFields. More...
 
void set_UpdateLastPrintedProperty (bool value)
 Setter for get_UpdateLastPrintedProperty. More...
 
void set_UpdateLastSavedTimeProperty (bool value)
 Setter for get_UpdateLastSavedTimeProperty. More...
 
void set_UpdateSdtContent (bool value)
 Setter for get_UpdateSdtContent. More...
 
void set_UseAntiAliasing (bool value)
 Setter for get_UseAntiAliasing. More...
 
void set_UseHighQualityRendering (bool value)
 Setter for get_UseHighQualityRendering. More...
 
- Public Member Functions inherited from Object
ASPOSECPP_SHARED_API Object ()
 
ASPOSECPP_SHARED_API Object (Object const &x)
 
virtual ASPOSECPP_SHARED_API ~Object ()
 
virtual ASPOSECPP_SHARED_API bool Equals (ptr obj)
 
Detail::SmartPtrCounter * GetCounter ()
 
virtual ASPOSECPP_SHARED_API int GetHashCode () const
 
ASPOSECPP_SHARED_API void Lock ()
 
virtual ASPOSECPP_SHARED_API ptr MemberwiseClone () const
 
Objectoperator= (Object const &x)
 
bool ReferenceEquals (String const &str, std::nullptr_t)
 
bool ReferenceEquals (String const &str1, String const &str2)
 
int RemovedSharedRefs (int count)
 
virtual ASPOSECPP_SHARED_API void SetTemplateWeakPtr (unsigned int argument)
 
int SharedCount () const
 
ObjectSharedRefAdded ()
 
int SharedRefRemovedSafe ()
 
virtual ASPOSECPP_SHARED_API String ToString () const
 
ASPOSECPP_SHARED_API void Unlock ()
 
Detail::SmartPtrCounter * WeakRefAdded ()
 
void WeakRefRemoved ()
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from FixedPageSaveOptions
static const TypeInfoType ()
 
- Static Public Member Functions inherited from SaveOptions
static SharedPtr< SaveOptionsCreateSaveOptions (SaveFormat saveFormat)
 Creates a save options object of a class suitable for the specified save format. More...
 
static SharedPtr< SaveOptionsCreateSaveOptions (String fileName)
 Creates a save options object of a class suitable for the file extension specified in the given file name. More...
 
static const TypeInfoType ()
 
- Static Public Member Functions inherited from Object
bool Equals (double const &objA, double const &objB)
 
bool Equals (float const &objA, float const &objB)
 
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 
static const TypeInfoType ()
 

Additional Inherited Members

- Public Types inherited from Object
typedef SmartPtr< Objectptr
 
typedef System::Details::SharedMembersType shared_members_type
 

Constructor & Destructor Documentation

◆ ImageSaveOptions()

Aspose::Words::Saving::ImageSaveOptions::ImageSaveOptions ( Aspose::Words::SaveFormat  saveFormat)

Initializes a new instance of this class that can be used to save rendered images in the Tiff, Png, Bmp, Emf, Jpeg or Svg format. Png, Bmp, Jpeg or Svg format.

Parameters
saveFormatCan be Tiff, Png, Bmp, Emf, Jpeg or Svg. Png, Bmp, Jpeg or Svg.
Examples

Shows how to save a document to the JPEG format using the Save method and the ImageSaveOptions class.

// Open the document
auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// Save as a JPEG image file with default options
doc->Save(ArtifactsDir + u"Rendering.SaveAsImage.DefaultJpgOptions.jpg");
// Save document to stream as a JPEG with default options
auto docStream = MakeObject<System::IO::MemoryStream>();
doc->Save(docStream, Aspose::Words::SaveFormat::Jpeg);
// Rewind the stream position back to the beginning, ready for use
docStream->Seek(static_cast<int64_t>(0), System::IO::SeekOrigin::Begin);
// Save document to a JPEG image with specified options
// Render the third page only and set the JPEG quality to 80%
// In this case we need to pass the desired SaveFormat to the ImageSaveOptions constructor
// to signal what type of image to save as
auto imageOptions = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Jpeg);
imageOptions->set_PageIndex(2);
imageOptions->set_PageCount(1);
imageOptions->set_JpegQuality(80);
doc->Save(ArtifactsDir + u"Rendering.SaveAsImage.CustomJpgOptions.jpg", imageOptions);

Member Function Documentation

◆ Clone()

System::SharedPtr<Aspose::Words::Saving::ImageSaveOptions> Aspose::Words::Saving::ImageSaveOptions::Clone ( )

Creates a deep clone of this object.

Examples

Show how to convert document images to black and white with 1 bit per pixel

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto imageSaveOptions = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Png);
imageSaveOptions->set_ImageColorMode(Aspose::Words::Saving::ImageColorMode::BlackAndWhite);
// ImageSaveOptions instances can be cloned
ASPOSE_ASSERT_NE(imageSaveOptions, imageSaveOptions->Clone());
doc->Save(ArtifactsDir + u"ImageSaveOptions.BlackAndWhite.png", imageSaveOptions);

◆ get_HorizontalResolution()

float Aspose::Words::Saving::ImageSaveOptions::get_HorizontalResolution ( ) const

Gets or sets the horizontal resolution for the generated images, in dots per inch.

This property has effect only when saving to raster image formats and affects the output size in pixels.

The default value is 96.

Examples

Shows how to edit image.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// When saving the document as an image, we can use an ImageSaveOptions object to edit various aspects of it
auto options = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Png);
options->set_ImageBrightness(0.3f);
options->set_ImageContrast(0.7f);
options->set_HorizontalResolution(72.f);
options->set_VerticalResolution(72.f);
options->set_Scale(96.f / 72.f);
doc->Save(ArtifactsDir + u"ImageSaveOptions.EditImage.png", options);

◆ get_ImageBrightness()

float Aspose::Words::Saving::ImageSaveOptions::get_ImageBrightness ( ) const

Gets or sets the brightness for the generated images.

This property has effect only when saving to raster image formats.

The default value is 0.5. The value must be in the range between 0 and 1.

Examples

Shows how to edit image.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// When saving the document as an image, we can use an ImageSaveOptions object to edit various aspects of it
auto options = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Png);
options->set_ImageBrightness(0.3f);
options->set_ImageContrast(0.7f);
options->set_HorizontalResolution(72.f);
options->set_VerticalResolution(72.f);
options->set_Scale(96.f / 72.f);
doc->Save(ArtifactsDir + u"ImageSaveOptions.EditImage.png", options);

◆ get_ImageColorMode()

Aspose::Words::Saving::ImageColorMode Aspose::Words::Saving::ImageSaveOptions::get_ImageColorMode ( ) const

Gets or sets the color mode for the generated images.

This property has effect only when saving to raster image formats.

The default value is None.

Examples

Show how to convert document images to black and white with 1 bit per pixel

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto imageSaveOptions = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Png);
imageSaveOptions->set_ImageColorMode(Aspose::Words::Saving::ImageColorMode::BlackAndWhite);
// ImageSaveOptions instances can be cloned
ASPOSE_ASSERT_NE(imageSaveOptions, imageSaveOptions->Clone());
doc->Save(ArtifactsDir + u"ImageSaveOptions.BlackAndWhite.png", imageSaveOptions);

◆ get_ImageContrast()

float Aspose::Words::Saving::ImageSaveOptions::get_ImageContrast ( ) const

Gets or sets the contrast for the generated images.

This property has effect only when saving to raster image formats.

The default value is 0.5. The value must be in the range between 0 and 1.

Examples

Shows how to edit image.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// When saving the document as an image, we can use an ImageSaveOptions object to edit various aspects of it
auto options = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Png);
options->set_ImageBrightness(0.3f);
options->set_ImageContrast(0.7f);
options->set_HorizontalResolution(72.f);
options->set_VerticalResolution(72.f);
options->set_Scale(96.f / 72.f);
doc->Save(ArtifactsDir + u"ImageSaveOptions.EditImage.png", options);

◆ get_JpegQuality()

int32_t Aspose::Words::Saving::ImageSaveOptions::get_JpegQuality ( )

Gets or sets a value determining the quality of the generated JPEG images.

Has effect only when saving to JPEG.

Use this property to get or set the quality of generated images when saving in JPEG format. The value may vary from 0 to 100 where 0 means worst quality but maximum compression and 100 means best quality but minimum compression.

The default value is 95.

Examples

Converts a page of a Word document into JPEG images of different qualities.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto saveOptions = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Jpeg);
// Try worst quality
saveOptions->set_JpegQuality(0);
doc->Save(ArtifactsDir + u"Rendering.SaveToImageJpegQuality.0.jpeg", saveOptions);
// Try best quality
saveOptions->set_JpegQuality(100);
doc->Save(ArtifactsDir + u"Rendering.SaveToImageJpegQuality.100.jpeg", saveOptions);

◆ get_MetafileRenderingOptions()

System::SharedPtr<Aspose::Words::Saving::MetafileRenderingOptions> Aspose::Words::Saving::ImageSaveOptions::get_MetafileRenderingOptions ( )

Allows to specify how metafiles are treated in the rendered output.

When Vector is specified, Aspose.Words renders metafile to vector graphics using its own metafile rendering engine first and then renders vector graphics to the image.

When Bitmap is specified, Aspose.Words renders metafile directly to the image using the GDI+ metafile rendering engine.

GDI+ metafile rendering engine works faster, supports almost all metafile features but on low resolutions may produce inconsistent result when compared to the rest of vector graphics (especially for text) on the page. Aspose.Words metafile rendering engine will produce more consistent result even on low resolutions but works slower and may inaccurately render complex metafiles.

The default value for MetafileRenderingMode is Bitmap.

Examples

Shows how to set the rendering mode for Windows Metafiles.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Use a DocumentBuilder to insert a .wmf image into the document
builder->InsertImage(System::Drawing::Image::FromFile(ImageDir + u"Windows MetaFile.wmf"));
// Save the document as an image while setting different metafile rendering modes,
// which will be applied to the image we inserted
auto options = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Png);
options->get_MetafileRenderingOptions()->set_RenderingMode(Aspose::Words::Saving::MetafileRenderingMode::Vector);
doc->Save(ArtifactsDir + u"ImageSaveOptions.WindowsMetaFile.png", options);

◆ get_PageCount()

int32_t Aspose::Words::Saving::ImageSaveOptions::get_PageCount ( )

Gets or sets the number of pages to render when saving to a multipage TIFF or SVG file (for other formats only the first page of the range is saved). Default is MaxValue which means all pages of the document will be rendered.

This property has effect only when rendering document pages. This property is ignored when rendering shapes to images.

OverridesPageSet when set.

Examples

Converts a page of a Word document into a TIFF image and uses the CCITT compression.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Tiff);
options->set_TiffCompression(Aspose::Words::Saving::TiffCompression::Ccitt3);
options->set_PageIndex(0);
options->set_PageCount(1);
doc->Save(ArtifactsDir + u"Rendering.SaveToTiffCompression.tiff", options);

◆ get_PageIndex()

int32_t Aspose::Words::Saving::ImageSaveOptions::get_PageIndex ( )

Gets or sets the 0-based index of the first page to render. Default is 0.

This property has effect only when rendering document pages. This property is ignored when rendering shapes to images.

OverridesPageSet when set.

Examples

Shows how to save specific document page as image file.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// For formats that can only save one page at a time,
// the SaveOptions object can determine which page gets saved
auto saveOptions = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Gif);
saveOptions->set_PageIndex(1);
doc->Save(ArtifactsDir + u"ImageSaveOptions.SaveSinglePage.gif", saveOptions);

Converts a page of a Word document into a TIFF image and uses the CCITT compression.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Tiff);
options->set_TiffCompression(Aspose::Words::Saving::TiffCompression::Ccitt3);
options->set_PageIndex(0);
options->set_PageCount(1);
doc->Save(ArtifactsDir + u"Rendering.SaveToTiffCompression.tiff", options);

◆ get_PageSet()

System::SharedPtr<Aspose::Words::Saving::PageSet> Aspose::Words::Saving::ImageSaveOptions::get_PageSet ( )

Gets or sets the pages to render. Default is all the pages in the document.

This property has effect only when rendering document pages. This property is ignored when rendering shapes to images.

OverridesPageIndex andPageCount when set.

◆ get_PaperColor()

System::Drawing::Color Aspose::Words::Saving::ImageSaveOptions::get_PaperColor ( )

Gets or sets the background (paper) color for the generated images. The default value is White.

When rendering pages of a document that specifies its own background color, then the document background color will override the color specified by this property.

Examples

Renders a page of a Word document into an image with transparent or colored background.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto imgOptions = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Png);
imgOptions->set_PaperColor(System::Drawing::Color::get_Transparent());
doc->Save(ArtifactsDir + u"Rendering.SaveToImagePaperColor.Transparent.png", imgOptions);
imgOptions->set_PaperColor(System::Drawing::Color::get_LightCoral());
doc->Save(ArtifactsDir + u"Rendering.SaveToImagePaperColor.Coral.png", imgOptions);

◆ get_PixelFormat()

Aspose::Words::Saving::ImagePixelFormat Aspose::Words::Saving::ImageSaveOptions::get_PixelFormat ( ) const

Gets or sets the pixel format for the generated images.

This property has effect only when saving to raster image formats.

The default value is Format32BppArgb.

Pixel format of the output image may differ from the set value because of work of GDI+.

Examples

Show how to convert document images to black and white with 1 bit per pixel

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto imageSaveOptions = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Png);
imageSaveOptions->set_ImageColorMode(Aspose::Words::Saving::ImageColorMode::BlackAndWhite);
// ImageSaveOptions instances can be cloned
ASPOSE_ASSERT_NE(imageSaveOptions, imageSaveOptions->Clone());
doc->Save(ArtifactsDir + u"ImageSaveOptions.BlackAndWhite.png", imageSaveOptions);

◆ get_SaveFormat()

Aspose::Words::SaveFormat Aspose::Words::Saving::ImageSaveOptions::get_SaveFormat ( )
overridevirtual

Specifies the format in which the rendered document pages or shapes will be saved if this save options object is used. Can be a raster Tiff, Png, Bmp, Jpeg or vector Emf, Svg.

On different platforms, the supported formats may be different. The number of other options depends on the selected format.

Also, it is possible to save to SVG both via ImageSaveOptions and via SvgSaveOptions.

Examples

Shows how to edit image.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// When saving the document as an image, we can use an ImageSaveOptions object to edit various aspects of it
auto options = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Png);
options->set_ImageBrightness(0.3f);
options->set_ImageContrast(0.7f);
options->set_HorizontalResolution(72.f);
options->set_VerticalResolution(72.f);
options->set_Scale(96.f / 72.f);
doc->Save(ArtifactsDir + u"ImageSaveOptions.EditImage.png", options);

Implements Aspose::Words::Saving::SaveOptions.

◆ get_Scale()

float Aspose::Words::Saving::ImageSaveOptions::get_Scale ( ) const

Gets or sets the zoom factor for the generated images.

Examples

Shows how to edit image.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// When saving the document as an image, we can use an ImageSaveOptions object to edit various aspects of it
auto options = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Png);
options->set_ImageBrightness(0.3f);
options->set_ImageContrast(0.7f);
options->set_HorizontalResolution(72.f);
options->set_VerticalResolution(72.f);
options->set_Scale(96.f / 72.f);
doc->Save(ArtifactsDir + u"ImageSaveOptions.EditImage.png", options);

◆ get_ThresholdForFloydSteinbergDithering()

uint8_t Aspose::Words::Saving::ImageSaveOptions::get_ThresholdForFloydSteinbergDithering ( ) const

Gets or sets the threshold that determines the value of the binarization error in the Floyd-Steinberg method. when ImageBinarizationMethod is ImageBinarizationMethod.FloydSteinbergDithering.

The default value is 128.

Examples

Shows how to control the threshold for TIFF binarization in the Floyd-Steinberg method

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Tiff);
options->set_TiffCompression(Aspose::Words::Saving::TiffCompression::Ccitt3);
options->set_ThresholdForFloydSteinbergDithering(254);
doc->Save(ArtifactsDir + u"ImageSaveOptions.FloydSteinbergDithering.tiff", options);

◆ get_TiffBinarizationMethod()

Aspose::Words::Saving::ImageBinarizationMethod Aspose::Words::Saving::ImageSaveOptions::get_TiffBinarizationMethod ( ) const

Gets or sets method used while converting images to 1 bpp format when SaveFormat is SaveFormat.Tiff and TiffCompression is equal to TiffCompression.Ccitt3 or TiffCompression.Ccitt4.

The default value is ImageBinarizationMethod.Threshold.

Examples

Shows how to control the threshold for TIFF binarization in the Floyd-Steinberg method

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Tiff);
options->set_TiffCompression(Aspose::Words::Saving::TiffCompression::Ccitt3);
options->set_ThresholdForFloydSteinbergDithering(254);
doc->Save(ArtifactsDir + u"ImageSaveOptions.FloydSteinbergDithering.tiff", options);

◆ get_TiffCompression()

Aspose::Words::Saving::TiffCompression Aspose::Words::Saving::ImageSaveOptions::get_TiffCompression ( ) const

Gets or sets the type of compression to apply when saving generated images to the TIFF format.

Has effect only when saving to TIFF.

The default value is Lzw.

Examples

Converts a page of a Word document into a TIFF image and uses the CCITT compression.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Tiff);
options->set_TiffCompression(Aspose::Words::Saving::TiffCompression::Ccitt3);
options->set_PageIndex(0);
options->set_PageCount(1);
doc->Save(ArtifactsDir + u"Rendering.SaveToTiffCompression.tiff", options);

◆ get_UseGdiEmfRenderer()

bool Aspose::Words::Saving::ImageSaveOptions::get_UseGdiEmfRenderer ( ) const

Gets or sets a value determining whether to use GDI+ or Aspose.Words metafile renderer when saving to EMF.

If set to true GDI+ metafile renderer is used. I.e. content is written to GDI+ graphics object and saved to metafile.

If set to false Aspose.Words metafile renderer is used. I.e. content is written directly to the metafile format with Aspose.Words.

Has effect only when saving to EMF.

GDI+ saving works only on .NET.

The default value is true.

Examples

Shows how to save metafiles directly without using GDI+ to EMF.

auto doc = MakeObject<Document>(MyDir + u"Images.docx");
auto saveOptions = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Emf);
saveOptions->set_UseGdiEmfRenderer(true);
doc->Save(ArtifactsDir + u"ImageSaveOptions.Renderer.emf", saveOptions);

◆ get_VerticalResolution()

float Aspose::Words::Saving::ImageSaveOptions::get_VerticalResolution ( ) const

Gets or sets the vertical resolution for the generated images, in dots per inch.

This property has effect only when saving to raster image formats and affects the output size in pixels.

The default value is 96.

Examples

Shows how to edit image.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
// When saving the document as an image, we can use an ImageSaveOptions object to edit various aspects of it
auto options = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Png);
options->set_ImageBrightness(0.3f);
options->set_ImageContrast(0.7f);
options->set_HorizontalResolution(72.f);
options->set_VerticalResolution(72.f);
options->set_Scale(96.f / 72.f);
doc->Save(ArtifactsDir + u"ImageSaveOptions.EditImage.png", options);

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Saving::ImageSaveOptions::GetType ( ) const
overridevirtual

◆ Is()

virtual bool Aspose::Words::Saving::ImageSaveOptions::Is ( const System::TypeInfo target) const
overridevirtual

◆ set_HorizontalResolution()

void Aspose::Words::Saving::ImageSaveOptions::set_HorizontalResolution ( float  value)

◆ set_ImageBrightness()

void Aspose::Words::Saving::ImageSaveOptions::set_ImageBrightness ( float  value)

◆ set_ImageColorMode()

void Aspose::Words::Saving::ImageSaveOptions::set_ImageColorMode ( Aspose::Words::Saving::ImageColorMode  value)

◆ set_ImageContrast()

void Aspose::Words::Saving::ImageSaveOptions::set_ImageContrast ( float  value)

◆ set_JpegQuality()

void Aspose::Words::Saving::ImageSaveOptions::set_JpegQuality ( int32_t  value)

◆ set_PageCount()

void Aspose::Words::Saving::ImageSaveOptions::set_PageCount ( int32_t  value)

◆ set_PageIndex()

void Aspose::Words::Saving::ImageSaveOptions::set_PageIndex ( int32_t  value)

◆ set_PageSet()

void Aspose::Words::Saving::ImageSaveOptions::set_PageSet ( System::SharedPtr< Aspose::Words::Saving::PageSet value)

◆ set_PaperColor()

void Aspose::Words::Saving::ImageSaveOptions::set_PaperColor ( System::Drawing::Color  value)

◆ set_PixelFormat()

void Aspose::Words::Saving::ImageSaveOptions::set_PixelFormat ( Aspose::Words::Saving::ImagePixelFormat  value)

◆ set_Resolution()

void Aspose::Words::Saving::ImageSaveOptions::set_Resolution ( float  value)

Sets both horizontal and vertical resolution for the generated images, in dots per inch.

This property has effect only when saving to raster image formats.

Examples

Renders a page of a Word document into a PNG image at a specific resolution.

auto doc = MakeObject<Document>(MyDir + u"Rendering.docx");
auto options = MakeObject<ImageSaveOptions>(Aspose::Words::SaveFormat::Png);
options->set_Resolution(300);
options->set_PageCount(1);
doc->Save(ArtifactsDir + u"Rendering.SaveToImageResolution.png", options);

◆ set_SaveFormat()

void Aspose::Words::Saving::ImageSaveOptions::set_SaveFormat ( Aspose::Words::SaveFormat  value)
overridevirtual

◆ set_Scale()

void Aspose::Words::Saving::ImageSaveOptions::set_Scale ( float  value)

◆ set_ThresholdForFloydSteinbergDithering()

void Aspose::Words::Saving::ImageSaveOptions::set_ThresholdForFloydSteinbergDithering ( uint8_t  value)

◆ set_TiffBinarizationMethod()

void Aspose::Words::Saving::ImageSaveOptions::set_TiffBinarizationMethod ( Aspose::Words::Saving::ImageBinarizationMethod  value)

◆ set_TiffCompression()

void Aspose::Words::Saving::ImageSaveOptions::set_TiffCompression ( Aspose::Words::Saving::TiffCompression  value)

◆ set_UseGdiEmfRenderer()

void Aspose::Words::Saving::ImageSaveOptions::set_UseGdiEmfRenderer ( bool  value)

◆ set_VerticalResolution()

void Aspose::Words::Saving::ImageSaveOptions::set_VerticalResolution ( float  value)

◆ Type()

static const System::TypeInfo& Aspose::Words::Saving::ImageSaveOptions::Type ( )
static
@ Grayscale
The pages of the document will be rendered as grayscale images.
@ Format1bppIndexed
1 bit per pixel, Indexed.
static ASPOSECPP_SHARED_API SharedPtr< Image > FromFile(const String &filename, bool use_embedded_color_management=false)
@ FloydSteinbergDithering
Specifies dithering using Floyd-Steinberg error diffusion method.
static ASPOSECPP_SHARED_API Color get_Transparent()
@ Tiff
Renders a page or pages of the document and saves them into a single or multipage TIFF file.
@ Gif
Renders a page of the document and saves it as a GIF file.
@ Emf
Renders a page of the document and saves it as a vector EMF (Enhanced Meta File) file.
@ Vector
Aspose.Words renders a metafile as vector graphics.
@ Begin
static ASPOSECPP_SHARED_API Color get_LightCoral()
@ Jpeg
Renders a page of the document and saves it as a JPEG file.
@ Ccitt3
Specifies the CCITT3 compression scheme.
@ Png
Renders a page of the document and saves it as a PNG file.
@ BlackAndWhite
The pages of the document will be rendered as black and white images.