Skip to content

bug: preserve word boundaries in wrapped PDF table cells #403

Closed

Description

@danny-avila

The extraction worker uses the default page.extract_text() mode. With the pinned pypdf 6.21.4, wrapped PDF table-cell lines can lose their word boundary while extraction still succeeds.

Reproduced through the real packages/extraction/worker/extract.py pdf entry point using a synthetic Helvetica table header: a row label at baseline 700 and adjacent two-line cells at baselines 706 and 694.

Observed worker result (exit 0):

{"kind":"page","index":1,"text":"Row AlphaBeta GammaDelta"}

Expected: retain boundaries between Alpha and Beta, and between Gamma and Delta (spaces or line breaks).

Upstream reproducer and analysis: py-pdf/pypdf#4254
Upstream fix: py-pdf/pypdf#4255

This is a compatibility follow-up to the security update in #380. Evaluate a tested backport or a qualified newer pypdf release; do not restore the vulnerable older pin merely to recover spacing. The worker uses private pypdf hooks for resource limits, so a major upgrade needs explicit compatibility and rejection-path coverage.

Acceptance:

  • Add the synthetic wrapped-cell PDF as a regression fixture and test the real worker result, not just nonempty extraction.
  • Preserve word boundaries for both wrapped cells.
  • Retain the PDF resource-limit, malformed-input, decompression-limit, and container isolation checks.

Activity

  1. danny-avila commented on Nov 17, 2026

    @danny-avila
    CollaboratorAuthor

    Fix published in #405: upgrade pypdf to 7.1.0 and add a wrapped-table fixture plus an extraction-endpoint regression assertion. The committed fixture reproduces merged words through the real worker on 6.21.4 and preserves all five words on 7.1.0. Local qualification passed 84 worker cases, all 19 unit tests, and the full container/isolation suite; GitHub extraction CI also passed. Exact-head review and remaining CI are being monitored.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions