Skip to content

Commit e6e86bd

Browse files
Merge pull request #143 from SyncfusionExamples/937636
937636 Added verify digital signature in existing PDF document and dash pattern
2 parents 12275f9 + 5881ed3 commit e6e86bd

File tree

8 files changed

+143
-0
lines changed

8 files changed

+143
-0
lines changed
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}") = "Verify-digital-sign-in-existing-PDF", "Verify-digital-sign-in-existing-PDF\Verify-digital-sign-in-existing-PDF.csproj", "{3DD425D8-40B2-4D5E-8ADD-66522B701503}"
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+
{3DD425D8-40B2-4D5E-8ADD-66522B701503}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{3DD425D8-40B2-4D5E-8ADD-66522B701503}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{3DD425D8-40B2-4D5E-8ADD-66522B701503}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{3DD425D8-40B2-4D5E-8ADD-66522B701503}.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: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.IO;
3+
using System.Reflection.Metadata;
4+
using Syncfusion.Pdf.Parsing;
5+
6+
7+
// Open the signed PDF file for reading
8+
using (FileStream inputFileStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read))
9+
{
10+
// Load the PDF document
11+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(inputFileStream);
12+
13+
// Check if the document has a form (which would contain signature fields)
14+
if (loadedDocument.Form == null)
15+
{
16+
Console.WriteLine("No signature fields found in the document.");
17+
return;
18+
}
19+
20+
// Iterate through all fields in the form
21+
foreach (var field in loadedDocument.Form.Fields)
22+
{
23+
// Check if the field is a signature field
24+
if (field is PdfLoadedSignatureField signatureField)
25+
{
26+
// Determine whether the signature field is signed or not
27+
string status = signatureField.IsSigned ? "Signed" : "UnSigned";
28+
29+
// Output the result for each signature field
30+
Console.WriteLine($"Signature Field {signatureField.Name} is : {status}");
31+
}
32+
}
33+
//Close the document
34+
loadedDocument.Close(true);
35+
}
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>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Verify_digital_sign_in_existing_PDF</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.Pdf.Net.Core" 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}") = "Dash-pattern-in-shapes", "Dash-pattern-in-shapes\Dash-pattern-in-shapes.csproj", "{DF549026-34A6-4622-9A1D-8C12AE115DAE}"
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+
{DF549026-34A6-4622-9A1D-8C12AE115DAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{DF549026-34A6-4622-9A1D-8C12AE115DAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{DF549026-34A6-4622-9A1D-8C12AE115DAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{DF549026-34A6-4622-9A1D-8C12AE115DAE}.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>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Dash_pattern_in_shapes</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
</Project>

Shapes/Dash-pattern-in-shapes/.NET/Dash-pattern-in-shapes/Output/gitkeep.txt

Whitespace-only changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Syncfusion.Pdf.Graphics;
2+
using Syncfusion.Pdf;
3+
using Syncfusion.Drawing;
4+
5+
// Create a new PDF document
6+
PdfDocument document = new PdfDocument();
7+
8+
// Add a page to the document
9+
PdfPage page = document.Pages.Add();
10+
11+
// Create a PdfGraphics object to draw on the page
12+
PdfGraphics graphics = page.Graphics;
13+
14+
// Create a custom dashed line pattern (5-point dash, 2-point gap)
15+
float[] dashPattern = { 5, 2 }; // Dash length, gap length
16+
17+
// Create a PdfPen with the dash pattern and color
18+
PdfPen dashPen = new PdfPen(PdfBrushes.Black, 2); // 2 is the line width
19+
20+
// Set the DashStyle to Custom before applying DashPattern
21+
dashPen.DashStyle = PdfDashStyle.Custom; // Use Custom style to enable DashPattern
22+
dashPen.DashPattern = dashPattern;
23+
24+
// Draw a line with the custom dash pattern
25+
graphics.DrawLine(dashPen, new Syncfusion.Drawing.PointF(10, 10), new PointF(300, 10));
26+
27+
//Create file stream.
28+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
29+
{
30+
//Save the PDF document to file stream.
31+
document.Save(outputFileStream);
32+
}
33+
//Close the document.
34+
document.Close(true);

0 commit comments

Comments
 (0)