From 6328a2783ebb36ee4df5a4fa58ff4bfad8e1dd8f Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Thu, 11 Dec 2025 14:50:45 +0000 Subject: [PATCH] fix(DeDocumentViewer): Account for toolbar and padding when calculating Fit Page zoom in viewer --- changelog.md | 6 ++++++ ts/00_commitinfo_data.ts | 2 +- ts_web/00_commitinfo_data.ts | 2 +- ts_web/elements/viewer.ts | 9 +++++++-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 3894275..afbb6e4 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2025-12-11 - 2.0.6 - fix(DeDocumentViewer) +Account for toolbar and padding when calculating Fit Page zoom in viewer + +- calculateFitPage now subtracts explicit top (toolbar + padding), bottom, and side paddings from viewport dimensions before computing scale. +- This produces a more accurate zoom level for the Fit Page preset by considering toolbar height and page margins. + ## 2025-12-11 - 2.0.2 - fix(page) Use theme variables for page styling, make pagecontainer background theme-aware, and use accent background for footer separator diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 67f611e..2a0c9e5 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@design.estate/dees-document', - version: '2.0.2', + version: '2.0.6', description: 'A sophisticated framework for dynamically generating and rendering business documents like invoices with modern web technologies, featuring PDF creation, templating, and automation.' } diff --git a/ts_web/00_commitinfo_data.ts b/ts_web/00_commitinfo_data.ts index 67f611e..2a0c9e5 100644 --- a/ts_web/00_commitinfo_data.ts +++ b/ts_web/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@design.estate/dees-document', - version: '2.0.2', + version: '2.0.6', description: 'A sophisticated framework for dynamically generating and rendering business documents like invoices with modern web technologies, featuring PDF creation, templating, and automation.' } diff --git a/ts_web/elements/viewer.ts b/ts_web/elements/viewer.ts index 800ed47..709f3c0 100644 --- a/ts_web/elements/viewer.ts +++ b/ts_web/elements/viewer.ts @@ -739,8 +739,13 @@ export class DeDocumentViewer extends DeesElement { const viewport = this.shadowRoot?.querySelector(".viewport"); if (!viewport) return; - const viewportHeight = viewport.clientHeight - 32; // Account for padding - const viewportWidth = viewport.clientWidth - 32; + // Account for padding: top = toolbar (40px) + 16px, bottom = 16px margin for visibility + const topPadding = 40 + 16; // toolbar height + padding + const bottomPadding = 16; // some margin at bottom + const sidePadding = 32; // 16px each side + + const viewportHeight = viewport.clientHeight - topPadding - bottomPadding; + const viewportWidth = viewport.clientWidth - sidePadding; const scaleByHeight = viewportHeight / plugins.shared.A4_HEIGHT; const scaleByWidth = viewportWidth / plugins.shared.A4_WIDTH;