ImageSaveOptions class

ImageSaveOptions class

Allows to specify additional options when rendering document pages or shapes to images. To learn more, visit the Specify Save Options documentation article.

Inheritance: ImageSaveOptionsFixedPageSaveOptionsSaveOptions

Constructors

NameDescription
ImageSaveOptions(saveFormat)Initializes a new instance of this class that can be used to save rendered images in the SaveFormat.Tiff, SaveFormat.Png, SaveFormat.Bmp, SaveFormat.Jpeg, SaveFormat.Emf, SaveFormat.Eps, SaveFormat.WebP or SaveFormat.Svg format.

Properties

NameDescription
allowEmbeddingPostScriptFontsGets or sets a boolean value indicating whether to allow embedding fonts with PostScript outlines when embedding TrueType fonts in a document upon it is saved. The default value is false.
(Inherited from SaveOptions)
colorModeGets or sets a value determining how colors are rendered.
(Inherited from FixedPageSaveOptions)
defaultTemplateGets or sets path to default template (including filename). Default value for this property is empty string .
(Inherited from SaveOptions)
dml3DEffectsRenderingModeGets or sets a value determining how 3D effects are rendered.
(Inherited from SaveOptions)
dmlEffectsRenderingModeGets or sets a value determining how DrawingML effects are rendered.
(Inherited from SaveOptions)
dmlRenderingModeGets or sets a value determining how DrawingML shapes are rendered.
(Inherited from SaveOptions)
exportGeneratorNameWhen true, causes the name and version of Aspose.Words to be embedded into produced files. Default value is true.
(Inherited from SaveOptions)
horizontalResolutionGets or sets the horizontal resolution for the generated images, in dots per inch.
imageBrightnessGets or sets the brightness for the generated images.
imageColorModeGets or sets the color mode for the generated images.
imageContrastGets or sets the contrast for the generated images.
imageSize2Gets or sets the size of a generated image in pixels.
imlRenderingModeGets or sets a value determining how ink (InkML) objects are rendered.
(Inherited from SaveOptions)
jpegQualityGets or sets a value determining the quality of the generated JPEG images.
memoryOptimizationGets or sets value determining if memory optimization should be performed before saving the document. Default value for this property is false.
(Inherited from SaveOptions)
metafileRenderingOptionsAllows to specify how metafiles are treated in the rendered output.
numeralFormatGets or sets NumeralFormat used for rendering of numerals. European numerals are used by default.
(Inherited from FixedPageSaveOptions)
optimizeOutputFlag 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.
(Inherited from FixedPageSaveOptions)
pageLayoutGets or sets the layout used when rendering multiple pages into a single output.
pageSavingCallbackAllows to control how separate pages are saved when a document is exported to fixed page format.
(Inherited from FixedPageSaveOptions)
pageSetGets or sets the pages to render. Default is all the pages in the document.
paperColorGets or sets the background (paper) color for the generated images. The default value is white.
pixelFormatGets or sets the pixel format for the generated images.
prettyFormatWhen true, pretty formats output where applicable. Default value is false.
(Inherited from SaveOptions)
saveFormatSpecifies the format in which the rendered document pages or shapes will be saved if this save options object is used. Can be a raster SaveFormat.Tiff, SaveFormat.Png, SaveFormat.Bmp, SaveFormat.Jpeg or vector SaveFormat.Emf, SaveFormat.Eps, SaveFormat.WebP, SaveFormat.Svg.
scaleGets or sets the zoom factor for the generated images.
tempFolderSpecifies 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.
(Inherited from SaveOptions)
thresholdForFloydSteinbergDitheringGets or sets the threshold that determines the value of the binarization error in the Floyd-Steinberg method. when ImageBinarizationMethod is ImageBinarizationMethod.FloydSteinbergDithering.
tiffBinarizationMethodGets or sets method used while converting images to 1 bpp format when ImageSaveOptions.saveFormat is SaveFormat.Tiff and ImageSaveOptions.tiffCompression is equal to TiffCompression.Ccitt3 or TiffCompression.Ccitt4.
tiffCompressionGets or sets the type of compression to apply when saving generated images to the TIFF format.
updateAmbiguousTextFontDetermines whether the font attributes will be changed according to the character code being used.
(Inherited from SaveOptions)
updateCreatedTimePropertyGets or sets a value determining whether the BuiltInDocumentProperties.createdTime property is updated before saving. Default value is false;
(Inherited from SaveOptions)
updateFieldsGets 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.
(Inherited from SaveOptions)
updateLastPrintedPropertyGets or sets a value determining whether the BuiltInDocumentProperties.lastPrinted property is updated before saving.
(Inherited from SaveOptions)
updateLastSavedTimePropertyGets or sets a value determining whether the BuiltInDocumentProperties.lastSavedTime property is updated before saving.
(Inherited from SaveOptions)
useAntiAliasingGets or sets a value determining whether or not to use anti-aliasing for rendering.
(Inherited from SaveOptions)
useGdiEmfRendererGets or sets a value determining whether to use GDI+ or Aspose.Words metafile renderer when saving to EMF.
useHighQualityRenderingGets or sets a value determining whether or not to use high quality (i.e. slow) rendering algorithms.
(Inherited from SaveOptions)
verticalResolutionGets or sets the vertical resolution for the generated images, in dots per inch.

Methods

NameDescription
clone()Creates a deep clone of this object.
createSaveOptions(saveFormat)Creates a save options object of a class suitable for the specified save format.
(Inherited from SaveOptions)
createSaveOptions(fileName)Creates a save options object of a class suitable for the file extension specified in the given file name.
(Inherited from SaveOptions)

Examples

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

let doc = new aw.Document();
let builder = new aw.DocumentBuilder(doc);

builder.font.name = "Times New Roman";
builder.font.size = 24;
builder.writeln("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");

builder.insertImage(base.imageDir + "Logo.jpg");

// Create an "ImageSaveOptions" object which we can pass to the document's "Save" method
// to modify the way in which that method renders the document into an image.
let imgOptions = new aw.Saving.ImageSaveOptions(aw.SaveFormat.Png);
// Set the "PaperColor" property to a transparent color to apply a transparent
// background to the document while rendering it to an image.
imgOptions.paperColor = "rgba(0,0,0,0)";

doc.save(base.artifactsDir + "ImageSaveOptions.paperColor.transparent.png", imgOptions);

// Set the "PaperColor" property to an opaque color to apply that color
// as the background of the document as we render it to an image.
imgOptions.paperColor = "#F08080";

doc.save(base.artifactsDir + "ImageSaveOptions.paperColor.LightCoral.png", imgOptions);

Shows how to configure compression while saving a document as a JPEG.

let doc = new aw.Document();
let builder = new aw.DocumentBuilder(doc);
builder.insertImage(base.imageDir + "Logo.jpg");

// Create an "ImageSaveOptions" object which we can pass to the document's "Save" method
// to modify the way in which that method renders the document into an image.
let imageOptions = new aw.Saving.ImageSaveOptions(aw.SaveFormat.Jpeg);
// Set the "JpegQuality" property to "10" to use stronger compression when rendering the document.
// This will reduce the file size of the document, but the image will display more prominent compression artifacts.
imageOptions.jpegQuality = 10;
doc.save(base.artifactsDir + "ImageSaveOptions.jpegQuality.HighCompression.jpg", imageOptions);

// Set the "JpegQuality" property to "100" to use weaker compression when rending the document.
// This will improve the quality of the image at the cost of an increased file size.
imageOptions.jpegQuality = 100;
doc.save(base.artifactsDir + "ImageSaveOptions.jpegQuality.HighQuality.jpg", imageOptions);

Shows how to specify a resolution while rendering a document to PNG.

let doc = new aw.Document();
let builder = new aw.DocumentBuilder(doc);

builder.font.name = "Times New Roman";
builder.font.size = 24;
builder.writeln("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");

builder.insertImage(base.imageDir + "Logo.jpg");

// Create an "ImageSaveOptions" object which we can pass to the document's "Save" method
// to modify the way in which that method renders the document into an image.
let options = new aw.Saving.ImageSaveOptions(aw.SaveFormat.Png);

// Set the "Resolution" property to "72" to render the document in 72dpi.
options.resolution = 72;
doc.save(base.artifactsDir + "ImageSaveOptions.resolution.72dpi.png", options);

// Set the "Resolution" property to "300" to render the document in 300dpi.
options.resolution = 300;
doc.save(base.artifactsDir + "ImageSaveOptions.resolution.300dpi.png", options);

See Also