Skip to content

Commit 22b9091

Browse files
1010299: changes updated
1 parent 428b594 commit 22b9091

2 files changed

Lines changed: 74 additions & 6 deletions

File tree

Document-Processing/PDF/PDF-Library/javascript/DigitalSignature.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,69 @@ ldocument.destroy();
521521
{% endhighlight %}
522522
{% endtabs %}
523523

524+
## Adding a timestamp in digital signature
525+
526+
This example shows how to apply a digital signature with a trusted timestamp, ensuring the signature remains valid even after the certificate expires. A timestamp callback contacts a Time Stamping Authority (TSA) to add an official time record to the signature. This provides long‑term proof of when the document was signed.
527+
528+
{% tabs %}
529+
{% highlight typescript tabtitle="TypeScript" %}
530+
531+
import { PdfDocument, PdfPage, PdfForm, PdfSignatureField, PdfSignature, CryptographicStandard, DigestAlgorithm } from '@syncfusion/ej2-pdf';
532+
533+
// Load the document
534+
let document: PdfDocument = new PdfDocument(data);
535+
// Gets the first page of the document
536+
let page: PdfPage = document.getPage(0);
537+
// Access the PDF form
538+
let form: PdfForm = document.form;
539+
// Create a new signature field
540+
let field: PdfSignatureField = new PdfSignatureField(page, 'Signature', {x: 10, y: 10, width: 100, height: 50});
541+
// Create a timestamp callback
542+
async function timestampCallback(request: Uint8Array): Promise<{ response: Uint8Array }> {
543+
// Implement timestamp response logic here
544+
return { response: new Uint8Array() }; // Placeholder return
545+
}
546+
// Create a new signature using PFX data, private key and call back function for timestamp
547+
const signature: PdfSignature = PdfSignature.create(certData, password, { cryptographicStandard: CryptographicStandard.cms, digestAlgorithm: DigestAlgorithm.sha256 }, timestampCallback);
548+
// Sets the signature to the field
549+
field.setSignature(signature);
550+
// Add the field into PDF form
551+
form.add(field);
552+
// Save the document
553+
await document.saveAsync('output.pdf');
554+
// Destroy the document
555+
document.destroy();
556+
557+
{% endhighlight %}
558+
{% highlight javascript tabtitle="JavaScript" %}
559+
560+
// Load the document
561+
var document = new ej.pdf.PdfDocument(data);
562+
// Gets the first page of the document
563+
var page = document.getPage(0);
564+
// Access the PDF form
565+
var form = document.form;
566+
// Create a new signature field
567+
var field = new ej.pdf.PdfSignatureField(page, 'Signature', {x: 10, y: 10, width: 100, height: 50});
568+
// Create a timestamp callback
569+
async function timestampCallback(request) {
570+
// Implement timestamp response logic here
571+
return { response: new Uint8Array() }; // Placeholder return
572+
}
573+
// Create a new signature using PFX data, private key and call back function for timestamp
574+
const signature = PdfSignature.create(certData, password, { cryptographicStandard: ej.pdf.CryptographicStandard.cms, digestAlgorithm: ej.pdf.DigestAlgorithm.sha256 }, timestampCallback);
575+
// Sets the signature to the field
576+
field.setSignature(signature);
577+
// Add the field into PDF form
578+
form.add(field);
579+
// Save the document
580+
await document.saveAsync('output.pdf');
581+
// Destroy the document
582+
document.destroy();
583+
584+
{% endhighlight %}
585+
{% endtabs %}
586+
524587
## Drawing text/image in the Signature Appearance
525588

526589
This example demonstrates how to create a visible signature field, apply a CMS (SHA-256) digital signature with signer information, customize the signature appearance using a base64-encoded image, and save the signed PDF document.

Document-Processing/PDF/PDF-Library/javascript/Redaction.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ N> For redaction features, you need to install the `@syncfusion/ej2-pdf-data-ext
1414
## Removing sensitive content from the PDF document
1515

1616
Redaction permanently removes confidential or sensitive information from a PDF. The `PdfRedactor` and `PdfRedactionRegion` classes allow you to mark specific areas and apply irreversible redaction to the document.
17+
> **Note:**
18+
> When calling `redact(callback)`, the callback is executed to render each redaction region on a canvas before the content is permanently removed. This allows customizing the final appearance of the redacted area.
1719
1820
{% tabs %}
1921
{% highlight typescript tabtitle="TypeScript" %}
@@ -29,14 +31,15 @@ let redactions: PdfRedactionRegion[] = [];
2931
redactions.push(new PdfRedactionRegion(0, {x: 10, y: 10, width: 100, height: 50}));
3032
redactor.add(redactions);
3133
// Apply redactions on the PDF document
32-
redactor.redact();
34+
redactor.redactSync();
3335
// Save the document
3436
document.save('output.pdf');
3537
// Destroy the document
3638
document.destroy();
3739

3840
{% endhighlight %}
3941
{% highlight javascript tabtitle="JavaScript" %}
42+
4043
// Load the document
4144
var document = new ej.pdf.PdfDocument(data);
4245
// Create a new text extractor
@@ -46,7 +49,7 @@ var redactions = [];
4649
redactions.push(new PdfRedactionRegion(0, {x: 10, y: 10, width: 100, height: 50}));
4750
redactor.add(redactions);
4851
// Apply redactions on the PDF document
49-
redactor.redact();
52+
redactor.redactSync();
5053
// Save the document
5154
document.save('output.pdf');
5255
// Destroy the document
@@ -77,13 +80,15 @@ redactions.push(redaction);
7780
// Add redactions with specified options.
7881
redactor.add(redactions);
7982
// Apply redactions on the PDF document
80-
redactor.redact();
83+
redactor.redactSync();
8184
// Save the document
8285
document.save('output.pdf');
8386
// Destroy the document
8487
document.destroy();
88+
8589
{% endhighlight %}
8690
{% highlight javascript tabtitle="JavaScript" %}
91+
8792
// Load an existing PDF document
8893
var document = new ej.pdf.PdfDocument(data);
8994
// Add redactions to the collection
@@ -98,7 +103,7 @@ redactions.push(redaction);
98103
// Add redactions with specified options.
99104
redactor.add(redactions);
100105
// Apply redactions on the PDF document
101-
redactor.redact();
106+
redactor.redactSync();
102107
// Save the document
103108
document.save('output.pdf');
104109
// Destroy the document
@@ -137,7 +142,7 @@ let redactor = new PdfRedactor(document);
137142
// Add redactions with specified options
138143
redactor.add(redactions);
139144
// Apply redactions on the PDF document
140-
redactor.redact();
145+
redactor.redactSync();
141146
// Save the document
142147
document.save('output.pdf');
143148
// Destroy the document
@@ -168,7 +173,7 @@ redactions.push(redaction);
168173
var redactor = new ej.pdf.PdfRedactor(document);
169174
// Add redactions and apply them
170175
redactor.add(redactions);
171-
redactor.redact();
176+
redactor.redactSync();
172177
// Save and dispose
173178
document.save('output.pdf');
174179
document.destroy();

0 commit comments

Comments
 (0)