|
| 1 | +using Syncfusion.DocIO; |
| 2 | +using Syncfusion.DocIO.DLS; |
| 3 | +using System.IO; |
| 4 | + |
| 5 | + |
| 6 | +// Creates a new instance of WordDocument to work with. |
| 7 | +using (WordDocument document = new WordDocument()) |
| 8 | +{ |
| 9 | + // Adds a new section to the document. |
| 10 | + IWSection section = document.AddSection(); |
| 11 | + IWParagraph paragraph = section.AddParagraph(); |
| 12 | + |
| 13 | + // Adds a numbered list style with CardinalText pattern (One, Two, Three, ...). |
| 14 | + ListStyle listStyle = document.AddListStyle(ListType.Numbered, "CardinalText"); |
| 15 | + WListLevel levelOne = listStyle.Levels[0]; |
| 16 | + levelOne.PatternType = ListPatternType.CardinalText; |
| 17 | + levelOne.StartAt = 1; |
| 18 | + |
| 19 | + // Adds a heading paragraph for the CardinalText list. |
| 20 | + paragraph = section.AddParagraph(); |
| 21 | + paragraph.AppendText("List pattern Cardinal Text"); |
| 22 | + |
| 23 | + // Adds first list item using CardinalText style. |
| 24 | + paragraph = section.AddParagraph(); |
| 25 | + paragraph.AppendText("List item 1"); |
| 26 | + paragraph.ListFormat.ApplyStyle("CardinalText"); |
| 27 | + paragraph.ListFormat.ContinueListNumbering(); |
| 28 | + |
| 29 | + // Adds second list item using CardinalText style. |
| 30 | + paragraph = section.AddParagraph(); |
| 31 | + paragraph.AppendText("List item 2"); |
| 32 | + paragraph.ListFormat.ApplyStyle("CardinalText"); |
| 33 | + paragraph.ListFormat.ContinueListNumbering(); |
| 34 | + |
| 35 | + // Adds third list item using CardinalText style. |
| 36 | + paragraph = section.AddParagraph(); |
| 37 | + paragraph.AppendText("List item 3"); |
| 38 | + paragraph.ListFormat.ApplyStyle("CardinalText"); |
| 39 | + paragraph.ListFormat.ContinueListNumbering(); |
| 40 | + |
| 41 | + // Adds a blank paragraph before the next list. |
| 42 | + paragraph = section.AddParagraph(); |
| 43 | + |
| 44 | + // Adds a numbered list style with HindiLetter1 pattern. |
| 45 | + listStyle = document.AddListStyle(ListType.Numbered, "HindiLetter1"); |
| 46 | + levelOne = listStyle.Levels[0]; |
| 47 | + levelOne.PatternType = ListPatternType.HindiLetter1; |
| 48 | + levelOne.StartAt = 1; |
| 49 | + |
| 50 | + // Adds a heading paragraph for the HindiLetter1 list. |
| 51 | + paragraph = section.AddParagraph(); |
| 52 | + paragraph.AppendText("List pattern Hindi Letter"); |
| 53 | + |
| 54 | + // Adds first list item using HindiLetter1 style. |
| 55 | + paragraph = section.AddParagraph(); |
| 56 | + paragraph.AppendText("List item 1"); |
| 57 | + paragraph.ListFormat.ApplyStyle("HindiLetter1"); |
| 58 | + paragraph.ListFormat.ContinueListNumbering(); |
| 59 | + |
| 60 | + // Adds second list item using HindiLetter1 style. |
| 61 | + paragraph = section.AddParagraph(); |
| 62 | + paragraph.AppendText("List item 2"); |
| 63 | + paragraph.ListFormat.ApplyStyle("HindiLetter1"); |
| 64 | + paragraph.ListFormat.ContinueListNumbering(); |
| 65 | + |
| 66 | + // Adds third list item using HindiLetter1 style. |
| 67 | + paragraph = section.AddParagraph(); |
| 68 | + paragraph.AppendText("List item 3"); |
| 69 | + paragraph.ListFormat.ApplyStyle("HindiLetter1"); |
| 70 | + paragraph.ListFormat.ContinueListNumbering(); |
| 71 | + |
| 72 | + // Adds a blank paragraph before the next list. |
| 73 | + paragraph = section.AddParagraph(); |
| 74 | + |
| 75 | + // Adds a numbered list style with Hebrew1 pattern. |
| 76 | + listStyle = document.AddListStyle(ListType.Numbered, "Hebrew1"); |
| 77 | + levelOne = listStyle.Levels[0]; |
| 78 | + levelOne.PatternType = ListPatternType.Hebrew1; |
| 79 | + levelOne.StartAt = 1; |
| 80 | + |
| 81 | + // Adds a heading paragraph for the Hebrew1 list. |
| 82 | + paragraph = section.AddParagraph(); |
| 83 | + paragraph.AppendText("List pattern Herbrew"); |
| 84 | + |
| 85 | + // Adds first list item using Hebrew1 style. |
| 86 | + paragraph = section.AddParagraph(); |
| 87 | + paragraph.AppendText("List item 1"); |
| 88 | + paragraph.ListFormat.ApplyStyle("Hebrew1"); |
| 89 | + paragraph.ListFormat.ContinueListNumbering(); |
| 90 | + |
| 91 | + // Adds second list item using Hebrew1 style. |
| 92 | + paragraph = section.AddParagraph(); |
| 93 | + paragraph.AppendText("List item 2"); |
| 94 | + paragraph.ListFormat.ApplyStyle("Hebrew1"); |
| 95 | + paragraph.ListFormat.ContinueListNumbering(); |
| 96 | + |
| 97 | + // Adds third list item using Hebrew1 style. |
| 98 | + paragraph = section.AddParagraph(); |
| 99 | + paragraph.AppendText("List item 3"); |
| 100 | + paragraph.ListFormat.ApplyStyle("Hebrew1"); |
| 101 | + paragraph.ListFormat.ContinueListNumbering(); |
| 102 | + |
| 103 | + // Create a file stream to save the document. |
| 104 | + using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite)) |
| 105 | + { |
| 106 | + // Saves the Word document to the specified file stream in DOCX format. |
| 107 | + document.Save(outputFileStream, FormatType.Docx); |
| 108 | + } |
| 109 | +} |
0 commit comments