Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fileformat-words-gists/291df28a345ff6556c6c1f19f2b08a09 to your computer and use it in GitHub Desktop.
Save fileformat-words-gists/291df28a345ff6556c6c1f19f2b08a09 to your computer and use it in GitHub Desktop.
C# Read Roman Alphabetic Paragraphs in Word Documents
// Prerequisite: Install <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>.
// Load the Word Document
var doc = new FileFormat.Words.Document($"WordParagraphsRomanAlphabetic.docx");
// Initialize the body with the document
var body = new FileFormat.Words.Body(doc);
//System.Collections.Generic.List<FileFormat.Words.IElements.Paragraph>
// paragraphs = body.Paragraphs;
var paragraphs = body.Paragraphs;
foreach (FileFormat.Words.IElements.Paragraph paragraph in paragraphs)
{
System.Console.WriteLine($"Paragraph Text : {paragraph.Text}");
System.Console.WriteLine($"Paragraph NumberingId : {paragraph.NumberingId}");
System.Console.WriteLine($"Paragraph Numbered? : {paragraph.IsNumbered}");
System.Console.WriteLine($"Paragraph Roman? : {paragraph.IsRoman}");
System.Console.WriteLine($"Paragraph AlphabeticNumber? : {paragraph.IsAlphabeticNumber}");
System.Console.WriteLine($"Paragraph Numbering Level : {paragraph.NumberingLevel}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment