RemoveEmbedFonts.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 System.Collections.Generic;
  9. using System.Linq;
  10. using GrapeCity.Documents.Word;
  11.  
  12. namespace DsWordWeb.Demos
  13. {
  14. // This sample shows how to enumerate and remove embedded font data from a DOCX.
  15. // Compare the size of the resulting DOCX with the size of the original "EmbedFonts.docx".
  16. public class RemoveEmbedFonts
  17. {
  18. public GcWordDocument CreateDocx()
  19. {
  20. GcWordDocument doc = new GcWordDocument();
  21.  
  22. // Load a DOCX that contains embedded font:
  23. doc.Load(Path.Combine("Resources", "WordDocs", "EmbedFonts.docx"));
  24.  
  25. // Enumerate the embedded fonts:
  26. foreach (var fi in doc.Fonts)
  27. {
  28. // Remove all embedded fonts:
  29. fi.Embedded.Clear();
  30. }
  31.  
  32. // Done:
  33. return doc;
  34. }
  35. }
  36. }
  37.