FontFillLine.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 example shows how to specify font fill and line styles.
  15. public class FontFillLine
  16. {
  17. public GcWordDocument CreateDocx()
  18. {
  19. var doc = new GcWordDocument();
  20. var style = doc.Styles.Add("My Style", StyleType.Paragraph);
  21. style.Font.Size = 48;
  22.  
  23. // Specify gradient fill for the font:
  24. var fill = style.Font.Fill;
  25. fill.Type = FillType.Gradient;
  26. var gradient = fill.GradientFill;
  27. gradient.Angle = 64;
  28. gradient.Stops[0].Color.RGB = Color.LightSeaGreen;
  29. gradient.Stops[1].Color.RGB = Color.Orange;
  30.  
  31. // Specify the outline for the font:
  32. var line = style.Font.Line;
  33. line.Width = 1;
  34. fill = line.Fill;
  35. fill.Type = FillType.Solid;
  36. fill.SolidFill.RGB = Color.Blue;
  37.  
  38. // Add sample text with the new style:
  39. doc.Body.Paragraphs.Add("Font Fill and Line styles.", style);
  40.  
  41. // Done:
  42. return doc;
  43. }
  44. }
  45. }
  46.