Skip to content

fix(docx): style PAGE and NUMPAGES fields from their run#458

Merged
developer0hye merged 1 commit into
mainfrom
fix/docx-hf-field-run-style
Jul 25, 2026
Merged

fix(docx): style PAGE and NUMPAGES fields from their run#458
developer0hye merged 1 commit into
mainfrom
fix/docx-hf-field-run-style

Conversation

@developer0hye

Copy link
Copy Markdown
Owner

Summary

  • Carry the containing run's TextStyle on the PAGE and NUMPAGES field IR variants and render the counter under those properties.
  • Word applies the run's properties to a field result; office2pdf fell back to the document default, printing the number at roughly 11 pt black inside an 8 pt gray footer and inflating the line box.

Related issue

Fixes #450

Testing

  • cargo test --workspace (1832 tests, all pass)
  • cargo clippy --workspace --all-targets (clean)
  • cargo fmt --check
  • pdftotext -bbox on the page-1 footer of 05_technical_manual_en against the Word PDF
  • pdftoppm -r 150 plus a 300% crop of the footer line
  • magick compare -metric AE -fuzz 5% on the size-normalized page

Page-1 footer glyph boxes:

Glyph Word GT before after
- literal 797.55-806.40 800.68-808.18 798.99-806.50
1 field 797.55-806.40 796.67-809.21 798.99-806.50

In Word every glyph on the footer line shares one box. Before the fix the field's box was 12.54 pt against the literals' 7.51 pt; after, all three match.

Visual impact

  • No rendered PDF change
  • Rendered PDF change or visual evidence added
  • Reason:

Visual audit

  • Issue: DOCX: PAGE and NUMPAGES fields in headers/footers lose their run formatting #450
  • Fixture: tests/golden_mocks/business/sources/docx/05_technical_manual_en.docx
  • Page(s): 1 (page 2 carries the same footer and was also checked)
  • Renderer and DPI: pdftoppm, 150 DPI
  • Evidence mode: fix
  • New follow-up issues found in this audit: None
  • GT: assets/bugfixes/issue-450/gt.jpg
  • Before: assets/bugfixes/issue-450/before.jpg
  • After: assets/bugfixes/issue-450/after.jpg

Visual comparison

GT Before After
GT Before After

Required inspection

  • Rendered all evidence at 150 DPI or higher
  • Stored progressive JPEG quality 86 assets with metadata stripped
  • Inspected matched region crops at full resolution
  • Ran the 5% fuzz pixel-difference sweep
  • Inventoried hairlines and border dash styles
  • Inventoried font weight, italic, and underline emphasis

Deviation audit

Check Result
Page count/order Matches GT: two pages in the same order
Element presence Matches GT: header, header rule, headings, code blocks, and footer are all present
Position/size Fixed: the footer field now shares the literals' line box instead of standing 5 pt taller
Rotation/flip No deviation observed
Fill Matches GT: the F4F4F4 code-block shading is present
Stroke/border Matches GT: the 0.5 pt CCCCCC header rule is present at its w:space offset
Text content Matches GT
Font family/weight/style Fixed: the page number renders at the run's 8 pt instead of the document default
Text color Fixed: the page number renders in the run's 888888 instead of black
Alignment Matches GT: the footer stays centered
Line/paragraph spacing Remaining: #452 tracks consecutive Courier New paragraphs advancing tighter than Word
Clipping/overflow No deviation observed

Checklist

  • Commits include a Signed-off-by line
  • PR scope contains one root cause
  • Remaining visual deviations each reference an open issue

Word applies the containing run's properties to a field result, so a
footer written as an 8 pt gray run with a `PAGE` field prints the number
at 8 pt gray. office2pdf dropped the run properties and fell back to the
document default, printing the number at roughly 11 pt black and
inflating the footer's line box.

Carry the run's `TextStyle` on the field IR variants and emit the counter
under those properties.

Fixes #450

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
@developer0hye
developer0hye merged commit 581edaa into main Jul 25, 2026
17 checks passed
@developer0hye
developer0hye deleted the fix/docx-hf-field-run-style branch July 25, 2026 11:45
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.

DOCX: PAGE and NUMPAGES fields in headers/footers lose their run formatting

1 participant