Skip to content

Commit 45065a7

Browse files
committed
263554: Added proper code example for signature field in PDF document
1 parent 69e7e06 commit 45065a7

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed
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.36616.10 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Add-signature-field-to-existing-PDF", "Add-signature-field-to-existing-PDF\Add-signature-field-to-existing-PDF.csproj", "{C2328A0D-96EC-4E23-A422-097276BB435F}"
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+
{C2328A0D-96EC-4E23-A422-097276BB435F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{C2328A0D-96EC-4E23-A422-097276BB435F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{C2328A0D-96EC-4E23-A422-097276BB435F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{C2328A0D-96EC-4E23-A422-097276BB435F}.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 = {8BB2F11E-8503-457F-B8B6-D597ED84F394}
24+
EndGlobalSection
25+
EndGlobal
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>Add_signature_field_to_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>

Digital Signature/Add-signature-field-to-existing-PDF/.NET/Add-signature-field-to-existing-PDF/Output/gitkeep.txt

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Syncfusion.Pdf;
2+
using Syncfusion.Pdf.Interactive;
3+
using Syncfusion.Pdf.Parsing;
4+
using Syncfusion.Drawing;
5+
6+
// Load the existing PDF document
7+
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(Path.GetFullPath(@"../../../Data/Input.pdf")))
8+
{
9+
// Ensure the document has a form; create one if it doesn't exist
10+
if (loadedDocument.Form == null)
11+
loadedDocument.CreateForm();
12+
// Load the first page of the PDF
13+
PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage;
14+
// Create a new PDF signature field on the loaded page
15+
PdfSignatureField signatureField = new PdfSignatureField(loadedPage, "Signature");
16+
// Set properties for the signature field (position and tooltip)
17+
signatureField.Bounds = new RectangleF(100, 300, 90, 20);
18+
signatureField.ToolTip = "Signature";
19+
// Add the signature field to the form in the existing document
20+
loadedDocument.Form.Fields.Add(signatureField);
21+
// Save the PDF document
22+
loadedDocument.Save(Path.GetFullPath(@"../../../Output/Output.pdf"));
23+
}

0 commit comments

Comments
 (0)