InkXml.vb
''
'' This code is part of Document Solutions for Word demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System.IO
Imports System.Drawing
Imports System.Collections
Imports System.Collections.Generic
Imports System.Linq
Imports System.Xml
Imports GrapeCity.Documents.Word

'' This sample shows how to load an existing ink XML
'' and create an InkShape with the loaded ink as content.
Public Class InkXml
    Function CreateDocx() As GcWordDocument
        Dim doc = New GcWordDocument()

        '' Load the ink XML and add it as an ink shape to the DOCX:
        Dim inkXml = New XmlDocument()
        inkXml.Load(Path.Combine("Resources", "Misc", "ink.xml"))
        Dim ink = doc.Body.Paragraphs.Add("Paragraph containing the ink shape.").GetRange().Runs.Add().GetRange().InkShapes.Add(inkXml)
        '' Modify the ink's size and angle:
        ink.WrapFormat.Type = WrapType.Square
        ink.Size.Width.Relative = 40
        ink.Size.Width.RelativeTo = SizeRelativeHorizontally.Margin
        ink.Size.Height.Relative = 30
        ink.Size.Height.RelativeTo = SizeRelativeVertically.Margin
        ink.Rotation.Angle = 30

        '' Add a paragraph after the one containing the ink:
        doc.Body.Paragraphs.Add(
                "This paragraph is added after the ink shape loaded from an XML. " +
                $"The ink shape's wrap type is set to {ink.WrapFormat.Type} " +
                $"and the shape is rotated {ink.Rotation.Angle} degrees clockwise. " +
                $"The width is {ink.Size.Width.Relative}% relative to page width sans the margins, " +
                $"and the height is {ink.Size.Height.Relative}% relative to page height sans the margins.")

        '' Done:
        Return doc
    End Function
End Class