Fix DOCX employee directory rendering - #161
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe change preserves DOCX border spacing and paragraph offsets, aligns inline images and selected heading text, and embeds bold Calibri through the Unicode font path. Tests and benchmark data validate paragraph layout and converted output. ChangesDOCX paragraph rendering
Estimated code review effort: 3 (Moderate) | ~25 minutes ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🟡 Changes recommended
Border spacing and border-space parsing changes introduce correctness risks (corner-join alignment and locale-dependent parsing) that should be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR improves DOCX-to-PDF fidelity for the “employee directory with photo” scenario by refining paragraph spacing/border rendering, image-only paragraph layout, and Calibri bold font embedding, plus adding targeted regression tests and updating benchmark artifacts.
Changes:
- Preserve first-paragraph spacing-before at the top of page 1 and keep empty bordered separator paragraphs consistent (including border spacing behavior).
- Adjust inline image-only paragraph vertical alignment and tweak Calibri bold heading baseline alignment.
- Embed Calibri Bold when available and add/refresh focused regression tests + benchmark report updates.
File summaries
| File | Description |
|---|---|
| tests/MiniPdf.Tests/DocxToPdfConverterTests.cs | Adds focused regression tests for spacing-before, empty bordered paragraphs, and image-only paragraph alignment. |
| tests/MiniPdf.Benchmark/reports_docx/comparison_report.json | Updates benchmark report metrics/artifacts to reflect improved rendering scores. |
| src/MiniPdf/PdfWriter.cs | Adds preferred-font embedding gating logic (including Calibri bold embedding) and maps “Calibri Bold” to a system font file. |
| src/MiniPdf/DocxToPdfConverter.cs | Updates paragraph spacing behavior for the very first paragraph, renders borders for empty bordered paragraphs, adjusts image rendering API and heading baseline. |
| src/MiniPdf/DocxReader.cs | Parses paragraph border spacing (w:space) into the border model. |
Review details
- Files reviewed: 5/7 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| var space = float.TryParse(el.Attribute(W + "space")?.Value, out var parsedSpace) | ||
| ? parsedSpace | ||
| : 0f; |
| if (borders.Left != null) | ||
| state.CurrentPage.AddLine(paragraphLeft - borders.Left.Space, paragraphTop + borders.Left.Space, | ||
| paragraphLeft - borders.Left.Space, paragraphBottom - borders.Left.Space, borders.Left.Color, borders.Left.Width); |
| if (borders.Right != null) | ||
| state.CurrentPage.AddLine(paragraphRight + borders.Right.Space, paragraphTop + borders.Right.Space, | ||
| paragraphRight + borders.Right.Space, paragraphBottom - borders.Right.Space, borders.Right.Color, borders.Right.Width); |
Summary
Validation
dotnet test tests/MiniPdf.Tests: 192/192 passedscripts/Run-Benchmark_docx.ps1 -Filter "employee_directory_with_photo"Summary by CodeRabbit
Bug Fixes
Tests