API Reference

Class

WordImage

Namespace OfficeIMO.Word
Assembly OfficeIMO.Word

Represents an image contained in a WordDocument and provides functionality to insert and manipulate pictures.

Inheritance

Usage

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Constructors

WordImage 4 overloads
public WordImage(WordDocument document, WordParagraph paragraph, String filePath, Nullable<Double> width, Nullable<Double> height, WordImageTextWrapping wrapImage = InLineWithText, String description = "", Nullable<OfficePresetShapeType> shape = null, Nullable<WordImageCompressionQuality> compressionQuality = null) #

Initializes a new image from a file path.

Parameters

document OfficeIMO.Word.WordDocument requiredposition: 0
paragraph OfficeIMO.Word.WordParagraph requiredposition: 1
filePath System.String requiredposition: 2
width System.Nullable{System.Double} requiredposition: 3
height System.Nullable{System.Double} requiredposition: 4
wrapImage OfficeIMO.Word.WordImageTextWrapping = InLineWithText optionalposition: 5
description System.String = "" optionalposition: 6
shape System.Nullable{OfficeIMO.Drawing.OfficePresetShapeType} = null optionalposition: 7
compressionQuality System.Nullable{OfficeIMO.Word.WordImageCompressionQuality} = null optionalposition: 8
public WordImage(WordDocument document, WordParagraph paragraph, Stream imageStream, String fileName, Nullable<Double> width, Nullable<Double> height, WordImageTextWrapping wrapImage = InLineWithText, String description = "", Nullable<OfficePresetShapeType> shape = null, Nullable<WordImageCompressionQuality> compressionQuality = null) #

Initializes a new image from a stream.

Parameters

document OfficeIMO.Word.WordDocument requiredposition: 0
paragraph OfficeIMO.Word.WordParagraph requiredposition: 1
imageStream System.IO.Stream requiredposition: 2
fileName System.String requiredposition: 3
width System.Nullable{System.Double} requiredposition: 4
height System.Nullable{System.Double} requiredposition: 5
wrapImage OfficeIMO.Word.WordImageTextWrapping = InLineWithText optionalposition: 6
description System.String = "" optionalposition: 7
shape System.Nullable{OfficeIMO.Drawing.OfficePresetShapeType} = null optionalposition: 8
compressionQuality System.Nullable{OfficeIMO.Word.WordImageCompressionQuality} = null optionalposition: 9
public WordImage(WordDocument document, WordParagraph paragraph, String base64String, String fileName, Nullable<Double> width, Nullable<Double> height, WordImageTextWrapping wrapImage = InLineWithText, String description = "", Nullable<OfficePresetShapeType> shape = null, Nullable<WordImageCompressionQuality> compressionQuality = null) #

Initializes a new image from a base64 string.

Parameters

document OfficeIMO.Word.WordDocument requiredposition: 0
paragraph OfficeIMO.Word.WordParagraph requiredposition: 1
base64String System.String requiredposition: 2
fileName System.String requiredposition: 3
width System.Nullable{System.Double} requiredposition: 4
height System.Nullable{System.Double} requiredposition: 5
wrapImage OfficeIMO.Word.WordImageTextWrapping = InLineWithText optionalposition: 6
description System.String = "" optionalposition: 7
shape System.Nullable{OfficeIMO.Drawing.OfficePresetShapeType} = null optionalposition: 8
compressionQuality System.Nullable{OfficeIMO.Word.WordImageCompressionQuality} = null optionalposition: 9
public WordImage(WordDocument document, WordParagraph paragraph, Uri externalUri, Double width, Double height, WordImageTextWrapping wrapImage = InLineWithText, String description = "", Nullable<OfficePresetShapeType> shape = null, Nullable<WordImageCompressionQuality> compressionQuality = null) #

Initializes an image linked to an external URI.

Parameters

document OfficeIMO.Word.WordDocument requiredposition: 0
paragraph OfficeIMO.Word.WordParagraph requiredposition: 1
externalUri System.Uri requiredposition: 2
width System.Double requiredposition: 3
height System.Double requiredposition: 4
wrapImage OfficeIMO.Word.WordImageTextWrapping = InLineWithText optionalposition: 5
description System.String = "" optionalposition: 6
shape System.Nullable{OfficeIMO.Drawing.OfficePresetShapeType} = null optionalposition: 7
compressionQuality System.Nullable{OfficeIMO.Word.WordImageCompressionQuality} = null optionalposition: 8

Methods

public WordImage Clone(WordParagraph paragraph) #
Returns: WordImage

Creates a copy of this image and appends it to the specified paragraph. The cloned image shares the same underlying image part.

Parameters

paragraph OfficeIMO.Word.WordParagraph requiredposition: 0
The paragraph to append the cloned image to.

Returns

The newly created WordImage instance.

public Stream OpenRead() #
Returns: Stream

Retrieves the image data as a stream without loading the entire image into memory.

Returns

A Stream for reading the image bytes.

public Void Remove() #
Returns: Void

Remove image from a Word Document

Save 2 overloads
public Void Save(String fileToSave) #
Returns: Void

Extract image from Word Document and save it to file

Parameters

fileToSave System.String requiredposition: 0
public Void Save(Stream stream) #
Returns: Void

Saves the image to a caller-owned stream.

Parameters

stream System.IO.Stream requiredposition: 0
SaveAsync 2 overloads
public async Task SaveAsync(String path, CancellationToken cancellationToken = null) #
Returns: Task

Saves the image to a file asynchronously.

Parameters

path System.String requiredposition: 0
cancellationToken System.Threading.CancellationToken = null optionalposition: 1
public async Task SaveAsync(Stream stream, CancellationToken cancellationToken = null) #
Returns: Task

Saves the image to a caller-owned stream asynchronously.

Parameters

stream System.IO.Stream requiredposition: 0
cancellationToken System.Threading.CancellationToken = null optionalposition: 1
public Byte[] ToBytes() #
Returns: Byte[]

Retrieves the image data as a byte array.

Returns

Bytes representing the image.

public MemoryStream ToStream() #
Returns: MemoryStream

Returns the image bytes in a new stream positioned at the beginning.

Properties

public Nullable<Int32> CropTop { get; set; } #

Gets or sets the number of EMUs to crop from the top of the image.

public Nullable<Int32> CropBottom { get; set; } #

Gets or sets the number of EMUs to crop from the bottom of the image.

public Nullable<Int32> CropLeft { get; set; } #

Gets or sets the number of EMUs to crop from the left side of the image.

public Nullable<Int32> CropRight { get; set; } #

Gets or sets the number of EMUs to crop from the right side of the image.

public Nullable<Double> CropTopCentimeters { get; set; } #

Gets or sets the number of centimeters to crop from the top of the image.

public Nullable<Double> CropBottomCentimeters { get; set; } #

Gets or sets the number of centimeters to crop from the bottom of the image.

public Nullable<Double> CropLeftCentimeters { get; set; } #

Gets or sets the number of centimeters to crop from the left side of the image.

public Nullable<Double> CropRightCentimeters { get; set; } #

Gets or sets the number of centimeters to crop from the right side of the image.

public Nullable<Int32> Transparency { get; set; } #

Gets or sets the image transparency percentage (0-100).

public Nullable<WordImageTextWrapping> WrapText { get; set; } #

Gets or sets the image's wrap text.

public WordImageFillMode FillMode { get; set; } #

Gets or sets how the image should fill its bounding box. Default is Stretch.

public Nullable<Boolean> UseLocalDpi { get; set; } #

Specifies whether to use the image's local DPI setting when rendering.

public ValueTuple<Int32, Int32> Location { get; } #

Gets the anchor location of the image.

public Nullable<Boolean> PreferRelativeResize { get; set; } #

Indicates whether resizing should be relative to the original size.

public Nullable<Boolean> NoChangeAspect { get; set; } #

Gets or sets whether the aspect ratio is locked.

public Nullable<Boolean> NoCrop { get; set; } #

Gets or sets whether the image cannot be cropped.

public Nullable<Boolean> NoMove { get; set; } #

Gets or sets whether the image is locked from moving.

public Nullable<Boolean> NoResize { get; set; } #

Gets or sets whether the image cannot be resized.

public Nullable<Boolean> NoRot { get; set; } #

Gets or sets whether the image cannot be rotated.

public Nullable<Boolean> NoSelect { get; set; } #

Gets or sets whether the image cannot be selected.

public Nullable<WordImageCompressionQuality> CompressionQuality { get; set; } #

Gets or sets the compression quality for embedded images.

public String RelationshipId { get; } #

Gets the relationship id of the embedded image.

public String ExternalRelationshipId { get; } #

Gets the relationship id of an externally linked image, if any.

public Boolean IsExternal { get; } #

Indicates whether the image is stored outside the package.

public String ContentType { get; } #

Gets the content type of the embedded image part, or an empty string for external images.

public Uri ExternalUri { get; } #

Gets the URI of the externally linked image.

public String FilePath { get; set; } #

Gets or sets the file path or name for the image.

public String FileName { get; set; } #

Get or sets the image's file name

public String Description { get; set; } #

Gets or sets the image's description.

public String Title { get; set; } #

Gets or sets the image's title.

public Nullable<Boolean> Hidden { get; set; } #

Specifies whether the picture is hidden.

public Nullable<Double> Width { get; set; } #

Gets or sets Width of an image

public Nullable<Double> Height { get; set; } #

Gets or sets Height of an image

public Nullable<Double> EmuWidth { get; } #

Gets the image width in EMUs.

public Nullable<Double> EmuHeight { get; } #

Gets the image height in EMUs.

public Nullable<OfficePresetShapeType> Shape { get; set; } #

Gets or sets the shape type used to display the image.

public Nullable<WordImageBlackWhiteMode> BlackWhiteMode { get; set; } #

Microsoft Office does not seem to fully support this attribute, and ignores this setting. More information: http://officeopenxml.com/drwSp-SpPr.php

public Nullable<WordImageBlackWhiteMode> BlackWiteMode { get; set; } #
Obsolete("Use BlackWhiteMode.")

Gets or sets the image black-and-white mode using the legacy misspelled member name.

public Nullable<Boolean> VerticalFlip { get; set; } #

Gets or sets whether the image is vertically flipped.

public Nullable<Boolean> HorizontalFlip { get; set; } #

Gets or sets whether the image is horizontally flipped.

public Nullable<Int32> Rotation { get; set; } #

Gets or sets the image rotation in degrees.

public Nullable<Int32> FixedOpacity { get; set; } #

Sets a fixed opacity value for the image.

public String AlphaInversionColorHex { get; set; } #

Gets or sets the alpha inversion color in hex.

public Nullable<OfficeColor> AlphaInversionColor { get; set; } #

Gets or sets the alpha inversion color.

public Nullable<Int32> BlackWhiteThreshold { get; set; } #

Gets or sets the threshold for black and white effect.

public Nullable<Int32> BlurRadius { get; set; } #

Gets or sets the blur radius in EMUs.

public Nullable<Boolean> BlurGrow { get; set; } #

Gets or sets whether the blur grows the image's bounds.

public String ColorChangeFromHex { get; set; } #

Gets or sets the source color to change from in hex.

public String ColorChangeToHex { get; set; } #

Gets or sets the target color to change to in hex.

public Nullable<OfficeColor> ColorChangeFrom { get; set; } #

Gets or sets the source color to change from.

public Nullable<OfficeColor> ColorChangeTo { get; set; } #

Gets or sets the target color to change to.

public String ColorReplacementHex { get; set; } #

Gets or sets a color replacement hex value.

public Nullable<OfficeColor> ColorReplacement { get; set; } #

Gets or sets a color replacement.

public String DuotoneColor1Hex { get; set; } #

Gets or sets the first duotone color in hex.

public String DuotoneColor2Hex { get; set; } #

Gets or sets the second duotone color in hex.

public Nullable<OfficeColor> DuotoneColor1 { get; set; } #

Gets or sets the first duotone color.

public Nullable<OfficeColor> DuotoneColor2 { get; set; } #

Gets or sets the second duotone color.

public Nullable<Boolean> GrayScale { get; set; } #

Gets or sets whether the image is displayed in grayscale.

public Nullable<Int32> LuminanceBrightness { get; set; } #

Gets or sets the brightness adjustment.

public Nullable<Int32> LuminanceContrast { get; set; } #

Gets or sets the contrast adjustment.

public Nullable<Int32> TintAmount { get; set; } #

Gets or sets the tint amount.

public Nullable<Int32> TintHue { get; set; } #

Gets or sets the tint hue.

public WordHorizontalRelativePosition HorizontalPositionRelativeFrom { get; set; } #

Gets or sets the horizontal reference used by a floating image.

public Nullable<Int64> HorizontalPositionOffset { get; set; } #

Gets or sets the horizontal image offset in English Metric Units.

public WordVerticalRelativePosition VerticalPositionRelativeFrom { get; set; } #

Gets or sets the vertical reference used by a floating image.

public Nullable<Int64> VerticalPositionOffset { get; set; } #

Gets or sets the vertical image offset in English Metric Units.