Unable to parse text from a valid pdf
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- backend
Research direction
Reproduce the problem with the linked laudo.pdf using extractPageTextsFromPdf and the PDFParser parseBuffer entry point. Trace how page text and character encodings are represented before decodePdfPageTexts; done means the extracted first-page text is readable rather than the shown incorrect characters.
Written by the indexing model from the issue text.
Description
Trying to extract the text from the following pdf gives wrong characters.
input pdf:
laudo.pdf
Fragment extracted from the 1st page:
䴀䄀吀䔀刀䤀䄀䰀 ⴀ 匀䄀一䜀唀䔀
䠀䔀䴀伀䜀刀䄀䴀䄀
Code used to extract text:
async function extractPageTextsFromPdf(pdfBuffer: Buffer): Promise<string[]> {
const pdfParser = new PDFParser(null, true, '');
function decodePdfPageTexts(texts: Text[]) {
return decodeURIComponent(
texts.map((t) =>t.R.map((tt) => tt.T).join(' ')).join(' ')
);
}
const texts: Promise<string[]> = new Promise((resolve, reject) => {
pdfParser.on('pdfParser_dataReady', (pdfData) => {
const { Pages: pages } = pdfData;
const tx = pages.map((p) => p.Texts).map(decodePdfPageTexts);
resolve(tx);
});
pdfParser.on('pdfParser_dataError', (errData) => {
reject(errData.parserError);
});
pdfParser.parseBuffer(pdfBuffer);
});
return texts;
}
- Dominant language
- Java
- Stars
- 2.2k
- Forks
- 396
- Avg merge
- 9d 19h
- Merged PRs (30d)
- 3
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modesty/pdf2json
-
getRawTextContent() returns the lines of every page in reverse order (bottom to top) since 4.0.3Open
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
-
`getRawTextContent` does not returns words' pieces in proper coordinate orderPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
All issues in modesty/pdf2json
Similar issues
-
bug subsystem:agent-harness triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ShaftHQ/SHAFT_ENGINE#7797 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
NationalSecurityAgency/ghidra#10155 ·
Maintainers usually reply within 2 days
-
area:data coverage
Difficulty 1/5 Under an hour Newbie friendliness 67/100
reacher-z/Awesome-CUA#4864 ·
Maintainers usually reply within 19 days
-
bug web-ui
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
jenkinsci/jenkins#27705 · 3 comments ·
Maintainers usually reply within 1 day
-
mod bug
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
elmital/FixMCStats#65 · 3 comments ·