Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fileformat-words-gists/337a12ff02605c5e4aff85354cb72195 to your computer and use it in GitHub Desktop.
Save fileformat-words-gists/337a12ff02605c5e4aff85354cb72195 to your computer and use it in GitHub Desktop.
C# Read Multiple Frame 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($"WordParagraphsFrame.docx");
var body = new FileFormat.Words.Body(doc);
// Traverse and display paragraphs with plain text
foreach (var paragraph in body.Paragraphs)
{
System.Console.WriteLine($" Paragraph Text: {paragraph.Text}");
if (paragraph.ParagraphBorder.Size > 0)
{
System.Console.WriteLine($" Paragraph Border Width: {paragraph.ParagraphBorder.Width}");
System.Console.WriteLine($" Paragraph Border Color: {paragraph.ParagraphBorder.Color}");
System.Console.WriteLine($" Paragraph Border Size: {paragraph.ParagraphBorder.Size}");
}
else
{
System.Console.WriteLine($" Paragraph Border Width: ");
System.Console.WriteLine($" Paragraph Border Color: ");
System.Console.WriteLine($" Paragraph Border Size: ");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment