Class WPicture
Represents the picture in the Word document.
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Base.dll
Syntax
public class WPicture : ParagraphItem, IXDLSSerializable, IOfficeRun, ILeafWidget, IWidget, IWPicture, IParagraphItem, IEntity
Examples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("This paragraph has picture. ");
//Append new picture to the paragraph
IWPicture picture = paragraph.AppendPicture(Image.FromFile("Image.png"));
//Set width and height for the paragraph
picture.Width = 150;
picture.Height = 100;
//Set text wrapping style � When the wrapping style is inline the images will not be absolutely positioned. It will be added next to the textrange.
picture.TextWrappingStyle = TextWrappingStyle.Square;
picture.TextWrappingType = TextWrappingType.Largest;
//Set horizontal and vertical origin
picture.HorizontalOrigin = HorizontalOrigin.Page;
picture.VerticalOrigin = VerticalOrigin.Paragraph;
//Set horizontal and vertical position for the picture
picture.HorizontalPosition = 200;
picture.VerticalPosition = 150;
//Set horizontal and vertical alignments
picture.HorizontalAlignment = ShapeHorizontalAlignment.Center;
picture.VerticalAlignment = ShapeVerticalAlignment.Bottom;
//Set name, title, alternate text.
picture.Title = "PictureTitle";
picture.Name = "PictureName";
picture.IsBelowText = true;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("This paragraph has picture. ")
'Append new picture to the paragraph
Dim picture As IWPicture = paragraph.AppendPicture(Image.FromFile("Image.png"))
'Set width and height for the paragraph
picture.Width = 150
picture.Height = 100
'Set text wrapping style � When the wrapping style is inline the images will not be absolutely positioned. It will be added next to the textrange.
picture.TextWrappingStyle = TextWrappingStyle.Square
picture.TextWrappingType = TextWrappingType.Largest
'Set horizontal and vertical origin
picture.HorizontalOrigin = HorizontalOrigin.Page
picture.VerticalOrigin = VerticalOrigin.Paragraph
'Set horizontal and vertical position for the picture
picture.HorizontalPosition = 200
picture.VerticalPosition = 150
'Set horizontal and vertical alignments
picture.HorizontalAlignment = ShapeHorizontalAlignment.Center
picture.VerticalAlignment = ShapeVerticalAlignment.Bottom
'Set name, title, alternate text.
picture.Title = "PictureTitle"
picture.Name = "PictureName"
picture.IsBelowText = True
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
Constructors
WPicture(IWordDocument)
Initializes a new instance of the WPicture class with the specified IWordDocument instance.
Declaration
public WPicture(IWordDocument doc)
Parameters
Type | Name | Description |
---|---|---|
IWordDocument | doc | The IWordDocument instance. |
Properties
AlternativeText
Gets or sets the alternate text for the picture.
Declaration
public string AlternativeText { get; set; }
Property Value
Type | Description |
---|---|
System.String | The string that represents the alternate text. |
CharacterFormat
Gets the character format(font properties) of the picture. Read-only.
Declaration
public WCharacterFormat CharacterFormat { get; }
Property Value
Type | Description |
---|---|
WCharacterFormat |
EntityType
Gets the type of the entity. Read-only.
Declaration
public override EntityType EntityType { get; }
Property Value
Type | Description |
---|---|
EntityType | The EntityType of the current item. |
Overrides
FlipHorizontal
Gets or sets a Horizontal flipping of Picture.
Declaration
public bool FlipHorizontal { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
This property returns True if the specified picture is flipped around the horizontal axis, and False if not.
Examples
The following code example demonstrates how to gets or sets the horizontal flip to picture.
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new text to the paragraph
IWParagraph paragraph = section.AddParagraph();
//Gets the image and convert to byte array
Image image = Image.FromFile("Image.png");
MemoryStream imageStream = new MemoryStream();
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
byte[] imageBytes = imageStream.ToArray();
//Initializes new picture
WPicture picture = new WPicture(document);
//Loads an image from the byte array
picture.LoadImage(imageBytes);
//Sets height and width for the image
picture.Height = 100;
picture.Width = 150;
//Sets horizontal flip to the picture
picture.FlipHorizontal = true;
//Adds image to the paragraph
paragraph.Items.Add(picture);
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
'Creates a New Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new text to the paragraph
Dim paragraph As IWParagraph = section.AddParagraph
'Gets the image and convert to byte array
Dim image As Image = Image.FromFile("Image.png")
Dim imageStream As MemoryStream = New MemoryStream
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png)
Dim imageBytes() As Byte = imageStream.ToArray
'Initializes new picture
Dim picture As WPicture = New WPicture(document)
'Loads an image from the byte array
picture.LoadImage(imageBytes)
'Sets height and width for the image
picture.Height = 100
picture.Width = 150
'Sets horizontal flip to the picture
picture.FlipHorizontal = True
'Adds image to the paragraph
paragraph.Items.Add(picture)
'Saves the Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the document
document.Close()
FlipVertical
Gets or sets a Vertical flipping of Picture.
Declaration
public bool FlipVertical { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
This property returns True if the specified picture is flipped around the vertical axis, and False if not.
Examples
The following code example demonstrates how to gets or sets the vertical flip to picture.
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new text to the paragraph
IWParagraph paragraph = section.AddParagraph();
//Gets the image and convert to byte array
Image image = Image.FromFile("Image.png");
MemoryStream imageStream = new MemoryStream();
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
byte[] imageBytes = imageStream.ToArray();
//Initializes new picture
WPicture picture = new WPicture(document);
//Loads an image from the byte array
picture.LoadImage(imageBytes);
//Sets height and width for the image
picture.Height = 100;
picture.Width = 150;
//Sets vertical flip to the picture
picture.FlipVertical = true;
//Adds image to the paragraph
paragraph.Items.Add(picture);
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
'Creates a New Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new text to the paragraph
Dim paragraph As IWParagraph = section.AddParagraph
'Gets the image and convert to byte array
Dim image As Image = Image.FromFile("Image.png")
Dim imageStream As MemoryStream = New MemoryStream
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png)
Dim imageBytes() As Byte = imageStream.ToArray
'Initializes new picture
Dim picture As WPicture = New WPicture(document)
'Loads an image from the byte array
picture.LoadImage(imageBytes)
'Sets height and width for the image
picture.Height = 100
picture.Width = 150
'Sets vertical flip to the picture
picture.FlipVertical = True
'Adds image to the paragraph
paragraph.Items.Add(picture)
'Saves the Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the document
document.Close()
Height
Gets or sets the picture height in points
Declaration
public float Height { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The float that specifies the height. |
HeightScale
Gets or sets the picture height scale factor in percent.
Declaration
public float HeightScale { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The float that specifies the height scale factor. |
HorizontalAlignment
Gets or sets the horizontal alignment of the picture.
Declaration
public ShapeHorizontalAlignment HorizontalAlignment { get; set; }
Property Value
Type | Description |
---|---|
ShapeHorizontalAlignment | The ShapeHorizontalAlignment member that specifies the horizontal alignment. |
Remarks
If the alignment is set as None, then the picture is explicitly positioned using position properties. Otherwise it is positioned according to the alignment specified. The position of the object is relative to HorizontalOrigin.
HorizontalOrigin
Gets or sets the horizontal origin of the picture.
Declaration
public HorizontalOrigin HorizontalOrigin { get; set; }
Property Value
Type | Description |
---|---|
HorizontalOrigin | The HorizontalOrigin member that specifies the horizontal origin. |
HorizontalPosition
Gets or sets absolute horizontal position of the picture in points.
Declaration
public float HorizontalPosition { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The float that specifies the horizontal position. |
Remarks
The horizontal position is relative to the HorizontalOrigin.
Image
Gets the System.Drawing.Image instance that represents the picture. Read-only.
Declaration
public Image Image { get; }
Property Value
Type | Description |
---|---|
System.Drawing.Image | The System.Drawing.Image instance. |
Remarks
This property is not supported in Silverlight, WinRT, Windows Phone, Universal, Universal Windows Platform, MVC6 and Xamarin platforms.
ImageBytes
Gets the image as byte array. Read-only.
Declaration
public byte[] ImageBytes { get; }
Property Value
Type | Description |
---|---|
System.Byte[] | The System.Byte array that represents image bytes. |
IsBelowText
Gets or sets a value indicating whether the picture is below the text.
Declaration
public bool IsBelowText { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the picture is below text; otherwise, false. |
LockAspectRatio
Gets or sets a value indicating whether the pictute has Lock aspect ratio. The default is false.
Declaration
public bool LockAspectRatio { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Name
Gets or sets the name of the picture.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String | The string that represents the name. |
Rotation
Gets or sets the picture rotation in degree.
Declaration
public float Rotation { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The float that specifies the rotation value of the picture. |
Remarks
A positive value indicates clockwise rotation; a negative value indicates counterclockwise rotation.
Examples
The following code example demonstrates how to gets or sets the rotation value of picture in degree.
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new text to the paragraph
IWParagraph paragraph = section.AddParagraph();
//Gets the image and convert to byte array
Image image = Image.FromFile("Image.png");
MemoryStream imageStream = new MemoryStream();
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
byte[] imageBytes = imageStream.ToArray();
//Initializes new picture
WPicture picture = new WPicture(document);
//Loads an image from the byte array
picture.LoadImage(imageBytes);
//Sets height and width for the image
picture.Height = 100;
picture.Width = 150;
//Sets picture rotation in degree
picture.Rotation = 90;
//Adds image to the paragraph
paragraph.Items.Add(picture);
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
'Creates a New Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new text to the paragraph
Dim paragraph As IWParagraph = section.AddParagraph
'Gets the image and convert to byte array
Dim image As Image = Image.FromFile("Image.png")
Dim imageStream As MemoryStream = New MemoryStream
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png)
Dim imageBytes() As Byte = imageStream.ToArray
'Initializes new picture
Dim picture As WPicture = New WPicture(document)
'Loads an image from the byte array
picture.LoadImage(imageBytes)
'Sets height and width for the image
picture.Height = 100
picture.Width = 150
'Sets picture rotation in degree
picture.Rotation = 90
'Adds image to the paragraph
paragraph.Items.Add(picture)
'Saves the Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the document
document.Close()
SvgData
Gets the SVG image as byte array. Read-only.
Declaration
public byte[] SvgData { get; }
Property Value
Type | Description |
---|---|
System.Byte[] | The System.Byte array that represents SVG image bytes. |
TextWrappingStyle
Gets or sets the text wrapping style of the picture.
Declaration
public TextWrappingStyle TextWrappingStyle { get; set; }
Property Value
Type | Description |
---|---|
TextWrappingStyle | The TextWrappingStyle member that specifies the text wrapping style. |
TextWrappingType
Gets or sets the text wrapping type of the picture.
Declaration
public TextWrappingType TextWrappingType { get; set; }
Property Value
Type | Description |
---|---|
TextWrappingType | The TextWrappingType member that specifies the text wrapping type. |
Title
Gets or sets the picture title.
Declaration
public string Title { get; set; }
Property Value
Type | Description |
---|---|
System.String | The string that represents the title. |
VerticalAlignment
Gets or sets the vertical alignment of the picture.
Declaration
public ShapeVerticalAlignment VerticalAlignment { get; set; }
Property Value
Type | Description |
---|---|
ShapeVerticalAlignment |
Remarks
If the alignment is set as None, then the picture is explicitly positioned using position properties. Otherwise it is positioned according to the alignment specified. The position of the object is relative to VerticalOrigin.
VerticalOrigin
Gets or sets the vertical origin of the picture.
Declaration
public VerticalOrigin VerticalOrigin { get; set; }
Property Value
Type | Description |
---|---|
VerticalOrigin | The VerticalOrigin member that specifies the vertical origin. |
VerticalPosition
Gets or sets absolute vertical position of the picture in points.
Declaration
public float VerticalPosition { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The float that specifies the vertical position. |
Remarks
The vertical position is relative to the VerticalOrigin.
Visible
Gets or sets a value indicating whether the picture is visible.
Declaration
public bool Visible { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the picture is visible; otherwise, false. |
Width
Gets or sets the picture width in points.
Declaration
public float Width { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The float that specifies the width. |
WidthScale
Gets or sets the picture width scale factor in percent.
Declaration
public float WidthScale { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The float that specifies the width scale factor. |
Methods
AddCaption(String, CaptionNumberingFormat, CaptionPosition)
Adds caption for the current picture with specified name, caption format and caption position.
Declaration
public IWParagraph AddCaption(string name, CaptionNumberingFormat format, CaptionPosition captionPosition)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The string that specifies the name. |
CaptionNumberingFormat | format | The CaptionNumberingFormat member that specifies the format for caption numbering. |
CaptionPosition | captionPosition | The CaptionPosition member that specifies the position of caption. |
Returns
Type | Description |
---|---|
IWParagraph | The paragraph instance with the specified caption. |
Examples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("This paragraph has picture. ");
//Append new picture to the paragraph
IWPicture picture = paragraph.AppendPicture(Image.FromFile("Image.png"));
//Set width and height for the paragraph
picture.Width = 150;
picture.Height = 100;
//Set caption for picture
picture.AddCaption("Figure 1.1", CaptionNumberingFormat.Number, CaptionPosition.AboveImage);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("This paragraph has picture. ")
'Append new picture to the paragraph
Dim picture As IWPicture = paragraph.AppendPicture(Image.FromFile("Image.png"))
'Set width and height for the paragraph
picture.Width = 150
picture.Height = 100
'Set caption for picture
picture.AddCaption("Figure 1.1", CaptionNumberingFormat.Number, CaptionPosition.AboveImage)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
CloneImpl()
Creates a duplicate copy of the entity.
Declaration
protected override object CloneImpl()
Returns
Type | Description |
---|---|
System.Object | An System.Object reference to the newly created instance. |
Overrides
CreateLayoutInfo()
Creates layout information.
Declaration
protected override void CreateLayoutInfo()
Overrides
DeleteEnhMetaFile(IntPtr)
Deletes an enhanced-format metafile or an enhanced-format metafile handle.
Declaration
public static bool DeleteEnhMetaFile(IntPtr hemf)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | hemf | A handle to an enhanced metafile. |
Returns
Type | Description |
---|---|
System.Boolean | If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. |
GetEnhMetaFileBits(Int32, Int32, Byte[])
Retrieves the contents of the specified enhanced-format metafile and copies them into a buffer.
Declaration
public static int GetEnhMetaFileBits(int hemf, int cbBuffer, byte[] lpbBuffer)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | hemf | A handle to the enhanced metafile. |
System.Int32 | cbBuffer | The size, in bytes, of the buffer to receive the data. |
System.Byte[] | lpbBuffer | A pointer to a buffer that receives the metafile data. The buffer must be sufficiently large to contain the data. If lpbBuffer is NULL, the function returns the size necessary to hold the data. |
Returns
Type | Description |
---|---|
System.Int32 | If the function succeeds and the buffer pointer is NULL, the return value is the size of the enhanced metafile, in bytes. If the function succeeds and the buffer pointer is a valid pointer, the return value is the number of bytes copied to the buffer. If the function fails, the return value is zero. |
Remarks
The GetEnhMetaFileBits(Int32, Int32, Byte[]) does not invalidate the enhanced-metafile handle. The application must call the DeleteEnhMetaFile(IntPtr) function to delete the handle when it is no longer needed.
InitXDLSHolder()
Registers child objects in XDSL holder.
Declaration
protected override void InitXDLSHolder()
Overrides
LoadImage(Byte[])
Loads the image from the specified byte array.
Declaration
public void LoadImage(byte[] imageBytes)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | imageBytes | The byte array that specifies the image as bytes. |
Examples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Get the image and convert to byte array
Image image = Image.FromFile("Image.png");
MemoryStream imageStream = new MemoryStream();
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
byte[] imageBytes = imageStream.ToArray();
//Initialize new picture
WPicture picture = new WPicture(document);
//Load image from the byte array
picture.LoadImage(imageBytes);
//Set width and height
picture.Height = 100;
picture.Width = 150;
//Add picture to the paragraph
paragraph.Items.Add(picture);
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Get the image and convert to byte array
Dim image__1 As Image = Image.FromFile("Image.png")
Dim imageStream As New MemoryStream()
image__1.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png)
Dim imageBytes As Byte() = imageStream.ToArray()
'Initialize new picture
Dim picture As New WPicture(document)
'Load image from the byte array
picture.LoadImage(imageBytes)
'Set width and height
picture.Height = 100
picture.Width = 150
'Add picture to the paragraph
paragraph.Items.Add(picture)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
LoadImage(Byte[], Byte[])
Loads the SVG image from the specified byte array.
Declaration
public void LoadImage(byte[] svgData, byte[] imageBytes)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | svgData | The byte array that specifies the SVG image as bytes. |
System.Byte[] | imageBytes | The byte array that specifies the image as bytes. |
Examples
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Get the SVG image as byte array.
byte[] imageBytes = File.ReadAllBytes("Image.png");
//Get the SVG image as byte array.
byte[] svgData = File.ReadAllBytes("Image.svg");
//Initialize new picture
WPicture picture = new WPicture(document);
//Load both fallback and SVG image from the byte array
picture.LoadImage(svgData, imageBytes);
//Set width and height
picture.Height = 100;
picture.Width = 150;
//Add picture to the paragraph
paragraph.Items.Add(picture);
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Get the image byte array
Dim imageBytes As Byte() = File.ReadAllBytes("Image.png")
'Get the SVG image as byte array.
Dim svgData As Byte() = File.ReadAllBytes("Image.svg")
'Initialize new picture
Dim picture As New WPicture(document)
'Load both fallback and SVG image from the byte array
picture.LoadImage(svgData, imageBytes)
'Set width and height
picture.Height = 100
picture.Width = 150
'Add picture to the paragraph
paragraph.Items.Add(picture)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.ArgumentException | Thrown when |
LoadImage(Image)
Loads the image from the specified System.Drawing.Image instance.
Declaration
public void LoadImage(Image image)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Image | image | The System.Drawing.Image instance. |
Remarks
This method is not supported in Silverlight, WinRT, Windows Phone, Universal, Universal Windows Platform and Xamarin platforms.
Examples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Initialize new picture
WPicture picture = new WPicture(document);
//Load image from the file
picture.LoadImage(Image.FromFile("Image.png"));
//Set width and height
picture.Height = 100;
picture.Width = 150;
//Add picture to the paragraph
paragraph.Items.Add(picture);
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Initialize new picture
Dim picture As New WPicture(document)
'Load image from the file
picture.LoadImage(Image.FromFile("Image.png"))
'Set width and height
picture.Height = 100
picture.Width = 150
'Add picture to the paragraph
paragraph.Items.Add(picture)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
ReadXmlAttributes(IXDLSAttributeReader)
Reads object data from xml attributes.
Declaration
protected override void ReadXmlAttributes(IXDLSAttributeReader reader)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeReader | reader | The IXDLSAttributeReader object. |
Overrides
ReadXmlContent(IXDLSContentReader)
Reads object data from xml attributes.
Declaration
protected override bool ReadXmlContent(IXDLSContentReader reader)
Parameters
Type | Name | Description |
---|---|---|
IXDLSContentReader | reader | The IXDLSContentReader object. |
Returns
Type | Description |
---|---|
System.Boolean | The value indicating the presence of xml content. |
Overrides
WriteXmlAttributes(IXDLSAttributeWriter)
Writes object data as xml attributes.
Declaration
protected override void WriteXmlAttributes(IXDLSAttributeWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeWriter | writer | The IXDLSAttributeWriter object. |
Overrides
WriteXmlContent(IXDLSContentWriter)
Writes object data as inside xml element.
Declaration
protected override void WriteXmlContent(IXDLSContentWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IXDLSContentWriter | writer | The IXDLSContentWriter object. |