浏览代码

fix: 注释跨页移动支持不同模式下的左右和上下跨页

liutian 2 周之前
父节点
当前提交
5f5da63dcb

+ 42 - 0
packages/core/src/annotation/freetext.js

@@ -752,11 +752,53 @@ export default class Shape extends Base {
       if (page.first && page.first !== (this.page + 1)) {
         const pagePoint = documentViewer.windowToPage(windowCoordinates, page.first, false)
 
+        const annotationWidth = Math.abs(leftTop.x - rightBottom.x)
         const annotationHeight = Math.abs(leftTop.y - rightBottom.y)
+        if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 0) {
+          left = pageX - (startState.clickX - leftTop.x)
+          top = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+          right = pageX - (startState.clickX - rightBottom.x)
+          bottom = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        } else if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 1) {
+          left = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+          top = pageY - (startState.clickY - leftTop.y)
+          right = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+          bottom = pageY - (startState.clickY - rightBottom.y)
+        } else if (documentViewer.pdfViewer.spreadMode === 1 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && minPage % 2 === 0)) {
+            return
+          }
+          if ((minPage + 1) === maxPage) {
+            left = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            top = pageY - (startState.clickY - leftTop.y)
+            right = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            bottom = pageY - (startState.clickY - rightBottom.y)
+          } else if ((minPage + 2) === maxPage) {
+            left = pageX - (startState.clickX - leftTop.x)
+            top = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            right = pageX - (startState.clickX - rightBottom.x)
+            bottom = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          }
+        } else if (documentViewer.pdfViewer.spreadMode === 2 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && !(minPage === 1 && maxPage === 2) && maxPage % 2 === 0 || (minPage === 1 && maxPage === 3))) {
+            return
+          }
+          if ((minPage + 2) === maxPage || (minPage === 1 && maxPage === 2)) {
         left = pageX - (startState.clickX - leftTop.x)
         top = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
         right = pageX - (startState.clickX - rightBottom.x)
         bottom = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          } else if ((minPage + 1) === maxPage) {
+            left = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            top = pageY - (startState.clickY - leftTop.y)
+            right = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            bottom = pageY - (startState.clickY - rightBottom.y)
+          }
+        }
         this.page = page.first - 1
 
         this.annotationContainer.remove()

+ 46 - 4
packages/core/src/annotation/ink.js

@@ -401,11 +401,53 @@ export default class Ink extends Base {
       if (page.first && page.first !== (this.page + 1)) {
         const pagePoint = documentViewer.windowToPage(windowCoordinates, page.first, false)
 
+        const annotationWidth = Math.abs(start.x - end.x)
         const annotationHeight = Math.abs(start.y - end.y)
-        x1 = pageX - (startState.clickX - start.x)
-        y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
-        x2 = pageX - (startState.clickX - this.end.x)
-        y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 0) {
+          x1 = pageX - (startState.clickX - this.start.x)
+          y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+          x2 = pageX - (startState.clickX - this.end.x)
+          y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        } else if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 1) {
+          x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+          y1 = pageY - (startState.clickY - this.start.y)
+          x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+          y2 = pageY - (startState.clickY - this.end.y)
+        } else if (documentViewer.pdfViewer.spreadMode === 1 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && minPage % 2 === 0)) {
+            return
+          }
+          if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          } else if ((minPage + 2) === maxPage) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          }
+        } else if (documentViewer.pdfViewer.spreadMode === 2 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && !(minPage === 1 && maxPage === 2) && maxPage % 2 === 0 || (minPage === 1 && maxPage === 3))) {
+            return
+          }
+          if ((minPage + 2) === maxPage || (minPage === 1 && maxPage === 2)) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          } else if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          }
+        }
         this.page = page.first - 1
 
         this.annotationContainer.remove()

+ 46 - 4
packages/core/src/annotation/line.js

@@ -462,11 +462,53 @@ export default class Line extends Base {
       if (page.first && page.first !== (this.page + 1)) {
         const pagePoint = documentViewer.windowToPage(windowCoordinates, page.first, false)
 
+        const annotationWidth = Math.abs(start.x - end.x)
         const annotationHeight = Math.abs(start.y - end.y)
-        x1 = pageX - (startState.clickX - this.start.x)
-        y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
-        x2 = pageX - (startState.clickX - this.end.x)
-        y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 0) {
+          x1 = pageX - (startState.clickX - this.start.x)
+          y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+          x2 = pageX - (startState.clickX - this.end.x)
+          y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        } else if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 1) {
+          x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+          y1 = pageY - (startState.clickY - this.start.y)
+          x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+          y2 = pageY - (startState.clickY - this.end.y)
+        } else if (documentViewer.pdfViewer.spreadMode === 1 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && minPage % 2 === 0)) {
+            return
+          }
+          if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          } else if ((minPage + 2) === maxPage) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          }
+        } else if (documentViewer.pdfViewer.spreadMode === 2 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && !(minPage === 1 && maxPage === 2) && maxPage % 2 === 0 || (minPage === 1 && maxPage === 3))) {
+            return
+          }
+          if ((minPage + 2) === maxPage || (minPage === 1 && maxPage === 2)) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          } else if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          }
+        }
         this.page = page.first - 1
 
         this.annotationContainer.remove()

+ 46 - 4
packages/core/src/annotation/link.js

@@ -601,11 +601,53 @@ export default class Link extends Base {
       if (page.first && page.first !== (this.page + 1)) {
         const pagePoint = documentViewer.windowToPage(windowCoordinates, page.first, false)
 
+        const annotationWidth = Math.abs(start.x - end.x)
         const annotationHeight = Math.abs(start.y - end.y)
-        x1 = pageX - (startState.clickX - this.start.x)
-        y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
-        x2 = pageX - (startState.clickX - this.end.x)
-        y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 0) {
+          x1 = pageX - (startState.clickX - this.start.x)
+          y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+          x2 = pageX - (startState.clickX - this.end.x)
+          y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        } else if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 1) {
+          x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+          y1 = pageY - (startState.clickY - this.start.y)
+          x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+          y2 = pageY - (startState.clickY - this.end.y)
+        } else if (documentViewer.pdfViewer.spreadMode === 1 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && minPage % 2 === 0)) {
+            return
+          }
+          if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          } else if ((minPage + 2) === maxPage) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          }
+        } else if (documentViewer.pdfViewer.spreadMode === 2 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && !(minPage === 1 && maxPage === 2) && maxPage % 2 === 0 || (minPage === 1 && maxPage === 3))) {
+            return
+          }
+          if ((minPage + 2) === maxPage || (minPage === 1 && maxPage === 2)) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          } else if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          }
+        }
         this.page = page.first - 1
 
         this.annotationContainer.remove()

+ 46 - 4
packages/core/src/annotation/shape.js

@@ -583,11 +583,53 @@ export default class Shape extends Base {
       if (page.first && page.first !== (this.page + 1)) {
         const pagePoint = documentViewer.windowToPage(windowCoordinates, page.first, false)
 
+        const annotationWidth = Math.abs(start.x - end.x)
         const annotationHeight = Math.abs(start.y - end.y)
-        x1 = pageX - (startState.clickX - this.start.x)
-        y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
-        x2 = pageX - (startState.clickX - this.end.x)
-        y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 0) {
+          x1 = pageX - (startState.clickX - this.start.x)
+          y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+          x2 = pageX - (startState.clickX - this.end.x)
+          y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        } else if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 1) {
+          x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+          y1 = pageY - (startState.clickY - this.start.y)
+          x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+          y2 = pageY - (startState.clickY - this.end.y)
+        } else if (documentViewer.pdfViewer.spreadMode === 1 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && minPage % 2 === 0)) {
+            return
+          }
+          if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          } else if ((minPage + 2) === maxPage) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          }
+        } else if (documentViewer.pdfViewer.spreadMode === 2 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && !(minPage === 1 && maxPage === 2) && maxPage % 2 === 0 || (minPage === 1 && maxPage === 3))) {
+            return
+          }
+          if ((minPage + 2) === maxPage || (minPage === 1 && maxPage === 2)) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          } else if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          }
+        }
         this.page = page.first - 1
 
         this.annotationContainer.remove()

+ 46 - 4
packages/core/src/annotation/stamp.js

@@ -562,11 +562,53 @@ export default class Stamp extends Base {
       if (page.first && page.first !== (this.page + 1)) {
         const pagePoint = documentViewer.windowToPage(windowCoordinates, page.first, false)
 
+        const annotationWidth = Math.abs(start.x - end.x)
         const annotationHeight = Math.abs(start.y - end.y)
-        x1 = pageX - (startState.clickX - this.start.x)
-        y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
-        x2 = pageX - (startState.clickX - this.end.x)
-        y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 0) {
+          x1 = pageX - (startState.clickX - this.start.x)
+          y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+          x2 = pageX - (startState.clickX - this.end.x)
+          y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        } else if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 1) {
+          x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+          y1 = pageY - (startState.clickY - this.start.y)
+          x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+          y2 = pageY - (startState.clickY - this.end.y)
+        } else if (documentViewer.pdfViewer.spreadMode === 1 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && minPage % 2 === 0)) {
+            return
+          }
+          if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          } else if ((minPage + 2) === maxPage) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          }
+        } else if (documentViewer.pdfViewer.spreadMode === 2 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && !(minPage === 1 && maxPage === 2) && maxPage % 2 === 0 || (minPage === 1 && maxPage === 3))) {
+            return
+          }
+          if ((minPage + 2) === maxPage || (minPage === 1 && maxPage === 2)) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          } else if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          }
+        }
         this.page = page.first - 1
 
         this.annotationContainer.remove()

+ 47 - 5
packages/core/src/annotation/text.js

@@ -180,11 +180,53 @@ export default class Text extends Base {
     if (page.first && page.first !== (this.page + 1)) {
       const pagePoint = documentViewer.windowToPage(windowCoordinates, page.first, false)
 
-      const annotationHeight = Math.abs(start.y - end.y)
-      x1 = pageX - (startState.clickX - this.start.x)
-      y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
-      x2 = pageX - (startState.clickX - this.end.x)
-      y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+      const annotationWidth = Math.abs(start.x - end.x)
+        const annotationHeight = Math.abs(start.y - end.y)
+        if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 0) {
+          x1 = pageX - (startState.clickX - this.start.x)
+          y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+          x2 = pageX - (startState.clickX - this.end.x)
+          y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        } else if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 1) {
+          x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+          y1 = pageY - (startState.clickY - this.start.y)
+          x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+          y2 = pageY - (startState.clickY - this.end.y)
+        } else if (documentViewer.pdfViewer.spreadMode === 1 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && minPage % 2 === 0)) {
+            return
+          }
+          if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          } else if ((minPage + 2) === maxPage) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          }
+        } else if (documentViewer.pdfViewer.spreadMode === 2 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && !(minPage === 1 && maxPage === 2) && maxPage % 2 === 0 || (minPage === 1 && maxPage === 3))) {
+            return
+          }
+          if ((minPage + 2) === maxPage || (minPage === 1 && maxPage === 2)) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          } else if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          }
+        }
       this.page = page.first - 1
 
       this.annotationContainer.remove()

+ 46 - 4
packages/core/src/form/check_box.js

@@ -722,11 +722,53 @@ export default class CheckBox extends Base {
       if (page.first && page.first !== (this.page + 1)) {
         const pagePoint = documentViewer.windowToPage(windowCoordinates, page.first, false)
 
+        const annotationWidth = Math.abs(start.x - end.x)
         const annotationHeight = Math.abs(start.y - end.y)
-        x1 = pageX - (startState.clickX - this.start.x)
-        y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
-        x2 = pageX - (startState.clickX - this.end.x)
-        y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 0) {
+          x1 = pageX - (startState.clickX - this.start.x)
+          y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+          x2 = pageX - (startState.clickX - this.end.x)
+          y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        } else if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 1) {
+          x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+          y1 = pageY - (startState.clickY - this.start.y)
+          x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+          y2 = pageY - (startState.clickY - this.end.y)
+        } else if (documentViewer.pdfViewer.spreadMode === 1 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && minPage % 2 === 0)) {
+            return
+          }
+          if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          } else if ((minPage + 2) === maxPage) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          }
+        } else if (documentViewer.pdfViewer.spreadMode === 2 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && !(minPage === 1 && maxPage === 2) && maxPage % 2 === 0 || (minPage === 1 && maxPage === 3))) {
+            return
+          }
+          if ((minPage + 2) === maxPage || (minPage === 1 && maxPage === 2)) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          } else if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          }
+        }
         this.page = page.first - 1
 
         this.annotationContainer.remove()

+ 46 - 4
packages/core/src/form/combo_box.js

@@ -696,11 +696,53 @@ export default class ComboBox extends Base {
       if (page.first && page.first !== (this.page + 1)) {
         const pagePoint = documentViewer.windowToPage(windowCoordinates, page.first, false)
 
+        const annotationWidth = Math.abs(start.x - end.x)
         const annotationHeight = Math.abs(start.y - end.y)
-        x1 = pageX - (startState.clickX - this.start.x)
-        y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
-        x2 = pageX - (startState.clickX - this.end.x)
-        y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 0) {
+          x1 = pageX - (startState.clickX - this.start.x)
+          y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+          x2 = pageX - (startState.clickX - this.end.x)
+          y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        } else if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 1) {
+          x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+          y1 = pageY - (startState.clickY - this.start.y)
+          x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+          y2 = pageY - (startState.clickY - this.end.y)
+        } else if (documentViewer.pdfViewer.spreadMode === 1 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && minPage % 2 === 0)) {
+            return
+          }
+          if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          } else if ((minPage + 2) === maxPage) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          }
+        } else if (documentViewer.pdfViewer.spreadMode === 2 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && !(minPage === 1 && maxPage === 2) && maxPage % 2 === 0 || (minPage === 1 && maxPage === 3))) {
+            return
+          }
+          if ((minPage + 2) === maxPage || (minPage === 1 && maxPage === 2)) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          } else if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          }
+        }
         this.page = page.first - 1
 
         this.annotationContainer.remove()

+ 46 - 4
packages/core/src/form/list_box.js

@@ -672,11 +672,53 @@ export default class ListBox extends Base {
       if (page.first && page.first !== (this.page + 1)) {
         const pagePoint = documentViewer.windowToPage(windowCoordinates, page.first, false)
 
+        const annotationWidth = Math.abs(start.x - end.x)
         const annotationHeight = Math.abs(start.y - end.y)
-        x1 = pageX - (startState.clickX - this.start.x)
-        y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
-        x2 = pageX - (startState.clickX - this.end.x)
-        y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 0) {
+          x1 = pageX - (startState.clickX - this.start.x)
+          y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+          x2 = pageX - (startState.clickX - this.end.x)
+          y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        } else if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 1) {
+          x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+          y1 = pageY - (startState.clickY - this.start.y)
+          x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+          y2 = pageY - (startState.clickY - this.end.y)
+        } else if (documentViewer.pdfViewer.spreadMode === 1 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && minPage % 2 === 0)) {
+            return
+          }
+          if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          } else if ((minPage + 2) === maxPage) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          }
+        } else if (documentViewer.pdfViewer.spreadMode === 2 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && !(minPage === 1 && maxPage === 2) && maxPage % 2 === 0 || (minPage === 1 && maxPage === 3))) {
+            return
+          }
+          if ((minPage + 2) === maxPage || (minPage === 1 && maxPage === 2)) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          } else if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          }
+        }
         this.page = page.first - 1
 
         this.annotationContainer.remove()

+ 46 - 4
packages/core/src/form/push_button.js

@@ -648,11 +648,53 @@ export default class PushButton extends Base {
       if (page.first && page.first !== (this.page + 1)) {
         const pagePoint = documentViewer.windowToPage(windowCoordinates, page.first, false)
 
+        const annotationWidth = Math.abs(start.x - end.x)
         const annotationHeight = Math.abs(start.y - end.y)
-        x1 = pageX - (startState.clickX - this.start.x)
-        y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
-        x2 = pageX - (startState.clickX - this.end.x)
-        y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 0) {
+          x1 = pageX - (startState.clickX - this.start.x)
+          y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+          x2 = pageX - (startState.clickX - this.end.x)
+          y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        } else if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 1) {
+          x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+          y1 = pageY - (startState.clickY - this.start.y)
+          x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+          y2 = pageY - (startState.clickY - this.end.y)
+        } else if (documentViewer.pdfViewer.spreadMode === 1 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && minPage % 2 === 0)) {
+            return
+          }
+          if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          } else if ((minPage + 2) === maxPage) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          }
+        } else if (documentViewer.pdfViewer.spreadMode === 2 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && !(minPage === 1 && maxPage === 2) && maxPage % 2 === 0 || (minPage === 1 && maxPage === 3))) {
+            return
+          }
+          if ((minPage + 2) === maxPage || (minPage === 1 && maxPage === 2)) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          } else if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          }
+        }
         this.page = page.first - 1
 
         this.annotationContainer.remove()

+ 46 - 4
packages/core/src/form/radio_button.js

@@ -725,11 +725,53 @@ export default class RadioButton extends Base {
       if (page.first && page.first !== (this.page + 1)) {
         const pagePoint = documentViewer.windowToPage(windowCoordinates, page.first, false)
 
+        const annotationWidth = Math.abs(start.x - end.x)
         const annotationHeight = Math.abs(start.y - end.y)
-        x1 = pageX - (startState.clickX - this.start.x)
-        y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
-        x2 = pageX - (startState.clickX - this.end.x)
-        y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 0) {
+          x1 = pageX - (startState.clickX - this.start.x)
+          y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+          x2 = pageX - (startState.clickX - this.end.x)
+          y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        } else if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 1) {
+          x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+          y1 = pageY - (startState.clickY - this.start.y)
+          x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+          y2 = pageY - (startState.clickY - this.end.y)
+        } else if (documentViewer.pdfViewer.spreadMode === 1 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && minPage % 2 === 0)) {
+            return
+          }
+          if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          } else if ((minPage + 2) === maxPage) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          }
+        } else if (documentViewer.pdfViewer.spreadMode === 2 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && !(minPage === 1 && maxPage === 2) && maxPage % 2 === 0 || (minPage === 1 && maxPage === 3))) {
+            return
+          }
+          if ((minPage + 2) === maxPage || (minPage === 1 && maxPage === 2)) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          } else if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          }
+        }
         this.page = page.first - 1
 
         this.annotationContainer.remove()

+ 46 - 4
packages/core/src/form/signature_fields.js

@@ -583,11 +583,53 @@ export default class SignatureFields extends Base {
       if (page.first && page.first !== (this.page + 1)) {
         const pagePoint = documentViewer.windowToPage(windowCoordinates, page.first, false)
 
+        const annotationWidth = Math.abs(start.x - end.x)
         const annotationHeight = Math.abs(start.y - end.y)
-        x1 = pageX - (startState.clickX - this.start.x)
-        y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
-        x2 = pageX - (startState.clickX - this.end.x)
-        y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 0) {
+          x1 = pageX - (startState.clickX - this.start.x)
+          y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+          x2 = pageX - (startState.clickX - this.end.x)
+          y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        } else if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 1) {
+          x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+          y1 = pageY - (startState.clickY - this.start.y)
+          x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+          y2 = pageY - (startState.clickY - this.end.y)
+        } else if (documentViewer.pdfViewer.spreadMode === 1 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && minPage % 2 === 0)) {
+            return
+          }
+          if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          } else if ((minPage + 2) === maxPage) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          }
+        } else if (documentViewer.pdfViewer.spreadMode === 2 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && !(minPage === 1 && maxPage === 2) && maxPage % 2 === 0 || (minPage === 1 && maxPage === 3))) {
+            return
+          }
+          if ((minPage + 2) === maxPage || (minPage === 1 && maxPage === 2)) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          } else if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          }
+        }
         this.page = page.first - 1
 
         this.annotationContainer.remove()

+ 46 - 4
packages/core/src/form/text_field.js

@@ -654,11 +654,53 @@ export default class TextField extends Base {
       if (page.first && page.first !== (this.page + 1)) {
         const pagePoint = documentViewer.windowToPage(windowCoordinates, page.first, false)
 
+        const annotationWidth = Math.abs(start.x - end.x)
         const annotationHeight = Math.abs(start.y - end.y)
-        x1 = pageX - (startState.clickX - this.start.x)
-        y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
-        x2 = pageX - (startState.clickX - this.end.x)
-        y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 0) {
+          x1 = pageX - (startState.clickX - this.start.x)
+          y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+          x2 = pageX - (startState.clickX - this.end.x)
+          y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+        } else if (documentViewer.pdfViewer.spreadMode === 0 && documentViewer.pdfViewer.scrollMode === 1) {
+          x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+          y1 = pageY - (startState.clickY - this.start.y)
+          x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+          y2 = pageY - (startState.clickY - this.end.y)
+        } else if (documentViewer.pdfViewer.spreadMode === 1 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && minPage % 2 === 0)) {
+            return
+          }
+          if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          } else if ((minPage + 2) === maxPage) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          }
+        } else if (documentViewer.pdfViewer.spreadMode === 2 && documentViewer.pdfViewer.scrollMode === 0) {
+          const minPage = Math.min(page.first, this.page + 1)
+          const maxPage = Math.max(page.first, this.page + 1)
+          if ((maxPage - minPage) > 2 || ((minPage + 1) === maxPage && !(minPage === 1 && maxPage === 2) && maxPage % 2 === 0 || (minPage === 1 && maxPage === 3))) {
+            return
+          }
+          if ((minPage + 2) === maxPage || (minPage === 1 && maxPage === 2)) {
+            x1 = pageX - (startState.clickX - this.start.x)
+            y1 = page.first > (this.page + 1) ? pagePoint.y : pagePoint.y - annotationHeight
+            x2 = pageX - (startState.clickX - this.end.x)
+            y2 = page.first > (this.page + 1) ? pagePoint.y + annotationHeight : pagePoint.y
+          } else if ((minPage + 1) === maxPage) {
+            x1 = page.first > (this.page + 1) ? pagePoint.x : pagePoint.x - annotationWidth
+            y1 = pageY - (startState.clickY - this.start.y)
+            x2 = page.first > (this.page + 1) ? pagePoint.x + annotationWidth : pagePoint.x
+            y2 = pageY - (startState.clickY - this.end.y)
+          }
+        }
         this.page = page.first - 1
 
         this.annotationContainer.remove()

+ 0 - 205
packages/core/src/pdf_page_view.js

@@ -287,8 +287,6 @@ class PDFPageView {
         // this.contentContainer = null
       }
     }
-
-    if (this.compdfAnnotationLayer) return
   }
 
   handleSearch(searchResults) {
@@ -471,209 +469,6 @@ class PDFPageView {
     }
   }
 
-  renderPage() {
-    if (this.renderingState !== RenderingStates.INITIAL) {
-      console.error("Must be in new state before drawing");
-      this.reset(); // Ensure that we reset all state to prevent issues.
-    }
-    const { div, viewport, pdfPage, annotations, annotationsAll } = this;
-
-    if (!pdfPage) {
-      this.renderingState = RenderingStates.FINISHED;
-      throw new Error("pdfPage is not loaded");
-    }
-
-    this.renderingState = RenderingStates.RUNNING;
-
-    const canvasWrapper = document.createElement("div");
-    canvasWrapper.classList.add("canvasWrapper");
-    div.append(canvasWrapper)
-
-    const canvas = document.createElement("canvas");
-    canvas.setAttribute("role", "presentation");
-
-    canvas.hidden = true;
-    let isCanvasHidden = true;
-    const showCanvas = function () {
-      if (isCanvasHidden) {
-        canvas.hidden = false;
-        isCanvasHidden = false;
-      }
-    }
-
-    canvasWrapper.append(canvas);
-    this.canvas = canvas
-
-    const radio = window.devicePixelRatio || 1
-    this.radio = radio
-    const { width, height, scale } = viewport
-
-    const canvasWidth = Math.round(width * radio)
-    const canvasHeight = Math.round(height * radio)
-
-    canvas.width = canvasWidth
-    canvas.height = canvasHeight
-    const { style } = canvas;
-    style.width = Math.round(width) + "px"
-    style.height = Math.round(height) + "px"
-
-    this.paintedViewportMap.set(canvas, viewport)
-
-    const renderTask = (this.renderTask = this.internalRenderTask({
-      width,
-      height,
-      scale: scale * radio
-    }))
-
-    const resultPromise = renderTask.promise.then(
-      async () => {
-        showCanvas();
-        await this.finishRenderTask();
-
-        this.#renderTextLayer();
-
-          if (this.annotationLayer) {
-            await this._renderAnnotationLayer();
-          }
-
-          if (!this.annotationEditorLayer) {
-            const { annotationEditorUIManager, annotationStorage } = this.layerProperties();
-
-            if (!annotationEditorUIManager) {
-              return;
-            }
-            this.annotationEditorLayer = new PDFAnnotationLayer({
-              uiManager: annotationEditorUIManager,
-              annotationStorage,
-              pageIndex: this.pageIndex,
-              pageDiv: div,
-              viewport: this.viewport,
-              scale: this.scale,
-              annotations,
-              accessibilityManager: this._accessibilityManager,
-            });
-          }
-          this._renderAnnotationEditorLayer();
-
-          if (!this.compdfAnnotationLayer) {
-            this.compdfAnnotationLayer = new ComPDFAnnotationLayer({
-              documentViewer: this.documentViewer,
-              annotationStore: this.annotationStore,
-              messageHandler: this.messageHandler,
-              pageViewer: this,
-              annotations,
-              annotationsAll,
-              viewport: this.viewport,
-              scale: this.scale,
-              pageIndex: this.pageIndex,
-              pageDiv: div,
-              eventBus: this.eventBus,
-              selected: this.selected,
-              enableReply: this.enableReply,
-              $t: this.$t
-            })
-          }
-          this.compdfAnnotationLayer.render(this.viewport)
-
-          // this.AnnotationManager = new AnnotationManager({
-          //   annotations,
-          //   container: div,
-          //   viewport: this.viewport,
-          // })
-
-          if (!this.contentContainer) {
-            this.contentContainer = new ContentContainer({
-              annotationStore: this.annotationStore,
-              pageViewer: this,
-              annotations,
-              annotationsAll,
-              viewport: this.viewport,
-              scale: this.scale,
-              pageIndex: this.pageIndex,
-              pageDiv: div,
-              eventBus: this.eventBus,
-              selected: this.selected,
-              pagePtr: this.pagesPtr[this.pageIndex].pagePtr,
-              messageHandler: this.messageHandler,
-              $t: this.$t,
-              contentEditHistoryManager: this.contentEditHistoryManager
-            })
-            this.mode === 'editor' && this.contentContainer.init()
-          } else if (this.mode === 'editor') {
-            await this.contentContainer.render()
-          }
-
-          if (!this.textSelection) {
-            this.textSelection = new TextSelection({
-              viewport: this.viewport,
-              scale: this.scale,
-              pageIndex: this.pageIndex,
-              container: div,
-              eventBus: this.eventBus,
-              selected: this.selected,
-              pagePtr: this.pagesPtr[this.pageIndex],
-              messageHandler: this.messageHandler,
-              tool: this.tool,
-              toolMode: this.toolMode,
-              color: this.color,
-              pageViewer: this
-            })
-          }
-
-          if (!this.textSearch) {
-            this.textSearch = new TextSearch({
-              viewport: this.viewport,
-              scale: this.scale,
-              pageIndex: this.pageIndex,
-              container: div,
-              results: this.searchResults,
-            })
-            if (this.#activeSearch) {
-              this.textSearch.setActiveSearchResult(this.#activeSearch)
-            }
-          }
-
-          if (this.cropPage?.cropping) {
-            this.cropPage.draw()
-          }
-          if (!this.cropPage) {
-            this.cropPage = new CropPage({
-              viewport: this.viewport,
-              scale: this.scale,
-              pageIndex: this.pageIndex,
-              container: div,
-              eventBus: this.eventBus,
-              selected: this.selected,
-              pagePtr: this.pagesPtr[this.pageIndex],
-              messageHandler: this.messageHandler,
-              tool: this.tool,
-              toolMode: this.toolMode,
-              color: this.color,
-              pageViewer: this,
-              annotationStore: this.annotationStore
-            })
-          } else {
-            this.cropPage.updateInitialProps()
-          }
-          if (this.tool === 'cropPage') {
-            this.cropPage.init()
-          }
-      },
-      error => {
-        console.log(error)
-        return this.finishRenderTask(error);
-      }
-    )
-
-    div.setAttribute("data-loaded", true);
-
-    this.eventBus.dispatch("pagerender", {
-      source: this,
-      pageNumber: this.id,
-    });
-    return resultPromise
-  }
-
   internalRenderTask({
     width,
     height,

+ 1 - 1
packages/webview/src/components/Dialogs/SettingsDialog.vue

@@ -36,7 +36,7 @@
       <p class="title">{{ $t('header.settings.creationInfo') }}</p>
       <div class="version row">
         <span>{{ $t('header.settings.version') }}</span>
-        <span>2.5.1</span>
+        <span>2.5.2</span>
       </div>
 
       <template #footer>

+ 1 - 1
packages/webview/src/components/Dialogs/SignatureAppearanceDialog.vue

@@ -228,7 +228,7 @@ const getValue = (key) => {
       break
     case 'version':
       text.title = $t('signatures.appearanceDialog.ComPDFKitVersion')
-      text.value = '2.5.1'
+      text.value = '2.5.2'
       break
     case 'location':
       text.title = $t('signatures.appearanceDialog.location')

+ 0 - 1
packages/webview/src/components/DocumentContainer/DocumentContainer.vue

@@ -603,7 +603,6 @@ window.instances.UI.loadDocument = async (file, {
 .document.scrollHorizontal,
 .spread {
   white-space: nowrap;
-  text-align: center;
 
   .spread,
   .page {

+ 8 - 0
packages/webview/src/components/RightPanelPageMode/RightPanelPageMode.vue

@@ -61,11 +61,19 @@
   })
 
   const handleScrollMode = (mode, modeNum) => {
+    if (pageMode.value !== 0 && mode === 'Horizontal') {
+      core.switchSpreadMode(0)
+      useViewer.setPageMode(0)
+    }
     useViewer.setScrollMode(mode)
     core.switchScrollMode(modeNum)
   }
 
   const handleSpreadMode = (mode) => {
+    if (scrollMode.value === 'Horizontal') {
+      useViewer.setScrollMode('Vertical')
+      core.switchScrollMode(0)
+    }
     core.switchSpreadMode(mode)
     useViewer.setPageMode(mode)
   }