You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Document-Processing/PDF/PDF-Library/javascript/DigitalSignature.md
+295-1Lines changed: 295 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -306,7 +306,301 @@ document.destroy();
306
306
{% endhighlight %}
307
307
{% endtabs %}
308
308
309
-
## Retrieve the Signed Date of a PDF Signature
309
+
## Create and certify a digital signature field
310
+
311
+
This example demonstrates how to add a signature field to a PDF, create a digital signature using certificate data and a password, certify the document, and save the signed PDF document.
312
+
313
+
{% tabs %}
314
+
{% highlight typescript tabtitle="TypeScript" %}
315
+
import { PdfDocument, PdfPage, PdfSignatureField, PdfSignature } from '@syncfusion/ej2-pdf';
316
+
317
+
// Create a new PDF document
318
+
const document = new PdfDocument();
319
+
// Add a new page to the document
320
+
const page: PdfPage = document.addPage();
321
+
// Create a signature field on the page at specified coordinates
// Create a signature field on the page at specified coordinates
342
+
var field = new ej.pdf.PdfSignatureField(page, 'field', { x: 50, y: 50, width: 100, height: 100 });
343
+
// Create a digital signature using certificate data and password, enabling certification
344
+
var signature = ej.pdf.PdfSignature.create(certData, password, { certify: true });
345
+
// Assign the signature to the signature field
346
+
field.setSignature(signature);
347
+
//// Add the signature field to the document form
348
+
document.form.add(field);
349
+
// Save the document
350
+
document.save('Output.pdf');
351
+
// Release resources used by the document
352
+
document.destroy();
353
+
354
+
{% endhighlight %}
355
+
{% endtabs %}
356
+
357
+
## Create and lock a digitally signed PDF
358
+
359
+
This example shows how to add a signature field to a PDF, create a digital signature using certificate data and a password, lock the document after signing, and save the result in PDF library.
360
+
361
+
{% tabs %}
362
+
{% highlight typescript tabtitle="TypeScript" %}
363
+
import { PdfDocument, PdfPage, PdfSignatureField, PdfSignature } from '@syncfusion/ej2-pdf';
364
+
365
+
// Create a new PDF document
366
+
const document = new PdfDocument();
367
+
// Add a new page to the document
368
+
const page: PdfPage = document.addPage();
369
+
// Create a signature field on the page at specified coordinates
370
+
const field = new PdfSignatureField(page, 'field', { x: 50, y: 50, width: 100, height: 100 });
371
+
// Create a digital signature using certificate data and password, locking the document after signing
// Create a signature field on the page at specified coordinates
390
+
var field = new ej.pdf.PdfSignatureField(page, 'field', { x: 50, y: 50, width: 100, height: 100 });
391
+
// Create a digital signature using certificate data and password, locking the document after signing
392
+
var signature = ej.pdf.PdfSignature.create(certData, password, { isLocked: true });
393
+
// Assign// Assign the signature to the signature field
394
+
field.setSignature(signature);
395
+
// Add the signature field to the document form
396
+
document.form.add(field);
397
+
// Save the document
398
+
document.save('Output.pdf');
399
+
// Release resources used by the document
400
+
document.destroy();
401
+
402
+
{% endhighlight %}
403
+
{% endtabs %}
404
+
405
+
## Adding multiple signatures to a PDF
406
+
407
+
This example demonstrates how to add two visible signature fields to a PDF, apply a certifying signature to the first field (allowing form filling), then reopen the document and apply a second signature with forbid changes permissions.
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.
// Register the signature field with the document form
592
+
document.form.add(field);
593
+
// Apply the signature to the field
594
+
field.setSignature(signature);
595
+
// Save the document
596
+
document.save('Output.pdf');
597
+
// Release document resources
598
+
document.destroy();
599
+
600
+
{% endhighlight %}
601
+
{% endtabs %}
602
+
603
+
## Retrieve the signed date of a PDF signature
310
604
311
605
This example demonstrates how to retrieve the signed date of a PDF signature using the `getSignedDate()` method of the `PdfSignature` class. This property helps identify when the document was digitally signed.
0 commit comments