Skip to content

fix(java): align DOCX rendering with Word for Latin documents - #188

Merged
shps951023 merged 1 commit into
mainfrom
fix/java-docx-visual-parity
Sep 19, 2026
Merged

shps951023 merged 1 commit into
mainfrom
fix/java-docx-visual-parity

Conversation

@shps951023

Copy link
Copy Markdown
Member

Summary

Fixes #187 — aligns the Java DOCX renderer with Word for Latin documents, bringing 14_Thesis_Chapter to 0.9932 (text similarity 1.0, 2/2 pages).

Changes

  • Style text colors — paragraph-style rPr/w:color applied to runs without explicit color (Heading2 blue 4F81BD).
  • Bullet markers — resolve numPrabstractNumlvl; Symbol PUA bullet (\uF0B7) maps to .
  • Width metrics — mirror .NET EstimateCalibrTextWidth/EstimateWrapTextWidth: Calibri-default documents use calibrated tables; other defaults wrap with actual TTF advances; center/right alignment uses actual font advances.
  • Paragraph flowcontextualSpacing collapse, keepNext widow control, top-of-page baseline (font ascent), spacing-before suppression at page top, no spacing collapse across tables.
  • Tables — auto-width table indent -108 twips, cell vertical margin 0, spacing tuned to Word/LibreOffice.
  • Bullet line height — Symbol label advance 16.7pt (factor 1.21).

All changes are in PoiDocxRenderer.java.

Validation

  • mvn test: 78/79 passing (issues66 CJK smoke test fixed; one pre-existing Vietnamese issue91 extraction failure remains).
  • 14_Thesis_Chapter: 0.9856 → 0.9932 (text 1.0, visual 0.983, 2/2 pages).
  • Full issue/docx benchmark: 0.7224 average (28 cases).

- Resolve paragraph-style text colors (Heading blue 4F81BD) and bullet
  markers from numbering definitions
- Mirror .NET width metrics: Calibri-default documents use calibrated
  tables, other defaults wrap with actual TTF advances
- Position center/right aligned text with actual font advances
- Implement contextualSpacing, keepNext widow control, and top-of-page
  baseline (font ascent) with spacing-before suppression
- Align auto-width table indent (-108 twips), cell vertical margin (0),
  and table spacing with Word/LibreOffice
- Symbol-font bullet line height (1.21 factor) for Word parity

Validation: 14_Thesis_Chapter 0.9856 -> 0.9932 (text similarity 1.0,
2/2 pages); issues66 CJK smoke test fixed; full issue/docx benchmark
average 0.7224.
@shps951023
shps951023 merged commit 85bbbdb into main Sep 19, 2026
19 of 20 checks passed
@shps951023
shps951023 deleted the fix/java-docx-visual-parity branch September 19, 2026 07:06
@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: ff1559d2-ab50-4cfb-92a3-fea1a30d6a96

📥 Commits

Reviewing files that changed from the base of the PR and between 28cbae2 and d4859dd.

📒 Files selected for processing (1)
  • minipdf-java/minipdf/src/main/java/io/github/minisoftware/minipdf/internal/docx/PoiDocxRenderer.java
 ____________________________________________________________________________________________________________________________________________________
< There are no final decisions. No decision is cast in stone. Instead, consider each as being written in the sand at the beach, and plan for change. >
 ----------------------------------------------------------------------------------------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

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.

Java DOCX renderer: align Latin document layout with Word (14_Thesis_Chapter)

1 participant