|
@@ -469,6 +469,11 @@ class ComPDFKitViewer {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ deleteAnnotations(annotation) {
|
|
|
|
+ const annotations = Array.isArray(annotation) ? annotation : [annotation]
|
|
|
|
+ this.pdfViewer.deleteAnnotations(annotations)
|
|
|
|
+ }
|
|
|
|
+
|
|
addEvent(eventName, fn) {
|
|
addEvent(eventName, fn) {
|
|
this.eventBus._on(eventName, fn);
|
|
this.eventBus._on(eventName, fn);
|
|
}
|
|
}
|
|
@@ -1768,12 +1773,6 @@ class ComPDFKitViewer {
|
|
delete this.annotations[annotation.pageIndex]
|
|
delete this.annotations[annotation.pageIndex]
|
|
}
|
|
}
|
|
this.redactionList = this.redactionList.filter((item) => item.name !== annotation.name)
|
|
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]
|
|
|
|
- }
|
|
|
|
- return
|
|
|
|
} else {
|
|
} else {
|
|
if (!this.webviewerServer) {
|
|
if (!this.webviewerServer) {
|
|
annotation.doc = this.doc
|
|
annotation.doc = this.doc
|
|
@@ -2061,7 +2060,10 @@ class ComPDFKitViewer {
|
|
}
|
|
}
|
|
|
|
|
|
handleCreateSignature(data) {
|
|
handleCreateSignature(data) {
|
|
- this.addAnnotations(data)
|
|
|
|
|
|
+ this.eventBus.dispatch('annotationChange', {
|
|
|
|
+ type: 'add',
|
|
|
|
+ annotation: data
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
webViewerDistanceChanged(evt) {
|
|
webViewerDistanceChanged(evt) {
|
|
@@ -3057,7 +3059,7 @@ class ComPDFKitViewer {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- handleStamp(data) {
|
|
|
|
|
|
+ async handleStamp(data) {
|
|
if (!data) return
|
|
if (!data) return
|
|
let imgUi = data.stampContainer
|
|
let imgUi = data.stampContainer
|
|
let pageNum = data.page
|
|
let pageNum = data.page
|
|
@@ -3101,7 +3103,6 @@ class ComPDFKitViewer {
|
|
type: 'stamp',
|
|
type: 'stamp',
|
|
date: new Date(),
|
|
date: new Date(),
|
|
pageIndex: pageNum - 1,
|
|
pageIndex: pageNum - 1,
|
|
- // rect,
|
|
|
|
contents: data.text,
|
|
contents: data.text,
|
|
time: data.time,
|
|
time: data.time,
|
|
stampColor: data.color,
|
|
stampColor: data.color,
|
|
@@ -3109,7 +3110,38 @@ class ComPDFKitViewer {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
annotData.stampShape = 0
|
|
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) {
|
|
async compare(data) {
|