diff --git a/src/display/editor/draw.js b/src/display/editor/draw.js index faaeb516a..2ef564076 100644 --- a/src/display/editor/draw.js +++ b/src/display/editor/draw.js @@ -988,7 +988,7 @@ class DrawingEditor extends AnnotationEditor { /** @inheritdoc */ renderAnnotationElement(annotation) { annotation.updateEdited({ - rect: this.getRect(0, 0), + rect: this.getPDFRect(), }); return null; diff --git a/src/display/editor/editor.js b/src/display/editor/editor.js index 1d282ebe9..452028d24 100644 --- a/src/display/editor/editor.js +++ b/src/display/editor/editor.js @@ -1572,6 +1572,15 @@ class AnnotationEditor { } } + /** + * Get the rect in page coordinates without any translation. + * It's used when serializing the editor. + * @returns {Array} + */ + getPDFRect() { + return this.getRect(0, 0); + } + /** * Executed once this editor has been rendered. * @param {boolean} focus - true if the editor should be focused. diff --git a/src/display/editor/freetext.js b/src/display/editor/freetext.js index da947d61f..18b49d3e8 100644 --- a/src/display/editor/freetext.js +++ b/src/display/editor/freetext.js @@ -770,6 +770,12 @@ class FreeTextEditor extends AnnotationEditor { return this.editorDiv; } + /** @inheritdoc */ + getPDFRect() { + const padding = FreeTextEditor._internalPadding * this.parentScale; + return this.getRect(padding, padding); + } + /** @inheritdoc */ static async deserialize(data, parent, uiManager) { let initialData = null; @@ -833,8 +839,7 @@ class FreeTextEditor extends AnnotationEditor { return this.serializeDeleted(); } - const padding = FreeTextEditor._internalPadding * this.parentScale; - const rect = this.getRect(padding, padding); + const rect = this.getPDFRect(); const color = AnnotationEditor._colorManager.convert( this.isAttachedToDOM ? getComputedStyle(this.editorDiv).color @@ -901,9 +906,8 @@ class FreeTextEditor extends AnnotationEditor { content.append(div); } - const padding = FreeTextEditor._internalPadding * this.parentScale; const params = { - rect: this.getRect(padding, padding), + rect: this.getPDFRect(), }; params.popup = this.hasEditedComment ? this.comment diff --git a/src/display/editor/highlight.js b/src/display/editor/highlight.js index 59aec20d1..a4fe5ba6a 100644 --- a/src/display/editor/highlight.js +++ b/src/display/editor/highlight.js @@ -1023,7 +1023,7 @@ class HighlightEditor extends AnnotationEditor { return this.serializeDeleted(); } - const rect = this.getRect(0, 0); + const rect = this.getPDFRect(); const color = AnnotationEditor._colorManager.convert( this._uiManager.getNonHCMColor(this.color) ); @@ -1064,7 +1064,7 @@ class HighlightEditor extends AnnotationEditor { return null; } const params = { - rect: this.getRect(0, 0), + rect: this.getPDFRect(), }; if (this.hasEditedComment) { params.popup = this.comment; diff --git a/src/display/editor/stamp.js b/src/display/editor/stamp.js index bc59ae615..cf5f50d73 100644 --- a/src/display/editor/stamp.js +++ b/src/display/editor/stamp.js @@ -845,7 +845,7 @@ class StampEditor extends AnnotationEditor { annotationType: AnnotationEditorType.STAMP, bitmapId: this.#bitmapId, pageIndex: this.pageIndex, - rect: this.getRect(0, 0), + rect: this.getPDFRect(), rotation: this.rotation, isSvg: this.#isSvg, structTreeParentId: this._structTreeParentId, @@ -935,7 +935,7 @@ class StampEditor extends AnnotationEditor { return null; } const params = { - rect: this.getRect(0, 0), + rect: this.getPDFRect(), }; if (this.hasEditedComment) { params.popup = this.comment;