window.onload = function(){
var options = {
workerSrc: "/document-solutions/javascript-pdf-viewer/demos/product-bundles/build/dspdfviewer.worker.js",
supportApi: getSupportApiSettings()
};
// Set editor defaults:
options.editorDefaults = {
inkAnnotation: {
borderStyle: { width: 3, style: 1 },
color: '#ff9800'
},
squareAnnotation: {
borderStyle: { width: 5, style: 2, dashArray: [8, 4] },
color: '#000000',
interiorColor: '#f44336'
},
circleAnnotation: {
borderStyle: { width: 2, style: 1 },
color: '#2196f3',
interiorColor: '#fff9c8'
},
lineAnnotation: {
borderStyle: { width: 2, style: 1 },
color: '#4caf50',
interiorColor: '#2196f3',
lineStart: 'Circle',
lineEnd: 'Circle'
},
polyLineAnnotation: {
borderStyle: { width: 2, style: 1 },
color: '#000000',
interiorColor: '#f44336',
lineStart: 'Diamond',
lineEnd: 'ClosedArrow'
},
polygonAnnotation: {
borderStyle: { width: 5, style: 1 },
color: '#ff0000',
interiorColor: '#faa19b'
},
};
const viewer = new DsPdfViewer("#viewer", options);
viewer.addDefaultPanels();
viewer.addAnnotationEditorPanel();
viewer.layoutMode = 1;
// Configure toolbar buttons:
viewer.toolbarLayout.viewer = {
default: ['open', 'save', '$navigation', '$split', 'text-selection', 'pan', '$zoom', '$fullscreen', 'download', 'print', 'rotate', 'view-mode', 'hide-annotations', 'doc-properties', 'about'],
mobile: ['open', 'save', '$navigation', '$split', 'text-selection', 'pan', '$zoom', '$fullscreen', 'download', 'print', 'rotate', 'view-mode', 'hide-annotations', 'doc-properties', 'about'],
fullscreen: ['$fullscreen', 'open', 'save', '$navigation', '$split', 'text-selection', 'pan', '$zoom', '$fullscreen', 'download', 'print', 'rotate', 'view-mode', 'hide-annotations', 'doc-properties', 'about']
};
viewer.toolbarLayout.annotationEditor = {
default: ['save', '$split', 'edit-select', '$split', 'edit-ink', 'edit-square', 'edit-circle', 'edit-line', 'edit-polyline', 'edit-polygon', '$split', 'edit-erase', '$split', 'edit-undo', 'edit-redo'],
mobile: ['save', '$split', 'edit-select', '$split', 'edit-ink', 'edit-square', 'edit-circle', 'edit-line', 'edit-polyline', 'edit-polygon', '$split', 'edit-erase', '$split', 'edit-undo', 'edit-redo'],
fullscreen: ['$fullscreen', 'save', '$split', 'edit-select', '$split', 'edit-ink', 'edit-square', 'edit-circle', 'edit-line', 'edit-polyline', 'edit-polygon', '$split', 'edit-erase', '$split', 'edit-undo', 'edit-redo']
};
viewer.applyToolbarLayout();
viewer.applyOptions();
viewer.open("/document-solutions/javascript-pdf-viewer/demos/product-bundles/assets/pdf/viewer-editor-defaults.pdf");
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Editor Defaults</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/product-bundles/build/wasmSupportApi.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%;
}