modesty / modesty/pdf2json

`getRawTextContent` does not returns words' pieces in proper coordinate order

Open
#421 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
2.2k
Forks
394
Avg merge
3d 5h
Merged PRs (30d)
7

Description

Hey,

getRawTextContent seems to assume that word pieces in the bidiTexts array appear in ascending order of their y coordinate but they probably do appear as they are being added by the PDF rendering software. I have a file where a line of text looking on screen like

Some label 12.3 4455

appears in that array as

Some label | 3 | . | 2 | 1 | 5 | 5 | 4 | 4

that is, the character groups are properly following one after the other but the order of individual characters within the groups is reversed. And getRawTextContent() naively returns

Some label 3.21 5544

The y number of each item correctly shows the correct position but the code is not considering that (it only checks the absolute y difference).

So I wonder if this has a known solution before I go and change the code myself?

Cheers for the nice work.

Contributor guide

No contributing guide indexed for this repository

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 by locating getRawTextContent and inspect how bidiTexts items are ordered and how their y coordinates are handled. Reproduce the reported sequence with the example PDF or an equivalent fixture; done means extracted text preserves the intended coordinate order for reversed character groups.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.