InkXml.cs
C# VB
//// This code is part of Document Solutions for Word demos.// Copyright (c) MESCIUS inc. All rights reserved.//using System.IO;using System.Xml;using GrapeCity.Documents.Word;
namespace DsWordWeb.Demos{ // This sample shows how to load an existing ink XML // and create an InkShape with the loaded ink as content. public class InkXml { public GcWordDocument CreateDocx() { GcWordDocument doc = new GcWordDocument();
// Load the ink XML and add it as an ink shape to the DOCX: var inkXml = new XmlDocument(); inkXml.Load(Path.Combine("Resources", "Misc", "ink.xml")); var 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; } }}