API Reference
WordImage
Represents an image contained in a WordDocument and provides functionality to insert and manipulate pictures.
Inheritance
- WordElement
- WordImage
Usage
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by
- Property ImageBuilder.Image
- Method WordDocument.AddImageFromUrlAsync
- Method WordDocument.AddImageFromUrlAsync
- Method WordDocument.AddImageVml
- Property WordDocument.Images
- Property WordFooter.Images
- Property WordFormattedRun.Image
- Method WordHeader.AddImageVml
- Property WordHeader.Images
- Property WordHeaderFooter.Images
- Method WordImage.Clone
- Method WordParagraph.InsertImage
- Method WordParagraph.InsertImage
- Method WordParagraph.InsertImage
- Method WordParagraph.InsertImageFromBase64
- Property WordParagraph.Image
- Property WordPictureControl.Image
- Method WordSection.AddImageVml
- Property WordSection.Images
Constructors
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
- paragraph OfficeIMO.Word.WordParagraph
- filePath System.String
- width System.Nullable{System.Double}
- height System.Nullable{System.Double}
- wrapImage OfficeIMO.Word.WordImageTextWrapping = InLineWithText
- description System.String = ""
- shape System.Nullable{OfficeIMO.Drawing.OfficePresetShapeType} = null
- compressionQuality System.Nullable{OfficeIMO.Word.WordImageCompressionQuality} = null
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
- paragraph OfficeIMO.Word.WordParagraph
- imageStream System.IO.Stream
- fileName System.String
- width System.Nullable{System.Double}
- height System.Nullable{System.Double}
- wrapImage OfficeIMO.Word.WordImageTextWrapping = InLineWithText
- description System.String = ""
- shape System.Nullable{OfficeIMO.Drawing.OfficePresetShapeType} = null
- compressionQuality System.Nullable{OfficeIMO.Word.WordImageCompressionQuality} = null
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
- paragraph OfficeIMO.Word.WordParagraph
- base64String System.String
- fileName System.String
- width System.Nullable{System.Double}
- height System.Nullable{System.Double}
- wrapImage OfficeIMO.Word.WordImageTextWrapping = InLineWithText
- description System.String = ""
- shape System.Nullable{OfficeIMO.Drawing.OfficePresetShapeType} = null
- compressionQuality System.Nullable{OfficeIMO.Word.WordImageCompressionQuality} = null
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
- paragraph OfficeIMO.Word.WordParagraph
- externalUri System.Uri
- width System.Double
- height System.Double
- wrapImage OfficeIMO.Word.WordImageTextWrapping = InLineWithText
- description System.String = ""
- shape System.Nullable{OfficeIMO.Drawing.OfficePresetShapeType} = null
- compressionQuality System.Nullable{OfficeIMO.Word.WordImageCompressionQuality} = null
Methods
public WordImage Clone(WordParagraph paragraph) #WordImageCreates 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
- The paragraph to append the cloned image to.
Returns
The newly created WordImage instance.
public Stream OpenRead() #StreamRetrieves the image data as a stream without loading the entire image into memory.
Returns
A Stream for reading the image bytes.
public async Task SaveAsync(String path, CancellationToken cancellationToken = null) #TaskSaves the image to a file asynchronously.
Parameters
- path System.String
- cancellationToken System.Threading.CancellationToken = null
public async Task SaveAsync(Stream stream, CancellationToken cancellationToken = null) #TaskSaves the image to a caller-owned stream asynchronously.
Parameters
- stream System.IO.Stream
- cancellationToken System.Threading.CancellationToken = null
public Byte[] ToBytes() #Byte[]Retrieves the image data as a byte array.
Returns
Bytes representing the image.
public MemoryStream ToStream() #MemoryStreamReturns the image bytes in a new stream positioned at the beginning.
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
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 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.