Hi Abhishek,
Thank you for using Syncfusion products.
Please find the below code snippet to create the line shape using DocIO:
Code snippet:
Dim document As New WordDocument()
document.EnsureMinimal()
Dim shape As New Shape(document, AutoShapeType.Line)
shape.LineFormat.Line = True
shape.LineFormat.Style = LineStyle.[Single]
shape.Width = 150
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.Square
'Set X position of line
shape.HorizontalPosition = 30
shape.HorizontalOrigin = HorizontalOrigin.Margin
'Set Y position of line
shape.VerticalPosition = 40
shape.VerticalOrigin = VerticalOrigin.Margin
shape.Visible = True
document.LastParagraph.Items.Add(shape)
document.Save("result.docx")
document.Close()
Regarding Line Arrow head preservation:
Currently DocIO does not have any public API to set the value for line’s begin and end arrow style. We will provide the public API to get or set the value for line’s begin and end arrow style in our upcoming 2015 volume 4 release which is expected to be in the month of December.
Regards,
Sarath
Hi Abhishek,
Thank you for your update.
When you inserted the shape into the paragraph then by default its anchor is positioned at the beginning of the corresponding paragraph. If your requirement is to insert the shape inside table cell then first add the paragraph inside the cell and insert the shape into that paragraph. For your reference please find the following code snippet to insert the shape inside a table cell:
Code snippet:
'Create the Word document instance
Dim document As New WordDocument()
document.EnsureMinimal()
'Add the table in the document
Dim table As IWTable = document.LastSection.AddTable()
'Reset the table with two rows and two columns
table.ResetCells(2, 2)
'Add the paragraph to the second row second column
Dim paragraph As WParagraph = TryCast(table(1, 1).AddParagraph(), WParagraph)
'Create a new shape instance
Dim shape As New Shape(document, AutoShapeType.Line)
'specify the width of the line shape
shape.Width = 150
'Specify the line style
shape.LineFormat.Style = LineStyle.[Single]
'Specify the line shape's text wrapping style
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.Square
'Specify the horizontal origin to position the shape. In this case we have specified the margin,
'if the owner paragraph of the line is added directly to section then document page margin is act as origin
'or else if it is added inside Table Cell then cell's margin is act as origin.
shape.HorizontalOrigin = HorizontalOrigin.Margin
'Specify the horizontal position of the shape
shape.HorizontalPosition = 10
'Specify the vertical origin to position the shape. In this case we have specified the margin,
'if the owner paragraph of the line is added directly to section then document page margin is act as origin
'or else if it is added inside Table Cell then cell's margin is act as origin.
shape.VerticalOrigin = VerticalOrigin.Margin
'Specify the vertical position of the shape
shape.VerticalPosition = 10
'Specify the visible option of the shape as true
shape.Visible = True
'Add the shape into paragraph
paragraph.Items.Add(shape)
'Save and close the WordDocument instance
document.Save("result.docx")
document.Close()
Please let us know if you have any queries.
Regards,
Sarath
Hi Abhishek,
We are glad to announce that our Essential Studio Volume 4, 2015 is rolled out and is available for download under the following link.
http://www.syncfusion.com/forums/121657/essential-studio-2015-volume-4-final-release-v13-4-0-53-is-available-for-download
Please find the code snippet below:
'Create the Word document instance
Dim document As New WordDocument()
document.EnsureMinimal()
'Add the table in the document
Dim table As IWTable = document.LastSection.AddTable()
'Reset the table with two rows and two columns
table.ResetCells(2, 2)
'Add the paragraph to the second row second column
Dim paragraph As WParagraph = TryCast(table(1, 1).AddParagraph(), WParagraph)
'Create a new shape instance
Dim shape As New Shape(document, AutoShapeType.Line)
'specify the width of the line shape
shape.Width = 150
'Specify the line style
shape.LineFormat.Style = LineStyle.[Single]
'Specify the begin arrow head style
shape.LineFormat.BeginArrowheadStyle = ArrowheadStyle.ArrowheadTriangle
'Specify the end arrow head style
shape.LineFormat.EndArrowheadStyle = ArrowheadStyle.ArrowheadTriangle
'Specify the line shape's text wrapping style
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.Square
'Specify the horizontal origin to position the shape. In this case we have specified the margin,
'if the owner paragraph of the line is added directly to section then document page margin is act as origin
'or else if it is added inside Table Cell then cell's margin is act as origin.
shape.HorizontalOrigin = HorizontalOrigin.Margin
'Specify the horizontal position of the shape
shape.HorizontalPosition = 10
'Specify the vertical origin to position the shape. In this case we have specified the margin,
'if the owner paragraph of the line is added directly to section then document page margin is act as origin
'or else if it is added inside Table Cell then cell's margin is act as origin.
shape.VerticalOrigin = VerticalOrigin.Margin
'Specify the vertical position of the shape
shape.VerticalPosition = 10
'Specify the visible option of the shape as true
shape.Visible = True
'Add the shape into paragraph
paragraph.Items.Add(shape)
'Save and close the WordDocument instance
document.Save("result.docx")
document.Close()
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.
Regards,
Sarath