Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@ static void Main()
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
// Open an existing Word document
WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx);
//Initialize the default fallback fonts collection.
document.FontSettings.FallbackFonts.InitializeDefault();
DocIORenderer renderer = new DocIORenderer();
//Convert the entire Word document to images.
Stream[] imageStreams = document.RenderAsImages();
for (int i = 0; i < imageStreams.Length; i++)
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx))
{
//Save the image stream as file.
string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg");
using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write))
//Initialize the default fallback fonts collection.
document.FontSettings.FallbackFonts.InitializeDefault();
using (DocIORenderer renderer = new DocIORenderer())
{
imageStreams[i].CopyTo(fileStreamOutput);
//Convert the entire Word document to images.
Stream[] imageStreams = document.RenderAsImages();
for (int i = 0; i < imageStreams.Length; i++)
{
//Save the image stream as file.
string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg");
using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write))
{
imageStreams[i].CopyTo(fileStreamOutput);
}
}
}
}
stopwatch.Stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,27 @@ static void Main()
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
// Open an existing Word document
WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx);
//Hooks the font substitution event
document.FontSettings.SubstituteFont += FontSettings_SubstituteFont;
DocIORenderer renderer = new DocIORenderer();
//Convert the entire Word document to images.
Stream[] imageStreams = document.RenderAsImages();
//Unhooks the font substitution event after converting to PDF
document.FontSettings.SubstituteFont -= FontSettings_SubstituteFont;
for (int i = 0; i < imageStreams.Length; i++)
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx))
{
//Save the image stream as file.
string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg");
using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write))
//Hooks the font substitution event
document.FontSettings.SubstituteFont += FontSettings_SubstituteFont;
using (DocIORenderer renderer = new DocIORenderer())
{
imageStreams[i].CopyTo(fileStreamOutput);
}
}
//Convert the entire Word document to images.
Stream[] imageStreams = document.RenderAsImages();
//Unhooks the font substitution event after converting to PDF
document.FontSettings.SubstituteFont -= FontSettings_SubstituteFont;
for (int i = 0; i < imageStreams.Length; i++)
{
//Save the image stream as file.
string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg");
using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write))
{
imageStreams[i].CopyTo(fileStreamOutput);
}
}
}
}
stopwatch.Stop();
Console.WriteLine($"Word To Image processed in {stopwatch.Elapsed.TotalSeconds} seconds");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@ static void Main()
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
// Open an existing Word document
WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx);
DocIORenderer renderer = new DocIORenderer();
//Sets true to embed fonts True
renderer.Settings.EmbedFonts = true;
//Convert the entire Word document to images.
Stream[] imageStreams = document.RenderAsImages();
for (int i = 0; i < imageStreams.Length; i++)
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx))
{
//Save the image stream as file.
string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg");
using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write))
using (DocIORenderer renderer = new DocIORenderer())
{
imageStreams[i].CopyTo(fileStreamOutput);
//Convert the entire Word document to images.
Stream[] imageStreams = document.RenderAsImages();
for (int i = 0; i < imageStreams.Length; i++)
{
//Save the image stream as file.
string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg");
using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write))
{
imageStreams[i].CopyTo(fileStreamOutput);
}
}
}
}
stopwatch.Stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ static void Main()
//Creates an instance of DocIORenderer.
using (DocIORenderer renderer = new DocIORenderer())
{
//Sets true to embed fonts True
renderer.Settings.EmbedFonts = true;
//Converts Word document into PDF document.
using (PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,26 @@ static void Main()
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
// Open an existing Word document
WordDocument document = new WordDocument(fileStreamPath,FormatType.Docx);
DocIORenderer renderer = new DocIORenderer();
//Convert the entire Word document to images.
Stream[] imageStreams = document.RenderAsImages();
for (int i = 0; i < imageStreams.Length; i++)
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx))
{
//Save the image stream as file.
string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg");
using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write))
using (DocIORenderer renderer = new DocIORenderer())
{
imageStreams[i].CopyTo(fileStreamOutput);
}
//Convert the entire Word document to images.
Stream[] imageStreams = document.RenderAsImages();
for (int i = 0; i < imageStreams.Length; i++)
{
//Save the image stream as file.
string imagePath = Path.Combine(Path.GetFullPath(@"Output/Images"), $"WordToImage_{i + 1}.jpg");
using (FileStream fileStreamOutput = new(imagePath, FileMode.Create, FileAccess.Write))
{
imageStreams[i].CopyTo(fileStreamOutput);
}
}
}
}
stopwatch.Stop();
Console.WriteLine($"Word To Image processed in {stopwatch.Elapsed.TotalSeconds} seconds");
}
}
}
catch (Exception ex)
{
Expand Down
Loading