Skip to content

Commit d464be5

Browse files
authored
Merge pull request #64 from SyncfusionExamples/WPF-898741
898741 - How to check whether all the signature fields in the PDF document were signed in PdfViewer?
2 parents 4d8e268 + 6daebce commit d464be5

15 files changed

+578
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
5+
</startup>
6+
</configuration>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="CheckPDFSignatureformFieldsSigned.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:CheckPDFSignatureformFieldsSigned"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Windows;
2+
3+
namespace CheckPDFSignatureformFieldsSigned
4+
{
5+
/// <summary>
6+
/// Interaction logic for App.xaml
7+
/// </summary>
8+
public partial class App : Application
9+
{
10+
}
11+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{AD69FFC8-4BCA-4001-8F27-155F5DFE7179}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>CheckPDFSignatureformFieldsSigned</RootNamespace>
10+
<AssemblyName>CheckPDFSignatureformFieldsSigned</AssemblyName>
11+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<WarningLevel>4</WarningLevel>
15+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
16+
<Deterministic>true</Deterministic>
17+
<TargetFrameworkProfile />
18+
</PropertyGroup>
19+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
20+
<PlatformTarget>AnyCPU</PlatformTarget>
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Debug\</OutputPath>
25+
<DefineConstants>DEBUG;TRACE</DefineConstants>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<PlatformTarget>AnyCPU</PlatformTarget>
31+
<DebugType>pdbonly</DebugType>
32+
<Optimize>true</Optimize>
33+
<OutputPath>bin\Release\</OutputPath>
34+
<DefineConstants>TRACE</DefineConstants>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<PackageReference Include="Syncfusion.PdfViewer.WPF" Version="*" />
40+
<Reference Include="System" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Drawing" />
43+
<Reference Include="System.Xml" />
44+
<Reference Include="Microsoft.CSharp" />
45+
<Reference Include="System.Core" />
46+
<Reference Include="System.Xml.Linq" />
47+
<Reference Include="System.Data.DataSetExtensions" />
48+
<Reference Include="System.Net.Http" />
49+
<Reference Include="System.Xaml">
50+
<RequiredTargetFramework>4.0</RequiredTargetFramework>
51+
</Reference>
52+
<Reference Include="WindowsBase" />
53+
<Reference Include="PresentationCore" />
54+
<Reference Include="PresentationFramework" />
55+
</ItemGroup>
56+
<ItemGroup>
57+
<ApplicationDefinition Include="App.xaml">
58+
<Generator>MSBuild:Compile</Generator>
59+
<SubType>Designer</SubType>
60+
</ApplicationDefinition>
61+
<Page Include="MainWindow.xaml">
62+
<Generator>MSBuild:Compile</Generator>
63+
<SubType>Designer</SubType>
64+
</Page>
65+
<Compile Include="App.xaml.cs">
66+
<DependentUpon>App.xaml</DependentUpon>
67+
<SubType>Code</SubType>
68+
</Compile>
69+
<Compile Include="MainWindow.xaml.cs">
70+
<DependentUpon>MainWindow.xaml</DependentUpon>
71+
<SubType>Code</SubType>
72+
</Compile>
73+
</ItemGroup>
74+
<ItemGroup>
75+
<Compile Include="Properties\AssemblyInfo.cs">
76+
<SubType>Code</SubType>
77+
</Compile>
78+
<Compile Include="Properties\Resources.Designer.cs">
79+
<AutoGen>True</AutoGen>
80+
<DesignTime>True</DesignTime>
81+
<DependentUpon>Resources.resx</DependentUpon>
82+
</Compile>
83+
<Compile Include="Properties\Settings.Designer.cs">
84+
<AutoGen>True</AutoGen>
85+
<DependentUpon>Settings.settings</DependentUpon>
86+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
87+
</Compile>
88+
<EmbeddedResource Include="Properties\Resources.resx">
89+
<Generator>ResXFileCodeGenerator</Generator>
90+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
91+
</EmbeddedResource>
92+
<None Include="Properties\Settings.settings">
93+
<Generator>SettingsSingleFileGenerator</Generator>
94+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
95+
</None>
96+
</ItemGroup>
97+
<ItemGroup>
98+
<None Include="App.config" />
99+
</ItemGroup>
100+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
101+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35707.178 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CheckPDFSignatureformFieldsSigned", "CheckPDFSignatureformFieldsSigned.csproj", "{AD69FFC8-4BCA-4001-8F27-155F5DFE7179}"
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+
{AD69FFC8-4BCA-4001-8F27-155F5DFE7179}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{AD69FFC8-4BCA-4001-8F27-155F5DFE7179}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{AD69FFC8-4BCA-4001-8F27-155F5DFE7179}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{AD69FFC8-4BCA-4001-8F27-155F5DFE7179}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net8.0-windows</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<UseWPF>true</UseWPF>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.PdfViewer.WPF" Version="*" />
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35707.178 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CheckPDFSignatureformFieldsSigned_NET", "CheckPDFSignatureformFieldsSigned_NET.csproj", "{0D4D6E0B-9850-4FBD-9933-3904EC90CFAC}"
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+
{0D4D6E0B-9850-4FBD-9933-3904EC90CFAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{0D4D6E0B-9850-4FBD-9933-3904EC90CFAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{0D4D6E0B-9850-4FBD-9933-3904EC90CFAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{0D4D6E0B-9850-4FBD-9933-3904EC90CFAC}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Binary file not shown.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Window x:Class="CheckPDFSignatureformFieldsSigned.MainWindow"
2+
xmlns:PdfViewer="clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:local="clr-namespace:CheckPDFSignatureformFieldsSigned"
8+
mc:Ignorable="d"
9+
Title="MainWindow" WindowState="Maximized">
10+
<Grid>
11+
<Grid.RowDefinitions>
12+
<RowDefinition Height="50" />
13+
<RowDefinition Height="*" />
14+
</Grid.RowDefinitions>
15+
<PdfViewer:PdfViewerControl
16+
x:Name="pdfViewer"
17+
Grid.Row="1"/>
18+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="5" Grid.Row="0">
19+
<Button x:Name="validateSignature"
20+
Width="60"
21+
Content="Validate"
22+
Margin="5"
23+
Click="validateSignature_Click"/>
24+
</StackPanel>
25+
</Grid>
26+
</Window>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using Syncfusion.Pdf.Interactive;
2+
using Syncfusion.Pdf.Parsing;
3+
using System.Windows;
4+
5+
namespace CheckPDFSignatureformFieldsSigned
6+
{
7+
/// <summary>
8+
/// Interaction logic for MainWindow.xaml
9+
/// </summary>
10+
public partial class MainWindow : Window
11+
{
12+
string filepath;
13+
public MainWindow()
14+
{
15+
#if NETCOREAPP
16+
17+
filepath = @"../../../Data/Doc_with_sign.pdf";
18+
#else
19+
filepath = @"../../Data/Doc_with_sign.pdf";
20+
#endif
21+
//Load the PDF document
22+
InitializeComponent();
23+
pdfViewer.Load(filepath);
24+
}
25+
26+
/// <summary>
27+
/// Validate Is all the signature formField are signed
28+
/// </summary>
29+
private void validateSignature_Click(object sender, RoutedEventArgs e)
30+
{
31+
bool isSigned = false;
32+
PdfLoadedDocument loadedDocument = pdfViewer.LoadedDocument;
33+
if (loadedDocument.Form != null && loadedDocument.Form.Fields.Count > 0)
34+
{
35+
foreach (var field in loadedDocument.Form.Fields)
36+
{
37+
if (field is PdfLoadedSignatureField)
38+
{
39+
PdfLoadedSignatureField signatureField = field as PdfLoadedSignatureField;
40+
if (signatureField.Page != null && signatureField.Page.Annotations.Count > 0)
41+
{
42+
foreach (var annotation in signatureField.Page.Annotations)
43+
{
44+
if (annotation is PdfLoadedInkAnnotation)
45+
{
46+
PdfLoadedInkAnnotation signature = annotation as PdfLoadedInkAnnotation;
47+
if (signature.Name != signatureField.Name)
48+
{
49+
isSigned = false;
50+
}
51+
else
52+
{
53+
isSigned = true;
54+
break;
55+
}
56+
}
57+
else if (annotation is PdfInkAnnotation)
58+
{
59+
PdfInkAnnotation signature = annotation as PdfInkAnnotation;
60+
if (signature.Name != signatureField.Name)
61+
{
62+
isSigned = false;
63+
}
64+
else
65+
{
66+
isSigned = true;
67+
break;
68+
}
69+
}
70+
}
71+
if (!isSigned)
72+
{
73+
break;
74+
}
75+
}
76+
else
77+
{
78+
isSigned = false;
79+
break;
80+
}
81+
}
82+
}
83+
84+
if (!isSigned)
85+
{
86+
MessageBox.Show("There is some signature required");
87+
}
88+
else
89+
{
90+
MessageBox.Show("All signatures fields are signed!");
91+
}
92+
}
93+
}
94+
}
95+
}

0 commit comments

Comments
 (0)