Skip to content

Commit d195f12

Browse files
authored
Merge pull request #65 from SyncfusionExamples/WPF-939396
939396 - How to differentiate textbox field from signature field in WPF PdfViewer
2 parents 0230154 + 72ad0eb commit d195f12

15 files changed

+546
-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.7" />
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="IdentifySignatureFormField.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:IdentifySignatureFormField"
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 IdentifySignatureFormField
4+
{
5+
/// <summary>
6+
/// Interaction logic for App.xaml
7+
/// </summary>
8+
public partial class App : Application
9+
{
10+
}
11+
}
Binary file not shown.
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>{2E89EC9E-B1AF-4E68-9365-1FA15D2D9102}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>IdentifySignatureFormField</RootNamespace>
10+
<AssemblyName>IdentifySignatureFormField</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: 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.9.34622.214
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentifySignatureFormField", "IdentifySignatureFormField.csproj", "{2E89EC9E-B1AF-4E68-9365-1FA15D2D9102}"
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+
{2E89EC9E-B1AF-4E68-9365-1FA15D2D9102}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{2E89EC9E-B1AF-4E68-9365-1FA15D2D9102}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{2E89EC9E-B1AF-4E68-9365-1FA15D2D9102}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{2E89EC9E-B1AF-4E68-9365-1FA15D2D9102}.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 = {F7B6813F-0269-405B-AA4B-B5C0DEF1A65E}
24+
EndGlobalSection
25+
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}") = "IdentifySignatureFormField_NET", "IdentifySignatureFormField_NET.csproj", "{C587E488-1F72-4257-AA61-E1F9098F5C7D}"
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+
{C587E488-1F72-4257-AA61-E1F9098F5C7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{C587E488-1F72-4257-AA61-E1F9098F5C7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{C587E488-1F72-4257-AA61-E1F9098F5C7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{C587E488-1F72-4257-AA61-E1F9098F5C7D}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Window xmlns:PdfViewer="clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF" x:Class="IdentifySignatureFormField.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:IdentifySignatureFormField"
7+
mc:Ignorable="d"
8+
Title="MainWindow" WindowState="Maximized">
9+
<Grid>
10+
<PdfViewer:PdfViewerControl x:Name="pdfViewer"/>
11+
</Grid>
12+
</Window>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using Syncfusion.Pdf.Parsing;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Windows;
5+
using System.Windows.Controls;
6+
7+
namespace IdentifySignatureFormField
8+
{
9+
/// <summary>
10+
/// Interaction logic for MainWindow.xaml
11+
/// </summary>
12+
public partial class MainWindow : Window
13+
{
14+
string filePath;
15+
public List<String> NameList;
16+
public MainWindow()
17+
{
18+
InitializeComponent();
19+
#if NETCOREAPP
20+
filePath = @"../../../Data/FormFields.pdf";
21+
#else
22+
filePath = @"../../Data/FormFields.pdf";
23+
#endif
24+
//Load the PDF
25+
pdfViewer.Load(filePath);
26+
pdfViewer.DocumentLoaded += pdfViewer_DocumentLoaded;
27+
pdfViewer.DocumentUnloaded += pdfViewer_DocumentUnloaded;
28+
pdfViewer.FormFieldClicked += PdfViewer_FormFieldClicked;
29+
}
30+
/// <summary>
31+
/// Triggered whenever the formField is clicked
32+
/// </summary>
33+
private void PdfViewer_FormFieldClicked(object sender, Syncfusion.Windows.PdfViewer.FormFieldClickedEventArgs args)
34+
{
35+
if (args.FormField is TextBox)
36+
{
37+
//Typecast the `FormField` property to `System.Windows.Controls.TextBox`
38+
TextBox text = args.FormField as TextBox;
39+
if(NameList.Contains(text.Name))
40+
{
41+
MessageBox.Show("Signature Form Field Clicked");
42+
}
43+
}
44+
}
45+
46+
/// <summary>
47+
/// Triggered whenever the PDF document has finished loading.
48+
/// </summary>
49+
private void pdfViewer_DocumentLoaded(object sender, EventArgs args)
50+
{
51+
NameList = new List<String>();
52+
PdfLoadedDocument document = new PdfLoadedDocument(filePath);
53+
//Get the loaded form.
54+
PdfLoadedForm loadedForm = document.Form;
55+
for (int i = 0; i < loadedForm.Fields.Count; i++)
56+
{
57+
if (loadedForm.Fields[i] is PdfLoadedSignatureField)
58+
{
59+
NameList.Add(loadedForm.Fields[i].Name);
60+
}
61+
}
62+
}
63+
/// <summary>
64+
/// "Triggered whenever the PDF document has unloaded from PDF Viewer control."
65+
/// </summary>
66+
private void pdfViewer_DocumentUnloaded(object sender, EventArgs e)
67+
{
68+
NameList.Clear();
69+
}
70+
}
71+
}

0 commit comments

Comments
 (0)