Skip to content

Commit c327ae4

Browse files
authored
Merge pull request #552 from telerik/new-kb-create-pdf-with-empty-signature-field-radpdfprocessing-d7a5d3952f1d4138b4a93177f6528974
Added new kb article create-pdf-with-empty-signature-field-radpdfprocessing
2 parents 16b983b + 4037b36 commit c327ae4

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Creating a PDF Document with an Empty Signature Field Using RadPdfProcessing
3+
description: Learn how to create a PDF document with an empty signature field using the PdfProcessing library of the Document Processing Libraries.
4+
type: how-to
5+
page_title: How to Add an Empty Signature Field to a PDF Document in RadPdfProcessing
6+
slug: create-pdf-with-empty-signature-field-radpdfprocessing
7+
tags: pdfprocessing, document, processing, pdf, signature, field, empty, unsigned
8+
res_type: kb
9+
ticketid: 1687482
10+
---
11+
12+
## Environment
13+
14+
| Version | Product | Author |
15+
| ---- | ---- | ---- |
16+
| 2025.1.205| RadPdfProcessing |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)|
17+
18+
## Description
19+
Learn how to create a PDF document with an empty signature field, which allows signing the document in any PDF viewer. The document should only contain the empty signature field, and when opened in a viewer, it should provide the option to sign.
20+
21+
![UnSigned PDF](images/unsigned-pdf.png)
22+
23+
## Solution
24+
25+
To create a PDF document with an empty [signature field]({%slug radpdfprocessing-model-interactive-forms-form-fields-signaturefield%}) using [RadPdfProcessing]({%slug radpdfprocessing-overview%}), follow these steps:
26+
27+
1. Create a new PDF document and add a page.
28+
2. Define the rectangle area for the [signature field]({%slug radpdfprocessing-model-interactive-forms-form-fields-signaturefield%}).
29+
3. Create a signature field with a unique name.
30+
4. Add a [widget]({%slug radpdfprocessing-model-annotations-widgets%}) to the signature field and set its size and position.
31+
5. Add the widget to the page's annotations.
32+
6. Save the document to a file.
33+
34+
Here is the complete code snippet:
35+
36+
```csharp
37+
// Create a new PDF document and a page
38+
RadFixedDocument document = new RadFixedDocument();
39+
RadFixedPage page = document.Pages.AddPage();
40+
41+
// Define the rectangle for the signature field
42+
Rect signatureRect = new Rect(50, 700, 200, 50);
43+
44+
// Create the signature field (do not assign a certificate or signature)
45+
SignatureField signatureField = document.AcroForm.FormFields.AddSignature("SignatureFieldUniqueName");
46+
47+
// Add a widget for the signature field and set its position and size
48+
SignatureWidget signatureWidget = signatureField.Widgets.AddWidget();
49+
signatureWidget.Rect = signatureRect;
50+
51+
// Add the widget to the page's annotations
52+
page.Annotations.Add(signatureWidget);
53+
54+
// Save the document
55+
string filePath = "EmptySignatureWidget.pdf";
56+
File.Delete(filePath);
57+
using (var output = new System.IO.FileStream(filePath, System.IO.FileMode.Create, System.IO.FileAccess.Write))
58+
{
59+
new PdfFormatProvider().Export(document, output, TimeSpan.FromSeconds(10));
60+
}
61+
62+
// Open the PDF
63+
Process.Start(new ProcessStartInfo() { FileName = filePath, UseShellExecute = true });
64+
```
65+
66+
### Notes
67+
- The code creates an empty signature field without assigning a certificate or signature.
68+
- The resulting PDF can be opened in any PDF viewer that supports signing, allowing the user to sign the document.
69+
70+
## See Also
71+
72+
- [Digital Signature]({%slug radpdfprocessing-features-digital-signature%})
73+
- [Signature Field]({%slug radpdfprocessing-model-interactive-forms-form-fields-signaturefield%})
74+
- [Signing an Unsigned PDF Document that Contains a Signature Field with RadPdfProcessing]({%slug pdfprocessing-sign-an-unsigned-pdf%})
3.12 KB
Loading

knowledge-base/pdfprocessing-sign-an-unsigned-pdf.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,4 @@ Remember to adjust the file paths, certificate details, and specific document re
128128
- [RadPdfProcessing]({%slug radpdfprocessing-overview%})
129129
- [Form Fields concept in RadPdfProcessing]({%slug radpdfprocessing-model-interactive-forms-form-fields%})
130130
- [Digital Signature in RadPdfProcessing]({%slug radpdfprocessing-features-digital-signature%})
131+
- [Creating a PDF Document with an Empty Signature Field Using RadPdfProcessing]({%slug create-pdf-with-empty-signature-field-radpdfprocessing%})

0 commit comments

Comments
 (0)