Skip to content

Commit 2775198

Browse files
Added Reject All sample
1 parent bc36ef2 commit 2775198

5 files changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36915.13 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reject-All-Changes-Word-document", "Reject-All-Changes-Word-document\Reject-All-Changes-Word-document.csproj", "{01568B59-31BF-D702-B31D-69D4DAC216B0}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{01568B59-31BF-D702-B31D-69D4DAC216B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{01568B59-31BF-D702-B31D-69D4DAC216B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{01568B59-31BF-D702-B31D-69D4DAC216B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{01568B59-31BF-D702-B31D-69D4DAC216B0}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {5EFDAFE0-DCB1-46E4-85CA-FFAA44ED9D97}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using System.Diagnostics;
4+
using System.Reflection.Metadata;
5+
using System.Xml.Linq;
6+
7+
namespace Reject_All_Changes_Word_document
8+
{
9+
class Program
10+
{
11+
static void Main(string[] args)
12+
{
13+
//Load the document.
14+
using (FileStream inputFileStream = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read))
15+
{
16+
//Load the word document.
17+
using (WordDocument wordDocument = new WordDocument(inputFileStream, FormatType.Docx))
18+
{
19+
Stopwatch stopwatch = new Stopwatch();
20+
stopwatch.Start();
21+
//Reject all the tracked changes revisions in the Word document
22+
if (wordDocument.HasChanges)
23+
wordDocument.Revisions.RejectAll();
24+
stopwatch.Stop();
25+
Console.WriteLine($"Time taken for reject all changes in word Document: " + stopwatch.Elapsed.TotalSeconds);
26+
//Create file stream
27+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
28+
{
29+
//Save the Word document to file stream
30+
wordDocument.Save(outputFileStream, FormatType.Docx);
31+
}
32+
}
33+
}
34+
}
35+
}
36+
}
37+
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+
<RootNamespace>Reject_All_Changes_Word_document</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.DocIO.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+
</Project>

0 commit comments

Comments
 (0)