OfficeIMO

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

Constructors

WordImage 6 overloads
public WordImage(WordDocument document, WordParagraph paragraph, Uri externalUri, Double width, Double height, WrapTextImage wrapImage = InLineWithText, String description = "", Nullable<ShapeTypeValues> shape = null, Nullable<BlipCompressionValues> 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.WrapTextImage = InLineWithText optionalposition: 5
description System.String = "" optionalposition: 6
shape System.Nullable{DocumentFormat.OpenXml.Drawing.ShapeTypeValues} = null optionalposition: 7
compressionQuality System.Nullable{DocumentFormat.OpenXml.Drawing.BlipCompressionValues} = null optionalposition: 8
public WordImage(WordDocument document, WordParagraph paragraph, String base64String, String fileName, Nullable<Double> width, Nullable<Double> height, WrapTextImage wrapImage = InLineWithText, String description = "", Nullable<ShapeTypeValues> shape = null, Nullable<BlipCompressionValues> 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.WrapTextImage = InLineWithText optionalposition: 6
description System.String = "" optionalposition: 7
shape System.Nullable{DocumentFormat.OpenXml.Drawing.ShapeTypeValues} = null optionalposition: 8
compressionQuality System.Nullable{DocumentFormat.OpenXml.Drawing.BlipCompressionValues} = null optionalposition: 9
WordImage(OfficeIMO.Word.WordDocument document, OfficeIMO.Word.WordParagraph paragraph, System.String base64String, System.String fileName, System.Nullable{System.Double} width, System.Nullable{System.Double} height, OfficeIMO.Word.WrapTextImage wrapImage, System.String description, System.Nullable{DocumentFormat.OpenXml.Drawing.ShapeTypeValues} shape, System.Nullable{DocumentFormat.OpenXml.Drawing.BlipCompressionValues} compressionQuality) #

Initializes a new image from a base64 string.

Parameters

document OfficeIMO.Word.WordDocument required
paragraph OfficeIMO.Word.WordParagraph required
base64String System.String required
fileName System.String required
width System.Nullable{System.Double} required
height System.Nullable{System.Double} required
wrapImage OfficeIMO.Word.WrapTextImage required
description System.String required
shape System.Nullable{DocumentFormat.OpenXml.Drawing.ShapeTypeValues} required
compressionQuality System.Nullable{DocumentFormat.OpenXml.Drawing.BlipCompressionValues} required
WordImage(OfficeIMO.Word.WordDocument document, OfficeIMO.Word.WordParagraph paragraph, System.Uri externalUri, System.Double width, System.Double height, OfficeIMO.Word.WrapTextImage wrapImage, System.String description, System.Nullable{DocumentFormat.OpenXml.Drawing.ShapeTypeValues} shape, System.Nullable{DocumentFormat.OpenXml.Drawing.BlipCompressionValues} compressionQuality) #

Initializes an image linked to an external URI.

Parameters

document OfficeIMO.Word.WordDocument required
paragraph OfficeIMO.Word.WordParagraph required
externalUri System.Uri required
width System.Double required
height System.Double required
wrapImage OfficeIMO.Word.WrapTextImage required
description System.String required
shape System.Nullable{DocumentFormat.OpenXml.Drawing.ShapeTypeValues} required
compressionQuality System.Nullable{DocumentFormat.OpenXml.Drawing.BlipCompressionValues} required
public WordImage(WordDocument document, Drawing drawing) #

Wraps an existing drawing as a WordImage.

Parameters

document OfficeIMO.Word.WordDocument requiredposition: 0
drawing DocumentFormat.OpenXml.Wordprocessing.Drawing requiredposition: 1
WordImage(OfficeIMO.Word.WordDocument arg1, DocumentFormat.OpenXml.Wordprocessing.Paragraph arg2, DocumentFormat.OpenXml.Wordprocessing.Run arg3, DocumentFormat.OpenXml.Vml.Shape arg4) #

Wraps an existing VML image as a WordImage.

Parameters

arg1 OfficeIMO.Word.WordDocument required
arg2 DocumentFormat.OpenXml.Wordprocessing.Paragraph required
arg3 DocumentFormat.OpenXml.Wordprocessing.Run required
arg4 DocumentFormat.OpenXml.Vml.Shape required

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 Byte[] GetBytes() #
Returns: Byte[]

Retrieves the image data as a byte array.

Returns

Bytes representing the image.

public Stream GetStream() #
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

public Void SaveToFile(String fileToSave) #
Returns: Void

Extract image from Word Document and save it to file

Parameters

fileToSave System.String requiredposition: 0
SetPictureLock(System.Action{DocumentFormat.OpenXml.Drawing.PictureLocks} arg1) #

Sets picture lock property using provided action.

Parameters

arg1 System.Action{DocumentFormat.OpenXml.Drawing.PictureLocks} required

Properties

public HorizontalPosition horizontalPosition { get; set; } #

Get or set the Image's horizontal position.

public VerticalPosition verticalPosition { get; set; } #

Get or set the Image's vertical position.

public Nullable<BlipCompressionValues> 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 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<ShapeTypeValues> Shape { get; set; } #

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

public Nullable<BlackWhiteModeValues> BlackWiteMode { 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<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> 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<WrapTextImage> WrapText { get; set; } #

Gets or sets the image's wrap text.

public ImageFillMode 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<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<Color> 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<Color> ColorChangeFrom { get; set; } #

Gets or sets the source color to change from.

public Nullable<Color> 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<Color> 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<Color> DuotoneColor1 { get; set; } #

Gets or sets the first duotone color.

public Nullable<Color> 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.