InkXml.vb
  1. ''
  2. '' This code is part of Document Solutions for Word demos.
  3. '' Copyright (c) MESCIUS inc. All rights reserved.
  4. ''
  5. Imports System.IO
  6. Imports System.Drawing
  7. Imports System.Collections
  8. Imports System.Collections.Generic
  9. Imports System.Linq
  10. Imports System.Xml
  11. Imports GrapeCity.Documents.Word
  12.  
  13. '' This sample shows how to load an existing ink XML
  14. '' and create an InkShape with the loaded ink as content.
  15. Public Class InkXml
  16. Function CreateDocx() As GcWordDocument
  17. Dim doc = New GcWordDocument()
  18.  
  19. '' Load the ink XML and add it as an ink shape to the DOCX:
  20. Dim inkXml = New XmlDocument()
  21. inkXml.Load(Path.Combine("Resources", "Misc", "ink.xml"))
  22. Dim ink = doc.Body.Paragraphs.Add("Paragraph containing the ink shape.").GetRange().Runs.Add().GetRange().InkShapes.Add(inkXml)
  23. '' Modify the ink's size and angle:
  24. ink.WrapFormat.Type = WrapType.Square
  25. ink.Size.Width.Relative = 40
  26. ink.Size.Width.RelativeTo = SizeRelativeHorizontally.Margin
  27. ink.Size.Height.Relative = 30
  28. ink.Size.Height.RelativeTo = SizeRelativeVertically.Margin
  29. ink.Rotation.Angle = 30
  30.  
  31. '' Add a paragraph after the one containing the ink:
  32. doc.Body.Paragraphs.Add(
  33. "This paragraph is added after the ink shape loaded from an XML. " +
  34. $"The ink shape's wrap type is set to {ink.WrapFormat.Type} " +
  35. $"and the shape is rotated {ink.Rotation.Angle} degrees clockwise. " +
  36. $"The width is {ink.Size.Width.Relative}% relative to page width sans the margins, " +
  37. $"and the height is {ink.Size.Height.Relative}% relative to page height sans the margins.")
  38.  
  39. '' Done:
  40. Return doc
  41. End Function
  42. End Class
  43.