qpdj_obj is unknown when a fonts /ToUnicode is not a stream
Los mantenedores suelen responder en 5 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 58/100
Línea de trabajo
The report includes a minimal PDF reproduction and points to page_font.h, specifically the final else in init_cmap. Start by reading that function and the font parsing tests, then run the reproduction with the supplied PDF. Done means the page parses and returns Hello when /ToUnicode refers to a non-stream object; the suggested fix in the issue is unverified.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hello. I ran into a fun edge case today on one of my documents. It looks like when a fonts /ToUnicode entry is not a tsream or a name, the page gets dropped, which shows up downstream as "Page N failed to parse".
I believe this is an edge case but here is a minimal reproduction:
from docling_parse.pdf_parser import DoclingPdfParser
content = b"BT /F1 12 Tf 20 50 Td (Hello) Tj ET"
objects = [
b"<< /Type /Catalog /Pages 2 0 R >>",
b"<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
b"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 100]"
b" /Resources << /Font << /F1 5 0 R >> >> /Contents 4 0 R >>",
b"<< /Length %d >>\nstream\n%s\nendstream" % (len(content), content),
b"<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /ToUnicode 6 0 R >>",
b"<< /MCID 4 >>",
]
pdf = bytearray(b"%PDF-1.4\n")
offsets = []
for i, obj in enumerate(objects, start=1):
offsets.append(len(pdf))
pdf += b"%d 0 obj\n%s\nendobj\n" % (i, obj)
xref = len(pdf)
pdf += b"xref\n0 %d\n0000000000 65535 f \n" % (len(objects) + 1)
pdf += b"".join(b"%010d 00000 n \n" % off for off in offsets)
pdf += b"trailer\n<< /Size %d /Root 1 0 R >>\nstartxref\n%d\n%%%%EOF\n" % (len(objects) + 1, xref)
with open("repro_tounicode.pdf", "wb") as f:
f.write(pdf)
page = DoclingPdfParser().load("repro_tounicode.pdf").get_page(1)
# RuntimeError: qpdf_obj is unknown: 6 0 R
print([cell.text for cell in page.textline_cells]) # expected: ['Hello']
That same pdf gets read by pypdfium2.PdfDocument(BytesIO(pdf)[0].get_textpage().get_text_range()
I get this on docling-parse 7.22.2 and latest (7.24.2).
Claude Recommended Fix
In page_font.h, in the final else of init_cmap, set cmap_initialized = false, this way parsed fonts are unaffected
- Lenguaje dominante
- C++
- Estrellas
- 346
- Forks
- 92
- Merge medio
- 4 d 3 h
- PR fusionados (30 d)
- 26
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de docling-project/docling-parse
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
docling-project/docling-parse#448 ·
Los mantenedores suelen responder en 5 días
-
Text is lost when a `TJ` array is split across two content streams of a pagePosiblemente ocupada @morten-lagabote la tomó hace 2 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
docling-project/docling-parse#450 ·
Los mantenedores suelen responder en 5 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 58/100
docling-project/docling-parse#449 ·
Los mantenedores suelen responder en 5 días
-
Page geometry reports the crop box as the trim, bleed and art boxes (regression in 6.0.0)Posiblemente ocupada @RaphaelFakhri la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
docling-project/docling-parse#445 ·
Los mantenedores suelen responder en 5 días
-
SIGTRAP rendering a page with an MMR-coded JBIG2 image (CJBig2_GRDProc::StartDecodeMMR → FaxModule::FaxG4Decode)Posiblemente ocupada @wittjeff la tomó hace 5 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
docling-project/docling-parse#440 · 1 comentario ·
Los mantenedores suelen responder en 5 días
Todos los issues de docling-project/docling-parse
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
status:needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
PX4/PX4-Autopilot#29698 ·
Los mantenedores suelen responder en 1 día
-
go perft exits when EvalFile is unavailablePosiblemente ocupada @Muawiya-contact la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
official-stockfish/Stockfish#7292 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Wrong order of announce_to_all_trackers, announce_to_all_tiers in settings_packPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
arvidn/libtorrent#9149 ·
Los mantenedores suelen responder en 1 día
-
Upstream report: MSVC rejects a designated initializer in a dependent template argument (C2131)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
rhalbersma/tabula#72 ·