LoadDocx.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. // This sample shows how to load an existing DOCX file into DsWord.
  13. // It also appends a short note to the end of the loaded document.
  14. public class LoadDocx
  15. {
  16. public GcWordDocument CreateDocx()
  17. {
  18. var doc = new GcWordDocument();
  19.  
  20. // Load an existing DOCX file:
  21. var path = Path.Combine("Resources", "WordDocs", "JsFrameworkExcerpt.docx");
  22. doc.Load(path);
  23.  
  24. // Add a note at the end of the document:
  25. doc.Body.Sections.Last.GetRange().Paragraphs.Add($"Loaded into DsWord on {Util.TimeNow():R}.");
  26.  
  27. // Done:
  28. return doc;
  29. }
  30. }
  31. }
  32.