Skip to content

Write Roman front matter and body page labels with outlines - #61

Open
chroming wants to merge 4 commits into
masterfrom
codex/issue-60-page-labels
Open

chroming wants to merge 4 commits into
masterfrom
codex/issue-60-page-labels

Conversation

@chroming

@chroming chroming commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Closes #60

When the first body page is physical PDF page 31, exporting a directory now writes both the chapter outline targeting page 31 and PDF page labels that display that page as 1 (xxx on page 30, 1 on page 31). Existing page labels, including custom prefixes and multiple ranges, are preserved by default.

The GUI adds a reader-page-number option beside page offset, with an inferred or manually selected body start. The CLI exposes the same behavior through --page-labels roman-body and optional --body-start-page. Export validates page targets and labels, checks that the source did not change during writing, and replaces an existing output only after a verified temporary PDF is ready. The GUI confirms replacement, routes both typed paths and the Open dialog through the same unsaved-draft decision, and reports the final export status.

Validation:

  • 55 tests passed; the one deselected tests/test_convert.py::test_convert_dir_text also fails on unmodified origin/master.
  • Relevant PDF and GUI regression tests passed with the declared pypdf 3.17.4 dependency (10 passed).
  • CLI and macOS Cocoa GUI exports were reopened and checked: physical page 31 has label 1, and the chapter outline targets physical page 31.
  • Packaged-app and third-party PDF-reader checks were not run.

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review partially complete: 0 finding(s); 6 of 7 selected item(s) failed.

Comment thread src/gui/main.py Outdated
Comment thread src/gui/main.py
Comment thread src/gui/main.py Outdated
Comment thread src/pdf/pdf.py Outdated
Comment thread src/pdf/bookmark.py Outdated
Comment thread src/pdf/bookmark.py Outdated
Comment thread src/gui/main.py Outdated
Comment thread src/gui/main.py Outdated
Comment thread src/pdf/pdf.py Outdated
Comment thread src/pdf/bookmark.py Outdated
Comment thread src/gui/main.py
Comment thread run_cli.py
@chroming

Copy link
Copy Markdown
Owner Author

已在 a98fd91 处理审查意见:修复无效页码编辑导致切换 PDF 异常、导出权限回归和 CLI 越界报错;合并重复的页数读取、补充错误日志和校验;将新增 GUI 文案接入 Qt 翻译,并明确负页差时的手动操作。相关回归测试已补齐。当前测试为 60 passed、1 个既有失败(tests/test_convert.py::test_convert_dir_text,相关代码相对 origin/master 未改动)。

Windows 句柄那条未改:当前使用的 pypdf 3.17.4 在 PdfReader(path) 内通过 with open 读取到 BytesIO,随后立即关闭文件句柄;这里不会因 reader 持有临时文件句柄而阻止 os.replace。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] 非正文页自动使用罗马字符编号,正文页的标注页码从1开始

1 participant