function loadPSPDFKit(arrayBuffer, container, licenseKey, locale) { return PSPDFKit.load({ inlineWorkers: false, locale: locale, licenseKey: licenseKey, styleSheets: ['/css/site.css'], container: container, document: arrayBuffer, annotationPresets: getPresets(), electronicSignatures: { creationModes: ['DRAW', 'TYPE', 'IMAGE'], }, initialViewState: new PSPDFKit.ViewState({ sidebarMode: PSPDFKit.SidebarMode.THUMBNAILS, }), isEditableAnnotation: function (annotation) { // Check if the annotation is a signature // This will allow new signatures, but not allow edits. if (annotation.isSignature || annotation.description == 'FRAME') { return false } return true //return !annotation.isSignature; }, customRenderers: { Annotation: annotationRenderer, }, }); } const allowedToolbarItems = [ 'sidebar-thumbnails', 'sidebar-document-ouline', 'sidebar-bookmarks', 'pager', 'pan', 'zoom-out', 'zoom-in', 'zoom-mode', 'spacer', 'search', 'export-pdf' ] function addToolbarItems(instance, handler) { var toolbarItems = instance.toolbarItems.filter((item) => allowedToolbarItems.includes(item.type)); if (IS_READONLY) toolbarItems = toolbarItems.concat(getReadOnlyItems(handler)); else toolbarItems = toolbarItems.concat(getWritableItems(handler)); if (!IS_DESKTOP_SIZE && !IS_READONLY) toolbarItems = toolbarItems.concat(getMobileWritableItems(handler)); instance.setToolbarItems(toolbarItems) } function annotationRenderer(data) { // leave everything as is return null } function createElementFromHTML(html) { const el = document.createElement('div') el.innerHTML = html.trim() return el.firstChild } function getWritableItems(callback) { return [ { type: 'custom', id: 'button-share', className: 'button-share', title: 'Teilen', onPress() { callback('SHARE') }, icon: ` `, }, { type: 'custom', id: 'button-logout', className: 'button-logout', title: 'logout', onPress() { callback('LOGOUT') }, icon: ` ` }, { type: 'custom', id: 'mock', className: 'mock', title: 'Mock', icon: `` } ]; } function getReadOnlyItems(callback) { return [ { type: 'custom', id: 'button-copy-url', className: 'button-copy-url', title: 'Teilen', onPress() { callback('COPY_URL') }, icon: ` `, } ]; } function getMobileWritableItems(callback) { return [ { type: 'custom', id: 'button-finish', className: 'button-finish', onPress() { callback('FINISH') }, icon: `` }, { type: 'custom', id: 'button-reject', className: 'button-reject', title: 'Ablehnen', onPress() { callback('REJECT') }, icon: ` `, }, { type: 'custom', id: 'button-reset', className: 'button-reset', title: 'Zurücksetzen', onPress() { callback('RESET') }, icon: ` `, } ]; } function getPresets() { const annotationPresets = PSPDFKit.defaultAnnotationPresets annotationPresets.ink = { lineWidth: 10, } annotationPresets.widget = { readOnly: true, } return annotationPresets }