Skip to content

Commit 8ccd928

Browse files
committed
Merge branch 'Q3_2025' of https://github.com/telerik/document-processing-docs into Q3_2025
2 parents 5f270f9 + 08dd74a commit 8ccd928

File tree

7 files changed

+160
-117
lines changed

7 files changed

+160
-117
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
---
2+
title: Getting Started
3+
description: The digital signature feature enables you to sign and validate a PDF document.
4+
page_title: Digital Signature - Getting Started
5+
slug: radpdfprocessing-features-digital-signature-getting-started
6+
tags: digital, signature, getting, started
7+
position: 1
8+
---
9+
10+
# Getting Started
11+
12+
RadPdfProcessing allows adding a digital signature while editing a created from scratch document (or importing an existing one).
13+
14+
>To use the signing functionality in PdfProcessing for **.NET Standard/.NET Core**, you must add a reference to the **System.Security.Cryptography.Pkcs** NuGet package, version 6 or newer (This functionality is available since R1 2022 SP1).
15+
16+
## Signing a Document
17+
18+
To sign a document, follow the steps:
19+
20+
1\. Create a **Signature** object which takes a [X509Certificate2](https://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate2(v=vs.110).aspx) object as a parameter. This is the certificate that will be used to sign the PDF document.
21+
22+
2\. When instantiated, add the **Signature** to the document's content using a [SignatureField]({%slug radpdfprocessing-model-interactive-forms-form-fields-signaturefield%}).
23+
24+
3\. To create a signature, which has a visual representation, you must create a [SignatureWidget]({%slug radpdfprocessing-model-annotations-widgets%}) and associate the Widget annotation with the signed [SignatureField]({%slug radpdfprocessing-model-interactive-forms-form-fields-signaturefield%}). The widget also needs a [FormSource]({%slug radpdfprocessing-model-formsource-overview%}) object applied to its Content.**NormalContentSource** property. A **FormSource** could be filled with data using the FixedContentEditor.
25+
26+
>caution When exporting a digitally signed document, a stream that allows both, reading and writing, should be passed. Otherwise, an exception is thrown: *NotSupportedException: 'Stream does not support reading.'*.
27+
28+
The following example shows a full code snippet for a simple signing of a newly created document:
29+
30+
#### **[C#] Example: Sign a document**
31+
32+
{{region radpdfprocessing-features-digital-signature_2}}
33+
34+
using System;
35+
using Telerik.Windows.Documents.Fixed.Model.Annotations;
36+
using System.Security.Cryptography.X509Certificates;
37+
using Telerik.Windows.Documents.Fixed.Model.Editing;
38+
using Telerik.Windows.Documents.Fixed.Model.InteractiveForms;
39+
using Telerik.Windows.Documents.Fixed.Model.Objects;
40+
using Telerik.Windows.Documents.Fixed.Model.Resources;
41+
using Telerik.Windows.Documents.Fixed.Model;
42+
using Telerik.Windows.Documents.Fixed.Model.DigitalSignatures;
43+
using System.Windows;
44+
using System.IO;
45+
46+
namespace ConsoleNetFramework
47+
{
48+
internal class Program
49+
{
50+
static void Main(string[] args)
51+
{
52+
int signatureFieldWidth = 200;
53+
int signatureFieldHeight = 50;
54+
int signaturePositionLeft = 10;
55+
int signaturePositionTop = 10;
56+
57+
X509Certificate2 certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2("Certificate.pfx", "johndoe");
58+
SignatureField pdfSignature = new SignatureField("SignatureField");
59+
pdfSignature.Signature = new Signature(certificate);
60+
61+
Form pdfForm = new Telerik.Windows.Documents.Fixed.Model.Objects.Form();
62+
pdfForm.FormSource = new FormSource();
63+
pdfForm.FormSource.Size = new Size(signatureFieldWidth, signatureFieldHeight);
64+
FixedContentEditor editor = new FixedContentEditor(pdfForm.FormSource);
65+
pdfForm.Position.Translate(signaturePositionLeft, signaturePositionTop);
66+
editor.DrawText($"{certificate.GetNameInfo(X509NameType.SimpleName, false)} {DateTime.Now.ToString("yyyy.MM.dd HH:mm")}");
67+
68+
SignatureWidget signatureWidget = pdfSignature.Widgets.AddWidget();
69+
signatureWidget.Content.NormalContentSource = pdfForm.FormSource;
70+
signatureWidget.Rect = new Rect(signaturePositionLeft,signaturePositionTop,signatureFieldWidth,signatureFieldHeight);
71+
signatureWidget.RecalculateContent();
72+
73+
RadFixedDocument document = new RadFixedDocument();
74+
RadFixedPage pdfPage = document.Pages.AddPage();
75+
pdfPage.Annotations.Add(signatureWidget);
76+
77+
FixedContentEditor pageEditor = new FixedContentEditor(pdfPage);
78+
pageEditor.Position.Translate(signaturePositionLeft, signaturePositionTop);
79+
pageEditor.DrawForm(pdfForm.FormSource);
80+
document.AcroForm.FormFields.Add(pdfSignature);
81+
signatureWidget.RecalculateContent();
82+
83+
string signedDocumentFilePath = "signed.pdf";
84+
File.Delete(signedDocumentFilePath);
85+
using (System.IO.Stream output = new System.IO.FileStream(signedDocumentFilePath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite))
86+
{
87+
new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider().Export(document, output);
88+
}
89+
}
90+
}
91+
}
92+
93+
{{endregion}}
94+
95+
>important In .NET Standard use __Telerik.Documents.Primitives.Rect__ instead of __System.Windows.Rect__.
96+
97+
![Signed PDF](images/radpdfprocessing-features-digital-signature.png)
98+
99+
>important When signing an existing document (after the import) we must be sure the AcroForm's ViewersShouldRecalculateWidgetAppearances property is set to false, otherwise, the exported and signed PDF document could not be shown as a signed.
100+
101+
## Signature Encodings
102+
103+
RadPdfProcessing enables you to sign and validate signature fields using standard signature encodings:
104+
105+
* adbe.x509.rsa_sha1 (PKCS #1)
106+
107+
* adbe.pkcs7.sha1 (PKCS #7)
108+
109+
* adbe.pkcs7.detached (PKCS #7 Detached)
110+
111+
## Signature Flags
112+
113+
The signature flags were introduced in R2022 SP1. You can set the flags with the following code:
114+
115+
#### **[C#] Example: Set signature flags**
116+
117+
{{region radpdfprocessing-features-digital-signature_5}}
118+
119+
pdfDocument.AcroForm.SignatureFlags = SignatureFlags.None;
120+
121+
{{endregion}}
122+
123+
The possible values are:
124+
* __None__: Indicates no signature fields exist.
125+
* __SignaturesExist:__ If set, the document contains at least one signature field. This flag allows a viewer application to enable user interface items (such as menu items or pushbuttons) related to signature processing without having to scan the entire document for the presence of signature fields.
126+
* __AppendOnly:__ The document contains signatures that may be invalidated if the file is saved in a way that alters its previous contents. Viewer applications can use this flag to present a user requesting a full save with an additional alert box warning that signatures will be invalidated and requiring explicit confirmation before continuing with the operation.
127+
128+
## See Also
129+
130+
* [Form]({%slug radpdfprocessing-model-form%})
131+
* [Form Fields]({%slug radpdfprocessing-model-interactive-forms-form-fields%})
132+
* [AcroForm]({%slug radpdfprocessing-model-interactive-forms-acroform%})
133+
* [SignatureField]({%slug radpdfprocessing-model-interactive-forms-form-fields-signaturefield%})
134+
* [Signing a document with a digital signature]({%slug signing-a-document-with-digital-signature%})
135+
* [Widgets Types]({%slug radpdfprocessing-model-annotations-widgets%})
136+
* [How to Create Invisible Signatures for PDF Documents]({%slug pdf-invisible-signatures%})
137+
* [Signing a PDF Document with a SignatureWidget]({%slug sign-pdf-with-signature-widget%})
138+
* [Verifying If Digital Signatures Exist in PDF Documents]({%slug verify-digital-signatures-radpdfprocessing%})
139+
* [Signing an Unsigned PDF Document that Contains a Digital Signature with RadPdfProcessing]({%slug pdfprocessing-sign-an-unsigned-pdf%})
140+
* [Digitally Sign Document](https://demos.telerik.com/document-processing/pdfprocessing/digitally_sign_document)
Loading

libraries/radpdfprocessing/features/digital-signature/limitations.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@ position: 3
1111

1212
There are a few limitations related to the usage of digital signatures in RadPdfProcessing.
1313

14-
* Exporting a document that is signed must be done using a stream that supports reading.
14+
* Exporting a document that is signed must be done using a stream that supports **reading**. To ensure compatibility, always use a stream that supports both reading and writing when exporting signed documents with Telerik.
1515

16-
* The validation of a signature depends on the bytes representing the document. Thus, to validate a signature, the stream used to import the document must be still open.
16+
* The validation of a signature depends on the bytes representing the document. Thus, to validate a signature, the stream, used to import the document, must be still **open**.
1717

1818
* The validation is always performed for the current field, against the state of the document at the moment of importing.
1919

20-
* At this point, RadPdfProcessing supports only the signing of a document that does not contain a signed signature field. Signing a document containing a signed signature field will result in invalidation and corruption of the existing signature.
21-
22-
* RadPdfProcessing currently supports only the signing of a single signature field. Signing more than one signature field will result in the invalidation of all signatures except the last one.
23-
2420
## See Also
2521

2622
* [Form]({%slug radpdfprocessing-model-form%})

libraries/radpdfprocessing/features/digital-signature/overview.md

Lines changed: 8 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -9,94 +9,18 @@ position: 0
99

1010
# What is Digital Signature?
1111

12-
The digital signature feature enables you to sign and validate a PDF document. A signature confirms that the document's content originated from the signer and has not been modified in any way. A signed document is considered valid when it has not been changed after the signing, and all of its certificates have a valid trusted root certificate.
12+
The **digital signature** feature enables you to sign and validate a PDF document. A signature confirms that the document's content originated from the signer and has not been modified in any way. A signed document is considered valid when it has not been changed after the signing, and all of its certificates have a valid trusted root certificate.
1313

14-
>To use the signing functionality in PdfProcessing for **.NET Standard/.NET Core**, you must add a reference to the **System.Security.Cryptography.Pkcs** NuGet package, version 6 or newer (This functionality is available since R1 2022 SP1).
14+
Telerik **RadPdfProcessing** provides an easy-to-use API that allows you to:
1515

16-
## Signing a Document
16+
<a name="signing-a-document"><a/>
1717

18-
To sign a document, follow the steps:
18+
* [Create a PDF document from scratch and add a signature field]({%slug radpdfprocessing-features-digital-signature-getting-started%}).
19+
* [Sign PDF documents that contain a predifined signature field](https://demos.telerik.com/document-processing/pdfprocessing/digitally_sign_document).
20+
* [Verify existing signed PDF documents]({%slug radpdfprocessing-features-signature-validation%}).
21+
* [Multiple Digital Signing with PdfStreamSigner]({%slug radpdfprocessing-features-digital-signature-pdfstreamsigner%}).
1922

20-
1\. Create a **Signature** object which takes a [X509Certificate2](https://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate2(v=vs.110).aspx) object as a parameter. This is the certificate that will be used to sign the PDF document.
21-
22-
2\. When instantiated, add the **Signature** to the document's content using a [SignatureField]({%slug radpdfprocessing-model-interactive-forms-form-fields-signaturefield%}).
23-
24-
3\. To create a signature, which has a visual representation, you must create a [SignatureWidget]({%slug radpdfprocessing-model-annotations-widgets%}) and associate the Widget annotation with the signed [SignatureField]({%slug radpdfprocessing-model-interactive-forms-form-fields-signaturefield%}). The widget also needs a [FormSource]({%slug radpdfprocessing-model-formsource-overview%}) object applied to its Content.**NormalContentSource** property. A **FormSource** could be filled with data using the FixedContentEditor.
25-
26-
>caution When exporting a digitally signed document, a stream that allows both, reading and writing, should be passed. Otherwise, an exception is thrown: *NotSupportedException: 'Stream does not support reading.'*.
27-
28-
The following example shows a full code snippet for a simple signing of a newly created document:
29-
30-
#### **[C#] Example: Sign a document**
31-
32-
{{region radpdfprocessing-features-digital-signature_2}}
33-
34-
using System;
35-
using Telerik.Windows.Documents.Fixed.Model.Annotations;
36-
using System.Security.Cryptography.X509Certificates;
37-
using Telerik.Windows.Documents.Fixed.Model.Editing;
38-
using Telerik.Windows.Documents.Fixed.Model.InteractiveForms;
39-
using Telerik.Windows.Documents.Fixed.Model.Objects;
40-
using Telerik.Windows.Documents.Fixed.Model.Resources;
41-
using Telerik.Windows.Documents.Fixed.Model;
42-
using Telerik.Windows.Documents.Fixed.Model.DigitalSignatures;
43-
using System.Windows;
44-
using System.IO;
45-
46-
namespace ConsoleNetFramework
47-
{
48-
internal class Program
49-
{
50-
static void Main(string[] args)
51-
{
52-
int signatureFieldWidth = 200;
53-
int signatureFieldHeight = 50;
54-
int signaturePositionLeft = 10;
55-
int signaturePositionTop = 10;
56-
57-
X509Certificate2 certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2("Certificate.pfx", "johndoe");
58-
SignatureField pdfSignature = new SignatureField("SignatureField");
59-
pdfSignature.Signature = new Signature(certificate);
60-
61-
Form pdfForm = new Telerik.Windows.Documents.Fixed.Model.Objects.Form();
62-
pdfForm.FormSource = new FormSource();
63-
pdfForm.FormSource.Size = new Size(signatureFieldWidth, signatureFieldHeight);
64-
FixedContentEditor editor = new FixedContentEditor(pdfForm.FormSource);
65-
pdfForm.Position.Translate(signaturePositionLeft, signaturePositionTop);
66-
editor.DrawText($"{certificate.GetNameInfo(X509NameType.SimpleName, false)} {DateTime.Now.ToString("yyyy.MM.dd HH:mm")}");
67-
68-
SignatureWidget signatureWidget = pdfSignature.Widgets.AddWidget();
69-
signatureWidget.Content.NormalContentSource = pdfForm.FormSource;
70-
signatureWidget.Rect = new Rect(signaturePositionLeft,signaturePositionTop,signatureFieldWidth,signatureFieldHeight);
71-
signatureWidget.RecalculateContent();
72-
73-
RadFixedDocument document = new RadFixedDocument();
74-
RadFixedPage pdfPage = document.Pages.AddPage();
75-
pdfPage.Annotations.Add(signatureWidget);
76-
77-
FixedContentEditor pageEditor = new FixedContentEditor(pdfPage);
78-
pageEditor.Position.Translate(signaturePositionLeft, signaturePositionTop);
79-
pageEditor.DrawForm(pdfForm.FormSource);
80-
document.AcroForm.FormFields.Add(pdfSignature);
81-
signatureWidget.RecalculateContent();
82-
83-
string signedDocumentFilePath = "signed.pdf";
84-
File.Delete(signedDocumentFilePath);
85-
using (System.IO.Stream output = new System.IO.FileStream(signedDocumentFilePath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite))
86-
{
87-
new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider().Export(document, output);
88-
}
89-
}
90-
}
91-
}
92-
93-
{{endregion}}
94-
95-
>important In .NET Standard use __Telerik.Documents.Primitives.Rect__ instead of __System.Windows.Rect__.
96-
97-
![Signed PDF](images/radpdfprocessing-features-digital-signature.png)
98-
99-
>important When signing an existing document (after the import) we must be sure the AcroForm's ViewersShouldRecalculateWidgetAppearances property is set to false, otherwise, the exported and signed PDF document could not be shown as a signed.
23+
![Overview of Signed PDF](images/radpdfprocessing-features-digital-signature-overview.png)
10024

10125
## See Also
10226

libraries/radpdfprocessing/features/digital-signature/pdfstreamsigner.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ published: True
88
position: 1
99
---
1010

11-
# PdfStreamSigner
11+
# Multiple Digital Signing with PdfStreamSigner
1212

1313
As of **Q2 2025** RadPdfProcessing introduces the **PdfStreamSigner**. The **SignDocument** method it exposes allows the user to insert one or more [Digital Signatures]({%slug radpdfprocessing-features-digital-signature%}) into a PDF document.
1414

15+
>important When adding multiple signatures, make sure the document is exported after each signature before importing it back again.
16+
1517
|Method|Description|
1618
|----|----|
1719
|**PdfStreamSigner(Stream outputStream)**|Creates a new instance of thе PdfStreamSigner and specifies the output stream of the signed document.|
@@ -21,7 +23,7 @@ The following example shows how to insert multiple [Digital Signatures]({%slug r
2123

2224
>important In .NET Standard use __Telerik.Documents.Primitives.Rect__ instead of __System.Windows.Rect__.
2325
24-
>important When adding multiple signatures, make sure the document is exported after each signature before importing it back again.
26+
2527

2628
<snippet id='libraries-pdf-features-digital-signature-pdfstreamsigner'/>
2729

@@ -31,3 +33,4 @@ The following example shows how to insert multiple [Digital Signatures]({%slug r
3133

3234
* [Digital Signature]({%slug radpdfprocessing-features-digital-signature%})
3335
* [Signature Field]({%slug radpdfprocessing-model-interactive-forms-form-fields-signaturefield%})
36+
* [Multiple Digital Signatures Demo](https://demos.telerik.com/document-processing/pdfprocessing/multiple_digital_signatures)

libraries/radpdfprocessing/features/digital-signature/signature-validation.md

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -75,36 +75,12 @@ The following example shows how the validation can be used:
7575

7676
>To evaluate a certificate as trusted, it must be added to the [trusted certificates on your machine](https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-view-certificates-with-the-mmc-snap-in).
7777
78-
## Signature Encodings
7978

80-
RadPdfProcessing enables you to sign and validate signature fields using standard signature encodings:
81-
82-
* adbe.x509.rsa_sha1 (PKCS #1)
83-
84-
* adbe.pkcs7.sha1 (PKCS #7)
85-
86-
* adbe.pkcs7.detached (PKCS #7 Detached)
87-
88-
## Signature Flags
89-
90-
The signature flags were introduced in R2022 SP1. You can set the flags with the following code:
91-
92-
#### **[C#] Example: Set signature flags**
93-
94-
{{region radpdfprocessing-features-digital-signature_5}}
95-
96-
pdfDocument.AcroForm.SignatureFlags = SignatureFlags.None;
97-
98-
{{endregion}}
99-
100-
The possible values are:
101-
* __None__
102-
* __SignaturesExist:__ If set, the document contains at least one signature field.
103-
* __AppendOnly:__ The document contains signatures that may be invalidated if the file is saved in a way that alters its previous contents.
10479

10580
## See Also
10681

10782
* [Form]({%slug radpdfprocessing-model-form%})
10883
* [Form Fields]({%slug radpdfprocessing-model-interactive-forms-form-fields%})
10984
* [AcroForm]({%slug radpdfprocessing-model-interactive-forms-acroform%})
11085
* [SignatureField]({%slug radpdfprocessing-model-interactive-forms-form-fields-signaturefield%})
86+
* [Validate Digital Signature Demo](https://demos.telerik.com/document-processing/pdfprocessing/validate_digital_signature)

web.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@
199199
<match url="^libraries/radpdfprocessing/editing/tablerow$"/>
200200
<action type="Redirect" url="libraries/radpdfprocessing/editing/table/tablerow"/>
201201
</rule>
202+
<rule name="radpdfprocessing-features-digital-signature-signature-validation" enabled="true" stopProcessing="true">
203+
<match url="^radpdfprocessing/features/digital-signature/signature-validation$"/>
204+
<action type="Redirect" url="radpdfprocessing/features/digital-signature/getting-started"/>
205+
</rule>
202206
</rules>
203207
</rewrite>
204208
<httpProtocol>

0 commit comments

Comments
 (0)