Skip to content

Commit 20cc144

Browse files
Added UpdateDocumentFields Sample
1 parent 2775198 commit 20cc144

5 files changed

Lines changed: 83 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}") = "UpdateDocumentFields-Word-document", "UpdateDocumentFields-Word-document\UpdateDocumentFields-Word-document.csproj", "{96910988-4F2D-04D6-F614-705FDC85FB12}"
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+
{96910988-4F2D-04D6-F614-705FDC85FB12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{96910988-4F2D-04D6-F614-705FDC85FB12}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{96910988-4F2D-04D6-F614-705FDC85FB12}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{96910988-4F2D-04D6-F614-705FDC85FB12}.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 = {3100F9EC-04F8-4CA7-8934-646C451CEA37}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using System.Diagnostics;
4+
5+
namespace UpdateDocumentFields_Word_document
6+
{
7+
class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
//Load the document.
12+
using (FileStream inputFileStream = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read))
13+
{
14+
//Load the word document.
15+
using (WordDocument wordDocument = new WordDocument(inputFileStream, FormatType.Docx))
16+
{
17+
Stopwatch stopwatch = new Stopwatch();
18+
stopwatch.Start();
19+
//Updates the document fields.
20+
wordDocument.UpdateDocumentFields();
21+
stopwatch.Stop();
22+
Console.WriteLine($"Time taken for update fields in word Document: " + stopwatch.Elapsed.TotalSeconds);
23+
//Create file stream
24+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
25+
{
26+
//Save the Word document to file stream
27+
wordDocument.Save(outputFileStream, FormatType.Docx);
28+
}
29+
}
30+
}
31+
}
32+
}
33+
}
34+
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>UpdateDocumentFields_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)