This sample shows how to hide the graphical signature tool from toolbar once the signature has been added.
window.onload = function(){
//DsPdfViewer.LicenseKey = "***key***";
let viewer;
function applyNormalViewerLayout() {
viewer.toolbarLayout.viewer = {
default: ['save', 'edit-sign-tool', 'doc-title', '$split', 'about'],
mobile: ['save', 'edit-sign-tool', 'doc-title', '$split', 'about'],
fullscreen: ['$fullscreen', 'save', 'edit-sign-tool', 'doc-title', '$split', 'about']
};
viewer.applyToolbarLayout();
}
function applySignedViewerLayout() {
viewer.toolbarLayout.viewer = {
default: ['save', 'doc-title', '$split', 'about'],
mobile: ['save', 'doc-title', '$split', 'about'],
fullscreen: ['$fullscreen', 'save', 'doc-title', '$split', 'about']
};
viewer.applyToolbarLayout();
}
function onSignatureAdded(resultDetails) {
viewer.scrollAnnotationIntoView(resultDetails.pageIndex, resultDetails.annotation);
applySignedViewerLayout();
}
var options = {
workerSrc: "/document-solutions/javascript-pdf-viewer/demos/product-bundles/build/dspdfviewer.worker.js",
supportApi: getSupportApiSettings(),
restoreViewStateOnLoad: false
};
options.signTool = {
selectedTab: 'Draw',
saveSignature: false,
penColor: '#000000',
penWidth: 2,
hideSaveSignature: true,
canvasSize: { width: 480, height: 168 },
autoResizeCanvas: false,
destinationScale: 0.33,
afterAdd: function (result) {
onSignatureAdded(result);
return true;
},
location: { x: 87, y: 116 },
title: 'Landlord/Lessor',
};
options.restoreViewStateOnLoad = false;
viewer = new DsPdfViewer("#viewer", options);
viewer.mouseMode = 1;
viewer.addDefaultPanels();
viewer.addAnnotationEditorPanel();
viewer.zoom = 70;
applyNormalViewerLayout();
viewer.open("/document-solutions/javascript-pdf-viewer/demos/product-bundles/assets/pdf/viewer-add-signature-from-toolbar.pdf");
}