question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot open attached pdf file - TypeError: Cannot read properties of null (reading 'appendChild')

See original GitHub issue

PDF attached here: SampleWithIssue12.7.pdf

Configuration:

  • Web browser and its version: Chrome, Version 106.0.5249.119 (Official Build) (64-bit)
  • Operating system and its version: Windows 10 Pro Version 21H2 OS Build 19044.2130
  • PDF.js version: Tested on 2.11.338 and then upgraded to 2.14.305, having the same problem.
  • Invoking the library via https://github.com/VadimDez/ng2-pdf-viewer

Steps to reproduce the problem:

  1. Open the attached pdf using pdf.js in the Chrome browser
  2. It crashed with this error in the console:
Error captured:  Error: Uncaught (in promise): TypeError: Cannot read properties of null (reading 'appendChild')
TypeError: Cannot read properties of null (reading 'appendChild')
    at TextLayerRenderTask._processItems (pdf.js:22212:20)
    at pdf.js:22317:20
    at _ZoneDelegate.invoke (zone.js:372:1)
    at Object.onInvoke (core.mjs:25608:1)
    at _ZoneDelegate.invoke (zone.js:371:1)
    at Zone.run (zone.js:134:1)
    at zone.js:1275:1
    at _ZoneDelegate.invokeTask (zone.js:406:1)
    at Object.onInvokeTask (core.mjs:25595:1)
    at _ZoneDelegate.invokeTask (zone.js:405:1)
    at resolvePromise (zone.js:1211:1)
    at zone.js:1282:1
    at _ZoneDelegate.invokeTask (zone.js:406:1)
    at Object.onInvokeTask (core.mjs:25595:1)
    at _ZoneDelegate.invokeTask (zone.js:405:1)
    at Zone.runTask (zone.js:178:1)
    at drainMicroTaskQueue (zone.js:585:1)

What is the expected behavior?

It should open the pdf file.

What went wrong?

Error screenshot 1 Error screenshot 2

What have I tried/analysis?

I used Nitro PDF and edited the text “Louise Anne Farrar” and changed it slightly. When I saved the PDF and opened it again in PDF.js, it worked. I noticed that the Helvetica font, which has Actual font ArialMT, was now embedded in the document (when I look at the pdf properties). Leads me to suspect that it is related to the embedding of the ArialMT Font, which the original PDF does not appear to have. It’s just a suspicion, don’t know if that is the actual issue though.

In addition, I tried to disable RenderTextMode, and that also solves the issue, the pdf will then display properly. But I don’t like this solution because the text is not selectable!!

Any ideas/suggestions?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Snuffleupaguscommented, Oct 26, 2022

Note that we’ve two EMC for one BMC.

Already noticed that, patch incoming 😃

0reactions
navilncommented, Oct 26, 2022

PDF.js version: Tested on 2.11.338 and then upgraded to 2.14.305, having the same problem.

While it doesn’t matter in this specific case, please note that neither of those versions are supported any more; please find the latest releases at https://mozilla.github.io/pdf.js/getting_started/#download

Thank you, I’m only these older versions because thats the dependancy from the library that I am actually using in my Angular project:

I will see if the author over there will move to the latest, or at least supported versions of pdf.js.

Cheers!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: Cannot read property 'appendChild' of null
The "Cannot read property 'appendChild' of null" error occurs for 2 reasons: Calling the appendChild() method on a DOM element that doesn't ...
Read more >
TypeError: Cannot read property 'appendChild' of Null in JS
The "Cannot read property 'appendChild' of null" error occurs when trying to call the appendChild method on a DOM element that doesn't exist....
Read more >
FormData.append() - Web APIs | MDN
The append() method of the FormData interface appends a new value onto an existing key inside a FormData object, or adds the key...
Read more >
uncaught typeerror: cannot read properties of null ... - You.com
i dont understand why i got this error. Open side panel. Uncaught TypeError: Cannot read properties of null (reading 'appendChild'); Persistent Error.
Read more >
Cannot read properties of null (reading 'appendChild ... - Reddit
What does this error message mean? TypeError: Cannot read properties of null (reading 'appendChild') (/index.js:11).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found