diff --git a/apps/web/src/PrecisePdfPreview.tsx b/apps/web/src/PrecisePdfPreview.tsx
index e29745a..328ef09 100644
--- a/apps/web/src/PrecisePdfPreview.tsx
+++ b/apps/web/src/PrecisePdfPreview.tsx
@@ -19,13 +19,16 @@ import {
import pdfWorkerUrl from "pdfjs-dist/build/pdf.worker.min.mjs?url";
import {
getPdfCanvasRenderScale,
- getPdfPageCssDimensions
+ getPdfPageCssDimensions,
+ getPrecisePdfDocumentWidth
} from "./pdf-page-geometry";
import { createPdfAnnotationLinkService } from "./pdf-annotation-links";
import { PdfPageRenderQueue } from "./pdf-render-queue";
GlobalWorkerOptions.workerSrc = pdfWorkerUrl;
+const PRECISE_PDF_INLINE_GUTTER = 30;
+
type PdfJsAnnotationLinkService = Parameters<
AnnotationLayer["render"]
>[0]["linkService"];
@@ -455,8 +458,17 @@ export function PrecisePdfPreview({
return
正在读取精确预览…
;
}
+ const documentWidth = getPrecisePdfDocumentWidth(
+ pages.map((page) => page.width),
+ zoomPercent / 100,
+ PRECISE_PDF_INLINE_GUTTER
+ );
+
return (
-
+
{pages.map((page) => (
{
);
expect(getPdfCanvasRenderScale(0, 800, 2)).toBe(0);
});
+
+ it.each([
+ [50, 457],
+ [100, 854],
+ [120, 1013],
+ [400, 3235]
+ ])("在 %i%% 缩放下把双侧固定留白计入滚动宽度", (zoom, expected) => {
+ expect(
+ getPrecisePdfDocumentWidth(
+ [595.275591],
+ zoom / 100,
+ 30
+ )
+ ).toBe(expected);
+ });
+
+ it("按混合纸张中最宽页面计算精确预览滚动宽度", () => {
+ expect(
+ getPrecisePdfDocumentWidth([595.275591, 792], 1.2, 30)
+ ).toBe(1328);
+ expect(getPrecisePdfDocumentWidth([], 1.2, 30)).toBe(0);
+ });
});
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index dfae03e..8ece731 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -346,6 +346,13 @@ SHA-256;交互模式仅在文件存在且哈希正确时显示默认勾选项
本阶段按版本策略未提前修改应用的 `0.5.1` 版本号;正式 `v0.6.0` 发布
提交升级版本后,字体包才满足其 `minimumAppVersion=0.6.0` 运行时门禁。
+已修复 `v0.5.1` 遗留的精确预览放大后右侧留白丢失问题。精确 PDF 文档
+容器现在按当前缩放下最宽页面加左右各 30px 显式计算自身宽度,页面较小
+时仍由 `min-width: 100%` 居中,页面溢出时双侧留白则稳定进入横向
+`scrollWidth`。真实 Chromium 在 100%、120% 和 400% 下滚动到最右端,
+文档右侧留白分别约为 30.38px、30.05px 和 30.45px;120% 与 400%
+均准确到达各自最大横向滚动值,快速和连续预览结构未改变。
+
## 2. 已完成
### 2.1 项目骨架