Skip to content

Commit 592792e

Browse files
committed
1006681: Added sample code for group signature for all pages.
1 parent c28924a commit 592792e

File tree

7 files changed

+67
-0
lines changed

7 files changed

+67
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Group-signature-for-all-pages/Group-signature-for-all-pages.csproj" />
3+
</Solution>
Binary file not shown.
Binary file not shown.
13.7 KB
Loading
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>Group_signature_for_all_pages</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/Group-signature-for-all-pages/.NET/Group-signature-for-all-pages/Output/gitkeep.txt

Whitespace-only changes.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using Syncfusion.Drawing;
2+
using Syncfusion.Pdf;
3+
using Syncfusion.Pdf.Graphics;
4+
using Syncfusion.Pdf.Parsing;
5+
using Syncfusion.Pdf.Security;
6+
7+
// Load the PDF document
8+
using (PdfLoadedDocument document = new PdfLoadedDocument(Path.GetFullPath(@"Data/Input.pdf")))
9+
{
10+
// Ensure the form (AcroForm) exists before adding signature fields
11+
if (document.Form == null)
12+
document.CreateForm();
13+
// Turn off automatic field naming if you want full control over field names
14+
document.Form.FieldAutoNaming = false;
15+
// Create certificate from PFX file
16+
PdfCertificate pdfCert = new PdfCertificate(Path.GetFullPath(@"Data/PDF.pfx"), "syncfusion");
17+
// Load the signature image once
18+
using FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/Signature.png"), FileMode.Open, FileAccess.Read);
19+
PdfBitmap signatureImage = new PdfBitmap(imageStream);
20+
// use this flag. Set to 'false' to draw for each signature field
21+
bool appearanceApplied = false;
22+
// Iterate pages and add a signature field to each page
23+
for (int i = 0; i < document.Pages.Count; i++)
24+
{
25+
// Get current page
26+
PdfPageBase page = document.Pages[i];
27+
// Create a signature field on the page using the certificate
28+
PdfSignature signature = new PdfSignature(document, page, pdfCert, "Signature");
29+
// Position & size of the signature field
30+
signature.Bounds = new RectangleF(new PointF(10, 10), new SizeF(100, 60));
31+
// Optional metadata shown in the signature properties
32+
signature.ContactInfo = "johndoe@owned.us";
33+
signature.LocationInfo = "Honolulu, Hawaii";
34+
signature.Reason = "I am author of this document.";
35+
// Draw the signature image into the signature appearance once
36+
if (!appearanceApplied)
37+
{
38+
signature.Appearance.Normal.Graphics.DrawImage(
39+
signatureImage,
40+
0, 0,
41+
signature.Bounds.Width,
42+
signature.Bounds.Height
43+
);
44+
appearanceApplied = true;
45+
}
46+
}
47+
// Save the PDF document
48+
document.Save(Path.GetFullPath(@"Output/Output.pdf"));
49+
}

0 commit comments

Comments
 (0)