Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

LineSample.cs 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /***************************************************************************************
  2. DocX – DocX is the community edition of Xceed Words for .NET
  3. Copyright (C) 2009-2017 Xceed Software Inc.
  4. This program is provided to you under the terms of the Microsoft Public
  5. License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
  6. For more features and fast professional support,
  7. pick up Xceed Words for .NET at https://xceed.com/xceed-words-for-net/
  8. *************************************************************************************/
  9. using System;
  10. using System.Drawing;
  11. using System.IO;
  12. namespace Xceed.Words.NET.Examples
  13. {
  14. public class LineSample
  15. {
  16. #region Private Members
  17. private const string LineSampleOutputDirectory = Program.SampleDirectory + @"Line\Output\";
  18. #endregion
  19. #region Constructors
  20. static LineSample()
  21. {
  22. if( !Directory.Exists( LineSample.LineSampleOutputDirectory ) )
  23. {
  24. Directory.CreateDirectory( LineSample.LineSampleOutputDirectory );
  25. }
  26. }
  27. #endregion
  28. #region Public Methods
  29. /// <summary>
  30. /// Create a document and add different lines under paragraphs.
  31. /// </summary>
  32. public static void InsertHorizontalLine()
  33. {
  34. Console.WriteLine( "\tInsertHorizontalLine()" );
  35. using( var document = DocX.Create( LineSample.LineSampleOutputDirectory + @"InsertHorizontalLine.docx" ) )
  36. {
  37. // Add a title
  38. document.InsertParagraph( "Adding bottom Horizontal lines" ).FontSize( 15d ).SpacingAfter( 50d ).Alignment = Alignment.center;
  39. // Add a paragraph with a single line.
  40. var p = document.InsertParagraph();
  41. p.Append( "This is a paragraph with a single line." ).Font( new Font( "Arial" ) ).FontSize( 20 );
  42. p.InsertHorizontalLine( "single", 6, 1, "auto" );
  43. p.SpacingAfter( 20 );
  44. // Add a paragraph with a double green line.
  45. var p2 = document.InsertParagraph();
  46. p2.Append( "This is a paragraph with a double colored line." ).Font( new Font( "Arial" ) ).FontSize( 20 );
  47. p2.InsertHorizontalLine( "double", 6, 1, "green" );
  48. p2.SpacingAfter( 20 );
  49. // Add a paragraph with a triple red line.
  50. var p3 = document.InsertParagraph();
  51. p3.Append( "This is a paragraph with a triple colored line." ).Font( new Font( "Arial" ) ).FontSize( 20 );
  52. p3.InsertHorizontalLine( "triple", 6, 1, "red" );
  53. p3.SpacingAfter( 20 );
  54. // Add a paragraph with a single spaced line.
  55. var p4 = document.InsertParagraph();
  56. p4.Append( "This is a paragraph with a spaced line." ).Font( new Font( "Arial" ) ).FontSize( 20 );
  57. p4.InsertHorizontalLine( "single", 6, 12, "auto" );
  58. p4.SpacingAfter( 20 );
  59. // Add a paragraph with a single large line.
  60. var p5 = document.InsertParagraph();
  61. p5.Append( "This is a paragraph with a large line." ).Font( new Font( "Arial" ) ).FontSize( 20 );
  62. p5.InsertHorizontalLine( "single", 25, 1, "auto" );
  63. p5.SpacingAfter( 20 );
  64. document.Save();
  65. Console.WriteLine( "\tCreated: InsertHorizontalLine.docx\n" );
  66. }
  67. }
  68. #endregion
  69. }
  70. }