Using ruler lines with graphical signature

This sample demonstrates how to configure the ruler lines for the graphical signature feature.

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: 80, y: 100}; } } function onSignatureAdded(resultDetails) { viewer.scrollAnnotationIntoView(resultDetails.pageIndex, resultDetails.annotation); } let options = { 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 }, restoreViewStateOnLoad: false }; options.signTool = { ruler: { Draw: [{ color: '#ffe21e', size: 2, type: 'solid', position: 20 }, { color: '#ff0000', size: 5, type: 'dashed', position: 50 }, { color: '#ffe21e', size: 2, type: 'solid', position: 80 } ], Type: [{ color: '#717171', size: 1, type: 'dashed', position: 30 } ] }, afterShow: function(dialog) { updateDestinationLocation(dialog.destinationSize); }, afterAdd: function (result) { onSignatureAdded(result); return true; } }; options.restoreViewStateOnLoad = false; viewer = new DsPdfViewer("#viewer", options); viewer.addDefaultPanels(); viewer.addAnnotationEditorPanel(); 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.applyToolbarLayout(); viewer.zoom = 70; viewer.onAfterOpen.register(function() { viewer.showSignTool(); }); viewer.open("/document-solutions/javascript-pdf-viewer/demos/product-bundles/assets/pdf/viewer-signature-ruler.pdf"); }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Graphical Signature Ruler</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> </head> <body> <div id="viewer"></div> </body> </html>
#viewer { height: 100%; }