Skip to content

Commit c68cfba

Browse files
committed
fix redaction coordinates for PDF pages rotated by 90°/270°
1 parent 415063d commit c68cfba

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

frontend/javascript/components/redaction/pdf-redaction.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,10 @@ export default {
673673
// - but would have to limit effective canvas size to prevent crashes
674674
renderDensityFactor = Math.max(minRenderWidth / window.innerWidth, 1.0)
675675
676-
this.intrinsicPageWidth = page.view[2]
677-
this.intrinsicpageHeight = page.view[3]
676+
// is the page rotated by ±{90, 270}?
677+
const flipWidthHeight = Math.abs(page.rotate) % 180 === 90
678+
this.intrinsicPageWidth = flipWidthHeight ? page.view[3] : page.view[2]
679+
this.intrinsicPageHeight = flipWidthHeight ? page.view[2] : page.view[3]
678680
this.scaleFactor = (renderDensityFactor * maxWidth) / this.intrinsicPageWidth
679681
const viewport = page.getViewport({ scale: this.scaleFactor })
680682
@@ -687,6 +689,9 @@ export default {
687689
const wPx = viewport.width / renderDensityFactor + 'px'
688690
const hPx = viewport.height / renderDensityFactor + 'px'
689691
console.log('PdfRedaction loadPage', {
692+
flipWidthHeight,
693+
page,
694+
viewport,
690695
renderDensityFactor,
691696
scaleFactor: this.scaleFactor,
692697
maxWidth,

0 commit comments

Comments
 (0)