From 4339f94e10764d0888ad4387d29444e951e69d53 Mon Sep 17 00:00:00 2001 From: Richard Eckart de Castilho Date: Mon, 4 Mar 2024 18:50:03 +0100 Subject: [PATCH] #4587 - Annotations are misaligned when PDF pages vary in dimensions - Adjustment has to be made not only if first page is larger but also if first page is smaller than subsequent pages --- .../src/main/ts/src/pdfanno/core/src/render/renderSpan.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inception/inception-pdf-editor2/src/main/ts/src/pdfanno/core/src/render/renderSpan.ts b/inception/inception-pdf-editor2/src/main/ts/src/pdfanno/core/src/render/renderSpan.ts index ff432cad443..f56535e7b58 100644 --- a/inception/inception-pdf-editor2/src/main/ts/src/pdfanno/core/src/render/renderSpan.ts +++ b/inception/inception-pdf-editor2/src/main/ts/src/pdfanno/core/src/render/renderSpan.ts @@ -32,7 +32,9 @@ export function mapToDocumentCoordinates (aRectangles: Rectangle[]): Rectangle[] const pageTopY = pageContainer.offsetTop / scale + paddingTop + marginBetweenPages let leftOffset = 0 - if (firstPageElement.clientWidth > pageContainer.clientWidth) { + // If the pages are not rendered left-aligned because one is wider than the other, we need + // to adjust the position of the rectangle on the X-axis + if (firstPageElement.clientWidth != pageContainer.clientWidth) { const firstContainerStyle = getComputedStyle(firstPageElement) const firstPageLeft = parseInt(firstContainerStyle.marginLeft) + parseInt(firstContainerStyle.borderLeftWidth) const currentPageStyle = getComputedStyle(pageContainer)