|
@@ -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);
|
|
|
}
|
|
@@ -3050,7 +3055,7 @@ class ComPDFKitViewer {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- handleStamp(data) {
|
|
|
+ async handleStamp(data) {
|
|
|
if (!data) return
|
|
|
let imgUi = data.stampContainer
|
|
|
let pageNum = data.page
|
|
@@ -3094,7 +3099,6 @@ class ComPDFKitViewer {
|
|
|
type: 'stamp',
|
|
|
date: new Date(),
|
|
|
pageIndex: pageNum - 1,
|
|
|
- // rect,
|
|
|
contents: data.text,
|
|
|
time: data.time,
|
|
|
stampColor: data.color,
|
|
@@ -3102,7 +3106,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) {
|