smalot / smalot/pdfparser

getDataTm() positions wrong?

Open
#671 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
2.7k
Forks
579
Avg merge
2m
Merged PRs (30d)
1

Description

  • PHP Version: 7.3.25
  • PDFParser Version: latest
Description:

I'm giving PDFParser a try, but already I can see that the positions reported when using getDataTm() seem to have various issues.

In one PDF, an invoice, all elements but one were reported as having the same Y coordinate (10.0049). Most of the X coordinates look wrong as well, like an element on the left has a higher X coordinate than an element on the right, and the numbers themselves don't seem right either. E.g. an element roughly in the middle of the page has X = 3.66, but then an element to the left has X = 37.1.

I tried another PDF, another invoice, and looked specifically at one of the invoice lines. My own parser gave mt this:

[553.19] => Array // <- Y coordinate
(
[46.84] => 1
[66.83] => GSC12708
[156.84] => Jujutsu Kaisen 0 Nendoroid Action Figure
[361.72] => 5
[396.08] => 27.36
[429.30] => 1,50 %
[481.08] => 26.95
[526.52] => 134.75
)
[543.19] => Array
(
[156.84] => Suguru Geto: Jujutsu Kaisen 0 Ver. 10 cm
)

This shows one line of several elements with the same Y coordinate (553.19), and one element at a different Y coordinate (the description of the item went onto two lines).

In PDFParser, the Y coordinates of those two description elements are swapped! The one beginning "Jujutsu" says 543.19, the one beginning Suguru says 553.19.

I am missing something here, or is it just broken?

PDF input
Expected output & actual output
Code

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the getDataTm() entry point and reproduce the reported coordinate behavior using the invoice examples described in the issue. The report does not include the PDF files, parsing code, or named tests, so first obtain a reproducible input and determine whether the extracted X and Y coordinates differ from the PDF positions before defining a fix and regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.