Repository navigation
Don't fail getTextContent when the first text in a stream has a zero font size (issue 22381) - #22383
zhaodengfeng wants to merge 1 commit into
Conversation
…font size (issue 22381) The text state is cloned before any `Tf` is applied, so its font is `null` and its font size is `0`. When the first text shown uses a zero font size, the font size comparison in `buildTextContentItem` is equal, and the font name comparison then reads `name` from that `null` font. With the default `ignoreErrors`, all of the text on the page was dropped.
|
@Snuffleupagus Thanks for getting this fixed so quickly in #22384. I had submitted the fix and regression test here after reporting #22381, and I see that the separate PR has now been merged. Could you clarify why a separate PR was preferred, and whether I should close this one as superseded? I'd appreciate understanding the preferred contribution workflow for future fixes. If the work here informed the final fix or test, a cross-reference from #22384 to this PR would also help preserve that contribution history. Thanks for your help. |
|
Note that the two PRs were submitted mere minutes apart, which means that I had obviously not seen this one while working on #22384 locally. |
|
Thanks for clarifying the timing. That answers my question about the parallel PRs. Long-standing contributions deserve respect. I would hope that respect also extends to people making their first contribution. Experience lends weight to a technical assessment; it should not take the place of one. If there are specific problems with the code or tests, I welcome that feedback. “New contributor” and “appears AI-generated” tell me how you have categorized the submission, but little about its correctness. As for AI-assisted development, I think the useful discussion today is about how we verify the work and take responsibility for it. If the use of AI itself is enough to end that discussion, then we probably have little more to discuss. The issue is fixed, which was my goal in reporting it and submitting a patch. I’m happy to leave it there. |
Fixes #22381.
The text state is cloned before any
Tfis applied, so its font isnulland its font size is0. When the first text shown uses a zero font size, the font size comparison inbuildTextContentItemis equal, and the font name comparison then readsnamefrom thatnullfont. With the defaultignoreErrors, all of the text on the page was dropped.This is the shape of the invisible watermark that Aspose.PDF adds (
BT /F0 0 Tf ... (<base64>) Tj ETin a form XObject), so it affects real-world documents.test/pdfs/issue22381.pdfis the reduced file from the issue: one size-0 run followed byVisible text.getTextContentwithstopAtErrors: truenow returnshiddenVisible text. Without the fix it fails withCannot read properties of null (reading 'name').textentry totest_manifest.json.gulp unittestclilocally: no new failures compared withmaster. The remaining local failures come from linked PDFs that weren't downloaded.