Skip to content

[Bug]: Text extraction interleaves columns in multi-column (two-column) PDF layouts #457

Description

@yllumi

Is there an existing issue for this?

  • I have searched the existing issues and found no similar reports

Are you using the latest version of this package?

  • The issue I'm reporting exists in the latest release

Can other PDF readers read the file?

  • The PDF I'm trying to read opens correctly in at least one other PDF reader

When running this snippet

$document = (new PdfParser())->parseFile('/path/to/file.pdf');

I run into the following issue/exception (Please attach the pdf)

Hi there!

First of all, thank you for maintaining this library. I encountered an issue when parsing PDF files that have a two-column text layout.

When extracting text from a PDF with two columns, the parser fails to read down the first column completely before moving to the second one. Instead, it interleaves (mixes up) the text from Column 1 and Column 2 line-by-line or section-by-section.

This results in a scrambled text output where sentences from both columns are merged together.

Interestingly, the smalot/pdfparser package handles this specific two-column layout correctly and preserves the correct reading order. I am hoping we can achieve similar layout-aware parsing in this package.

two-column.pdf

Do you allow attachment files to be used in tests to prevent regressions?

  • Yes, I give permission to use this file as a test file to prevent future regressions (And am authorized to give this permission)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions