Sign document using digital signature

This sample shows how to sign document using digital signature.

window.onload = function(){ var viewer = new DsPdfViewer("#viewer", getViewerOptions()); configureViewerUI(viewer); viewer.open("/document-solutions/javascript-pdf-viewer/demos/product-bundles/assets/pdf/sign-with-digital-signature.pdf"); }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Sign document using digital signature</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="./src/styles.css"> <script src="/document-solutions/javascript-pdf-viewer/demos/product-bundles/build/dspdfviewer.js"></script> <script src="/document-solutions/javascript-pdf-viewer/demos/resource/js/init.js"></script> <script src="./src/app.js"></script> <script src="./src/config.js"></script> </head> <body> <div id="viewer"></div> </body> </html>
#viewer { height: 100%; }
function getViewerOptions() { return { workerSrc: "/document-solutions/javascript-pdf-viewer/demos/product-bundles/build/dspdfviewer.worker.js", supportApi: { apiUrl: window.top.SUPPORTAPI_URL, token: window.top.SUPPORTAPI_TOKEN, webSocketUrl: false }, friendlyFileName: "digital-signature-sample.pdf", restoreViewStateOnLoad: false }; } function configureViewerUI(viewer) { viewer.toggleSidebar(false); viewer.toolbar.addItem({ text: "Apply employee signature", key: 'employee-signature', title: 'Apply employee signature',enabled: false, action: function() { const locationName = location.hostname || "Unknown"; viewer.save(undefined, { sign: { signatureField: "Employee", signerName: "Employee Name", location: locationName }, reload: true } ); }, onUpdate: function() { return { enabled: viewer.hasDocument, title: 'Apply employee signature' }; } }); viewer.toolbar.addItem({ text: "Apply supervisor signature", key: 'supervisor-signature', title: 'Apply supervisor signature',enabled: false, action: function() { const locationName = location.hostname || "Unknown"; viewer.save(undefined, { sign: { signatureField: "Supervisor", signerName: "Supervisor Name", location: locationName }, reload: true } ); }, onUpdate: function() { return { enabled: viewer.hasDocument, title: 'Apply supervisor signature' }; } }); viewer.toolbarLayout.viewer.mobile = viewer.toolbarLayout.viewer.default = ["employee-signature", "supervisor-signature", "$split", "download", "zoom", "$split", "about"]; }