diff --git a/src/core/evaluator.js b/src/core/evaluator.js index d974b75a593c0..b5e2dd96cdbef 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -2982,8 +2982,8 @@ class PartialEvaluator { currentTextState !== textState && (currentTextState.fontSize !== textState.fontSize || (currentTextState.fontName !== textState.fontName && - (currentTextState.font.name !== textState.font.name || - currentTextState.font.vertical !== textState.font.vertical))) + (currentTextState.font?.name !== textState.font?.name || + currentTextState.font?.vertical !== textState.font?.vertical))) ) { flushTextContentItem(); currentTextState = textState.clone(); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 6db7cfe8b5073..3313b4d784e02 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -189,6 +189,7 @@ !bug1337429.pdf !bug1606566.pdf !bug2086012.pdf +!issue22381.pdf !issue5564_reduced.pdf !canvas.pdf !bug1132849.pdf diff --git a/test/pdfs/issue22381.pdf b/test/pdfs/issue22381.pdf new file mode 100644 index 0000000000000..b395bb90d435a Binary files /dev/null and b/test/pdfs/issue22381.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index b52f3a181c098..185896af37fb7 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -14647,6 +14647,13 @@ "rounds": 1, "type": "eq" }, + { + "id": "issue22381", + "file": "pdfs/issue22381.pdf", + "md5": "3f5fd4d65e246557510fefa4bd6cebcb", + "rounds": 1, + "type": "text" + }, { "id": "devicen-none-zero-domain", "file": "pdfs/devicen-none-zero-domain.pdf", diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js index a9b4cd9a28cf1..c9660b3a6cd6a 100644 --- a/test/unit/api_spec.js +++ b/test/unit/api_spec.js @@ -5600,6 +5600,21 @@ have written that much by now. So, here’s to squashing bugs.`); await loadingTask.destroy(); }); + it("gets text content when the first text has a zero font size (issue 22381)", async function () { + const loadingTask = getDocument( + buildGetDocumentParams("issue22381.pdf", { stopAtErrors: true }) + ); + const pdfDoc = await loadingTask.promise; + const pdfPage = await pdfDoc.getPage(1); + const { items } = await pdfPage.getTextContent({ + disableNormalization: true, + }); + const text = mergeText(items); + expect(text).toEqual("hiddenVisible text"); + + await loadingTask.destroy(); + }); + it("gets empty structure tree", async function () { const tree = await page.getStructTree();