Footnotes.cs
  1. //
  2. // This code is part of Document Solutions for Word demos.
  3. // Copyright (c) MESCIUS inc. All rights reserved.
  4. //
  5. using System;
  6. using System.IO;
  7. using System.Drawing;
  8. using GrapeCity.Documents.Word;
  9.  
  10. namespace DsWordWeb.Demos
  11. {
  12. // Shows how to add and format footnotes.
  13. public class Footnotes
  14. {
  15. public GcWordDocument CreateDocx()
  16. {
  17. GcWordDocument doc = new GcWordDocument();
  18. // First section:
  19. var sec1 = doc.Body.Sections.First;
  20. // Section paragraphs:
  21. var pars1 = sec1.GetRange().Paragraphs;
  22. // Add a new paragraph:
  23. var p1 = pars1.Add("Section 1, Paragraph 1. " + Util.LoremIpsumPar());
  24. // Add two footnotes to the paragraph:
  25. p1.GetRange().Footnotes.Add("This is footnote 1 for Section 1, Paragraph 1.");
  26. p1.GetRange().Footnotes.Add("This is footnote 2 for Section 1, Paragraph 1.");
  27. // Add another paragraph, and a footnote to it:
  28. var p2 = pars1.Add("Section 1, Paragraph 2. ");
  29. p2.GetRange().Runs.Add(Util.LoremIpsumPar()).GetRange().Footnotes.Add(
  30. "This is a footnote for the last run in Section 1, Paragraph 2.");
  31. // Add 3rd paragraph:
  32. pars1.Add("Section 1, Paragraph 3. " + Util.LoremIpsumPar());
  33.  
  34. // Done:
  35. return doc;
  36. }
  37. }
  38. }
  39.