InkXml.vb
C# VB
'''' This code is part of Document Solutions for Word demos.'' Copyright (c) MESCIUS inc. All rights reserved.''Imports System.IOImports System.CollectionsImports System.Collections.GenericImports System.LinqImports System.XmlImports 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 FunctionEnd Class