You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Novacode;
  6. using System.IO.Packaging;
  7. using System.Diagnostics;
  8. namespace ConsoleApplication1
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. //// Testing constants
  15. //const string package_part_document = "/word/document.xml";
  16. //const string package_part_header_first = "/word/header3.xml";
  17. //const string package_part_header_odd = "/word/header2.xml";
  18. //const string package_part_header_even = "/word/header1.xml";
  19. //const string package_part_footer_first = "/word/footer3.xml";
  20. //const string package_part_footer_odd = "/word/footer2.xml";
  21. //const string package_part_footer_even = "/word/footer1.xml";
  22. //// Load Test-01.docx
  23. //using (DocX document = DocX.Load("../../data/Test-01.docx"))
  24. //{
  25. // // Get the headers from the document.
  26. // Headers headers = document.Headers; Debug.Assert(headers != null);
  27. // Header header_first = headers.first; Debug.Assert(header_first != null);
  28. // Header header_odd = headers.odd; Debug.Assert(header_odd != null);
  29. // Header header_even = headers.even; Debug.Assert(header_even != null);
  30. // // Get the footers from the document.
  31. // Footers footers = document.Footers; Debug.Assert(footers != null);
  32. // Footer footer_first = footers.first; Debug.Assert(footer_first != null);
  33. // Footer footer_odd = footers.odd; Debug.Assert(footer_odd != null);
  34. // Footer footer_even = footers.even; Debug.Assert(footer_even != null);
  35. // // Its important that each Paragraph knows the PackagePart it belongs to.
  36. // document.Paragraphs.ForEach(p => Debug.Assert(p.PackagePart.Uri.ToString() == package_part_document));
  37. // header_first.Paragraphs.ForEach(p => Debug.Assert(p.PackagePart.Uri.ToString() == package_part_header_first));
  38. // header_odd.Paragraphs.ForEach(p => Debug.Assert(p.PackagePart.Uri.ToString() == package_part_header_odd));
  39. // header_even.Paragraphs.ForEach(p => Debug.Assert(p.PackagePart.Uri.ToString() == package_part_header_even));
  40. // footer_first.Paragraphs.ForEach(p => Debug.Assert(p.PackagePart.Uri.ToString() == package_part_footer_first));
  41. // footer_odd.Paragraphs.ForEach(p => Debug.Assert(p.PackagePart.Uri.ToString() == package_part_footer_odd));
  42. // footer_even.Paragraphs.ForEach(p => Debug.Assert(p.PackagePart.Uri.ToString() == package_part_footer_even));
  43. //}
  44. }
  45. }
  46. }