Skip to content

ROB: Extract text with zero width in layout mode - #4174

Merged
stefan6419846 merged 1 commit into
py-pdf:mainfrom
RavSinghChandan:layout-zero-char-width
Oct 12, 2026
Merged

stefan6419846 merged 1 commit into
py-pdf:mainfrom
RavSinghChandan:layout-zero-char-width

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

Text drawn with a font size of 0, as in

BT /F1 0 Tf (Hello) Tj ET

made extract_text(extraction_mode="layout") raise "ZeroDivisionError: float floor division by zero": every glyph has zero width, so the page's fixed character width is 0 and fixed_width_page() divides by it. A horizontal scaling of 0 (0 Tz) does the same.

When the character width is 0 there is no column to align to, so the text is now placed where the line already ends: the example extracts as "Hello", matching plain mode.

The full suite passes locally (1930 tests), and the changed line is covered.

Used Claude Code (Claude Opus 5.5) to help find and patch this and to draft this description; I reviewed and tested the change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.14%. Comparing base (c64a4e4) to head (b25571d).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4174   +/-   ##
=======================================
  Coverage   98.14%   98.14%           
=======================================
  Files          59       59           
  Lines       11689    11689           
  Branches     2191     2191           
=======================================
  Hits        11472    11472           
  Misses        123      123           
  Partials       94       94           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stefan6419846
stefan6419846 merged commit ece7730 into py-pdf:main Oct 12, 2026
21 checks passed
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.

2 participants