Skip to content

Commit 2ce4d23

Browse files
Merge pull request #522 from SyncfusionExamples/1006383_Performacne_sample
1006383-Added Performance Benchmark samples in WordToPDF
2 parents 4914a98 + 1a5e194 commit 2ce4d23

81 files changed

Lines changed: 1016 additions & 50 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Accessible-PDF/Accessible-PDF.csproj" />
3+
</Solution>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Accessible_PDF</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="Data\Input.docx">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
<None Update="Output\.gitkeep">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</None>
22+
</ItemGroup>
23+
24+
</Project>
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using Syncfusion.DocIORenderer;
4+
using Syncfusion.Pdf;
5+
using System.Diagnostics;
6+
7+
class Program
8+
{
9+
static void Main()
10+
{
11+
Stopwatch stopwatch = Stopwatch.StartNew();
12+
try
13+
{
14+
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
15+
{
16+
// Open and convert Word to PDF
17+
using (WordDocument wordDocument = new WordDocument(fileStreamPath, FormatType.Docx))
18+
{
19+
//Creates an instance of DocIORenderer.
20+
using (DocIORenderer renderer = new DocIORenderer())
21+
{
22+
//Sets true to preserve document structured tags in the converted PDF document
23+
renderer.Settings.AutoTag = true;
24+
//Converts Word document into PDF document.
25+
using (PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument))
26+
{
27+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.pdf"), FileMode.Create, FileAccess.ReadWrite))
28+
{
29+
pdfDocument.Save(outputFileStream);
30+
}
31+
}
32+
}
33+
}
34+
stopwatch.Stop();
35+
Console.WriteLine($"Input.docx taken time to convert as PDF: {stopwatch.Elapsed.TotalSeconds} seconds");
36+
}
37+
}
38+
catch (Exception ex)
39+
{
40+
Console.WriteLine($"Error processing Input.docx: {ex.Message}");
41+
}
42+
}
43+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Comments/Comments.csproj" />
3+
</Solution>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="*" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<None Update="Data\Input.docx">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</None>
18+
<None Update="Output\.gitkeep">
19+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
20+
</None>
21+
</ItemGroup>
22+
23+
</Project>
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using Syncfusion.DocIORenderer;
4+
using Syncfusion.Pdf;
5+
using System.Diagnostics;
6+
7+
class Program
8+
{
9+
static void Main()
10+
{
11+
Stopwatch stopwatch = Stopwatch.StartNew();
12+
try
13+
{
14+
using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
15+
{
16+
// Open and convert Word to PDF
17+
using (WordDocument wordDocument = new WordDocument(fileStreamPath, FormatType.Docx))
18+
{
19+
//Sets ShowInBalloons to render a document comments in converted PDF document.
20+
wordDocument.RevisionOptions.CommentDisplayMode = CommentDisplayMode.ShowInBalloons;
21+
//Creates an instance of DocIORenderer.
22+
using (DocIORenderer renderer = new DocIORenderer())
23+
{
24+
//Converts Word document into PDF document.
25+
using (PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument))
26+
{
27+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.pdf"), FileMode.Create, FileAccess.ReadWrite))
28+
{
29+
pdfDocument.Save(outputFileStream);
30+
}
31+
}
32+
}
33+
}
34+
stopwatch.Stop();
35+
Console.WriteLine($"Input.docx taken time to convert as PDF: {stopwatch.Elapsed.TotalSeconds} seconds");
36+
}
37+
}
38+
catch (Exception ex)
39+
{
40+
Console.WriteLine($"Error processing Input.docx: {ex.Message}");
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)