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; |
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>. | |
// Initialize a new word document with the default template | |
var doc = new FileFormat.Words.Document(); | |
System.Console.WriteLine("Word Document with default template initialized"); | |
// Initialize the body with the new document | |
var body = new FileFormat.Words.Body(doc); | |
System.Console.WriteLine("Body of the Word Document initialized"); |
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); | |
foreach (FileFormat.Words.IElements.Paragraph paragraph in body.Paragraphs) | |
{ |
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; |
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>. | |
// Initialize a new word document with the default template | |
var doc = new FileFormat.Words.Document(); | |
System.Console.WriteLine("Word Document with default template initialized"); | |
// Initialize the body with the new document | |
var body = new FileFormat.Words.Body(doc); | |
System.Console.WriteLine("Body of the Word Document initialized"); |
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
// Concurrently updating three documents using <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a> | |
// Supported in v23.12.0 | |
var task1 = System.Threading.Tasks.Task.Run(() | |
=> ManipulateDocument("doc1.docx", "doc1_Threaded.docx")); | |
var task2 = System.Threading.Tasks.Task.Run(() | |
=> ManipulateDocument("doc2.docx", "doc2_Threaded.docx")); | |
var task3 = System.Threading.Tasks.Task.Run(() | |
=> ManipulateDocument("doc3.docx", "doc3_Threaded.docx")); | |
// Wait for all tasks to complete |
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
/// <summary> | |
/// Loads a Word Document with structured content using | |
/// <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>. | |
/// Modifies tables by setting column widths to 2000 | |
/// Saves the modified Word Document. | |
/// </summary> | |
/// <param name="documentDirectory"> | |
/// The directory where the Word Document to load is present and | |
/// the modified document will be saved (default is root of your project). | |
/// </param> |
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
/// <summary> | |
/// Loads a Word Document with structured content using | |
/// <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>. | |
/// Traverses tables and displays associated styles as defined by the Word document template. | |
/// Traverses through each row and then traverses columns within the row. | |
/// Traverses through paragrpahs within each cell and displays paragraph plain text | |
/// </summary> | |
/// <param name="documentDirectory"> | |
/// The directory where the Word Document to load is present | |
/// (default is root of your project). |
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
/// <summary> | |
/// Creates a new Word Document with structured content using | |
/// <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>. | |
/// Generates 5(rows) x 3(cols) tables with table styles defined by the Word document template. | |
/// Appends each table to the body of the word document. | |
/// Saves the newly created word document. | |
/// </summary> | |
/// <param name="documentDirectory"> | |
/// The directory where the Word Document will be saved (default is root of your project). | |
/// </param> |
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
/// <summary> | |
/// Loads a Word Document with structured content using | |
/// <a href="https://www.nuget.org/packages/FileFormat.Words">FileFormat.Words</a>. | |
/// Gets images from the word document. Decodes image using SkiaSharp and encode to JPG. | |
/// Resize image to 250(height) and 200(width). | |
/// Saves the modified Word Document. | |
/// </summary> | |
/// <param name="documentDirectory"> | |
/// The directory where the Word Document to load is present and | |
/// the modified document will be saved (default is root of your project). |