|
@@ -466,6 +466,11 @@ class ComPDFKitViewer {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ deleteAnnotations(annotation) {
|
|
|
+ const annotations = Array.isArray(annotation) ? annotation : [annotation]
|
|
|
+ this.pdfViewer.deleteAnnotations(annotations)
|
|
|
+ }
|
|
|
+
|
|
|
addEvent(eventName, fn) {
|
|
|
this.eventBus._on(eventName, fn);
|
|
|
}
|
|
@@ -1765,13 +1770,6 @@ class ComPDFKitViewer {
|
|
|
delete this.annotations[annotation.pageIndex]
|
|
|
}
|
|
|
this.redactionList = this.redactionList.filter((item) => item.name !== annotation.name)
|
|
|
- } else if (data.type === 'empty') {
|
|
|
- annotations.splice(index, 1)
|
|
|
- if (!annotations.length) {
|
|
|
- delete this.annotations[annotation.pageIndex]
|
|
|
- }
|
|
|
- this.redactionList = this.redactionList.filter((item) => item.pageIndex !== annotation.pageIndex)
|
|
|
- return
|
|
|
} else {
|
|
|
if (!this.webviewerServer) {
|
|
|
annotation.doc = this.doc
|
|
@@ -2059,7 +2057,10 @@ class ComPDFKitViewer {
|
|
|
}
|
|
|
|
|
|
handleCreateSignature(data) {
|
|
|
- this.addAnnotations(data)
|
|
|
+ this.eventBus.dispatch('annotationChange', {
|
|
|
+ type: 'add',
|
|
|
+ annotation: data
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
webViewerDistanceChanged(evt) {
|
|
@@ -3050,7 +3051,7 @@ class ComPDFKitViewer {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- handleStamp(data) {
|
|
|
+ async handleStamp(data) {
|
|
|
if (!data) return
|
|
|
let imgUi = data.stampContainer
|
|
|
let pageNum = data.page
|
|
@@ -3094,7 +3095,6 @@ class ComPDFKitViewer {
|
|
|
type: 'stamp',
|
|
|
date: new Date(),
|
|
|
pageIndex: pageNum - 1,
|
|
|
- // rect,
|
|
|
contents: data.text,
|
|
|
time: data.time,
|
|
|
stampColor: data.color,
|
|
@@ -3102,7 +3102,38 @@ class ComPDFKitViewer {
|
|
|
}
|
|
|
}
|
|
|
annotData.stampShape = 0
|
|
|
- this.addAnnotations(annotData)
|
|
|
+
|
|
|
+ if (!annotData.rect) {
|
|
|
+ const rect = await this.messageHandler.sendWithPromise('GetStampRect', {
|
|
|
+ doc: this.doc,
|
|
|
+ pagePtr: this.pagesPtr[pageNum - 1].pagePtr,
|
|
|
+ annotation: annotData
|
|
|
+ })
|
|
|
+ if (rect && rect.code) {
|
|
|
+ console.log(result.message)
|
|
|
+ alert(result.message)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ const pageWidth = pageView.viewport.viewBox[2]
|
|
|
+ const pageHeight = pageView.viewport.viewBox[3]
|
|
|
+ const imgWidth = rect.right - rect.left
|
|
|
+ const imgHeight = rect.bottom - rect.top
|
|
|
+
|
|
|
+ const left = (pageWidth - imgWidth) / 2
|
|
|
+ const top = (pageHeight - imgHeight) / 2
|
|
|
+ const right = (pageWidth + imgWidth) / 2
|
|
|
+ const bottom = (pageHeight + imgHeight) / 2
|
|
|
+ annotData.rect = {
|
|
|
+ left,
|
|
|
+ right,
|
|
|
+ top,
|
|
|
+ bottom
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.eventBus.dispatch('annotationChange', {
|
|
|
+ type: 'add',
|
|
|
+ annotation: annotData
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
async compare(data) {
|