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/Openize.Words">Openize.Words</a>. | |
// Initialize a new word document with the default template | |
var doc = new Openize.Words.Document(); | |
System.Console.WriteLine("Word Document with default template initialized"); | |
// Initialize the body with the new document | |
var body = new Openize.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/Openize.Words">Openize.Words</a>. | |
// Load the Word Document | |
var doc = new Openize.Words.Document($"WordParas.docx"); | |
var body = new Openize.Words.Body(doc); | |
var num = 0; | |
System.Console.WriteLine("Paragraphs Plain Text"); | |
// Traverse and display paragraphs with plain text |
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/Openize.Words">Openize.Words</a>. | |
// Load the Word Document | |
var doc = new Openize.Words.Document($"WordParas.docx"); | |
var body = new Openize.Words.Body(doc); | |
foreach (var paragraph in body.Paragraphs) | |
{ | |
foreach (var run in paragraph.Runs) | |
{ |
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/Openize.Words">Openize.Words</a>. | |
// Initialize a new word document with the default template | |
var doc = new Openize.Words.Document(); | |
// Initialize the body with the new document | |
var body = new Openize.Words.Body(doc); | |
// Load images from the specified directory | |
var imageFiles = System.IO.Directory.GetFiles(imageDirectory); |
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/Openize.Words">Openize.Words</a>. | |
// Load the Word Document | |
var doc = new Openize.Words.Document($"WordImgs.docx"); | |
var body = new Openize.Words.Body(doc); | |
var num = 0; | |
// Traverse images and display metadata info | |
foreach (var img in body.Images) | |
{ |
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/Openize.Words">Openize.Words</a>. | |
// Load the Word Document | |
var doc = new Openize.Words.Document($"WordImgs.docx"); | |
var body = new Openize.Words.Body(doc); | |
foreach (var img in body.Images) | |
{ | |
var skBitmap = SkiaSharp.SKBitmap.Decode(img.ImageData); | |
var skImage = SkiaSharp.SKImage.FromBitmap(skBitmap); |
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/Openize.Words">Openize.Words</a>. | |
// Initialize a new word document with the default template | |
var doc = new Openize.Words.Document(); | |
System.Console.WriteLine("Word Document with default template initialized"); | |
// Initialize the body with the new document | |
var body = new Openize.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/Openize.Words">Openize.Words</a>. | |
// Load the Word Document | |
var doc = new Openize.Words.Document($"WordTables.docx"); | |
var body = new Openize.Words.Body(doc); | |
var tables = body.Tables; | |
var tableNumber = 0; | |
var rowNumber = 0; |
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($"WordTables.docx"); | |
var body = new FileFormat.Words.Body(doc); | |
var tables = body.Tables; | |
foreach (var table in tables) | |
{ |
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/Openize.Words">Openize.Words</a> | |
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 |
OlderNewer