getRawTextContent() returns the lines of every page in reverse order (bottom to top) since 4.0.3
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 90/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, node.js
Direzione di ricerca
Leggi lib/pdftextsorter.js ed esamina l’ordinamento delle righe descritto nell’issue. Verifica in che modo le coordinate y di bidiTexts corrispondono all’ordine visivo della pagina, poi esegui la riproduzione fornita con tre righe e verifica che getRawTextContent() emetta First, Second, Third line in quest’ordine, seguito dall’interruzione di pagina.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Since 4.0.3, getRawTextContent() (and the CLI's -c content output) emits each page's lines from the bottom of the page to the top. A plain three-line page comes out last line first.
Reproduction (npm i [email protected], run with node repro.mjs):
import fs from "node:fs";
import PDFParser from "pdf2json";
// one page, three lines drawn top to bottom (y = 700, 680, 660)
const content = "BT /F1 12 Tf 72 700 Td (First line) Tj 0 -20 Td (Second line) Tj 0 -20 Td (Third line) Tj ET";
const objs = [
"<< /Type /Catalog /Pages 2 0 R >>",
"<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /Font << /F1 4 0 R >> >> /Contents 5 0 R >>",
"<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>",
`<< /Length ${content.length} >>\nstream\n${content}\nendstream`,
];
let pdf = "%PDF-1.4\n";
const offsets = objs.map((o, i) => { const off = pdf.length; pdf += `${i + 1} 0 obj\n${o}\nendobj\n`; return off; });
const xref = pdf.length;
pdf += `xref\n0 ${objs.length + 1}\n0000000000 65535 f \n` + offsets.map(o => `${String(o).padStart(10, "0")} 00000 n \n`).join("");
pdf += `trailer\n<< /Size ${objs.length + 1} /Root 1 0 R >>\nstartxref\n${xref}\n%%EOF\n`;
const parser = new PDFParser(null, true);
parser.on("pdfParser_dataError", (e) => console.error(e.parserError));
parser.on("pdfParser_dataReady", () => console.log(JSON.stringify(parser.getRawTextContent())));
fs.writeFileSync("lines.pdf", pdf, "latin1");
parser.loadPDF("lines.pdf");
Actual (pdf2json 4.0.3, 4.1.0, 4.1.1 / master 5edaa03 on Node v26.13.0):
"Third line\r\nSecond line\r\nFirst line\r\n----------------Page (0) Break----------------\r\n"
Expected (what 4.0.2 and pdftotext lines.pdf - produce):
"First line\r\nSecond line\r\nThird line\r\n----------------Page (0) Break----------------\r\n"
The same happens with ordinary PDFs, such as the Google Docs sample.pdf attached to #421 (comment of 2026-04-28).
The spatial sort added in #422 (lib/pdftextsorter.js, lines.sort((a, b) => a[0].y - b[0].y)) sorts lines by ascending y, but bidiTexts y coordinates are in PDF user space where y grows upward, so ascending y orders lines from bottom to top instead of top to bottom (lines.sort((a, b) => b[0].y - a[0].y)).
Credit: https://ucsbplse.github.io/
- Lingua principale
- Java
- Stelle
- 2.2k
- Fork
- 396
- Merge medio
- 9g 19h
- PR unite (30g)
- 3
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modesty/pdf2json
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
-
`getRawTextContent` does not returns words' pieces in proper coordinate orderForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
help-wanted: type3-font not-supported
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
Tutte le issue di modesty/pdf2json
Issue simili
-
bug subsystem:agent-harness triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ShaftHQ/SHAFT_ENGINE#7797 ·
I maintainer di solito rispondono entro 1 giorno
-
ARM: Q flag should be stickyAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
NationalSecurityAgency/ghidra#10155 ·
I maintainer di solito rispondono entro 2 giorni
-
area:data coverage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 67/100
reacher-z/Awesome-CUA#4864 ·
I maintainer di solito rispondono entro 19 giorni
-
bug web-ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
jenkinsci/jenkins#27705 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
"item-tooltip-keyboard-fix" crashes the game when opening the Items tab of the statistics menuApertamod bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
elmital/FixMCStats#65 · 3 commenti ·