Created
July 9, 2024 18:00
-
-
Save fileformat-words-gists/337a12ff02605c5e4aff85354cb72195 to your computer and use it in GitHub Desktop.
C# Read Multiple Frame Paragraphs in Word Documents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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