Last active
March 3, 2024 10:38
-
-
Save fileformat-words-gists/bd68c603de13475f65e2369969072b46 to your computer and use it in GitHub Desktop.
C# Read Word Paragraph Alignment
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($"filename.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; | |
foreach (FileFormat.Words.IElements.Paragraph paragraph in paragraphs) | |
{ | |
System.Console.WriteLine($"Paragraph Text : {paragraph.Text}"); | |
System.Console.WriteLine($"Paragraph Alignment : {paragraph.Alignment}"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment