This sample demonstrates the use of graphical signature feature. The tool is available via the Annotation Editor's toolbar button Signature tool.
window.onload = function() {
//DsPdfViewer.LicenseKey = "***key***";
let viewer;
function updateDestinationLocation(destinationSize) {
if(viewer) {
var options = viewer.options;
var pageSize = viewer.getPageSize(0);
options.signTool.location = {x: (pageSize.width - destinationSize.width) / 2, y: (pageSize.height - destinationSize.height) / 3};
}
}
let options = {
workerSrc: "/document-solutions/javascript-pdf-viewer/demos/product-bundles/build/dspdfviewer.worker.js",
supportApi: getSupportApiSettings(),
restoreViewStateOnLoad: false
};
options.signTool = {
selectedTab: 'Draw',
saveSignature: true,
penColor: 'darkblue',
penWidth: 2,
canvasSize: { width: 500, height: 200 },
autoResizeCanvas: true,
destinationScale: 0.5,
afterShow: function(dialog) {
updateDestinationLocation(dialog.destinationSize);
},
beforeAdd: function() {
//viewer.layoutMode = 1;
return true;
}
};
options.restoreViewStateOnLoad = false;
viewer = new DsPdfViewer("#viewer", options);
viewer.addDefaultPanels();
viewer.addAnnotationEditorPanel();
viewer.addFormEditorPanel();
viewer.layoutMode = 0;
viewer.mouseMode = 1;
viewer.toolbarLayout.viewer = {
default: ['open', 'save', 'edit-sign-tool', 'edit-undo', 'doc-title', '$split', 'about'],
mobile: ['open', 'save', 'edit-sign-tool', 'edit-undo', 'doc-title', '$split', 'about'],
fullscreen: ['$fullscreen', 'open', 'save', 'edit-sign-tool', 'edit-undo', 'doc-title', '$split', 'about']
};
viewer.toolbarLayout.annotationEditor = {
default: ['open', 'save', 'edit-sign-tool', 'edit-undo', 'doc-title', '$split', 'about'],
mobile: ['open', 'save', 'edit-sign-tool', 'edit-undo', 'doc-title', '$split', 'about'],
fullscreen: ['$fullscreen', 'open', 'save', 'edit-sign-tool', 'edit-undo', 'doc-title', '$split', 'about']
};
viewer.zoom = 70;
viewer.applyToolbarLayout();
viewer.open("/document-solutions/javascript-pdf-viewer/demos/product-bundles/assets/pdf/viewer-edit-signature-tool.pdf");
}