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.

TypeError: Cannot read property 'clone' of undefined

See original GitHub issue

Hi, When trying to copy a specific PDF, i have the error : TypeError: Cannot read property 'clone' of undefined

Here is a not working example : https://runkit.com/gautiert/5d81e279596dfc0015e16a7c

Probably related to #186

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
Hopdingcommented, Sep 24, 2019

I was able to fix the problem in #200. It will go out in the next pdf-lib release.

Incase, you’re interested, the problem was due to a missing newline. The PDF states that:

The last line of the file shall contain only the end-of-file marker, %%EOF.

This seems pretty clear cut. But it becomes ambiguous when you start dealing with incremental update sections (the file you shared here has one of these):

Each trailer shall be terminated by its own end-of-file (%%EOF) marker.

But it doesn’t really state whether the previous %%EOF marker should be followed by a newline before the update section’s content begins. All examples in the spec do have a newline. And every other updated PDF I’ve come across does as well.

However, the PDF you shared here does not follow this convention:

285 | 17201^M
286 | %%EOF28 0 obj^M
287 | <<^M

Notice line 286. That’s what caused the issue. pdf-lib’s parser was implicitly expecting a newline after the %%EOF. And when it didn’t find one, that caused it to enter error recovery mode and skip object 28.

Gotta love the PDF spec’s ambiguity and lack of clarity 🙄. Anyhow, it’s fixed now 👍

1reaction
GautierTcommented, Sep 25, 2019

Thanks a lot @Hopding !! Bravo for this awesome lib ! 👏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'clone' of undefined · Issue #539 - GitHub
This error appear if Owl container has only 1 child. If there are to Items then it works perfectly. I use this for...
Read more >
jQuery Owl Carousel: Cannot read property 'clone' of undefined
I am running a WordPress site. My error is below. Uncaught TypeError: Cannot read properties of undefined (reading 'clone ...
Read more >
[SOLVED] Cannot read properties of undefined (reading 'clone')
I am trying to clone a platform but it says that my properties are undefined. I already checked if I accidentally missed putting...
Read more >
Cannot read property 'clone' of null when inserting language
Uncaught TypeError: Cannot read property 'clone' of null when inserting language. Closed, ResolvedPublic1 Estimated Story Points. Actions.
Read more >
“Uncaught TypeError: Cannot read property 'clone ... - iTecNote
For some reason I'm getting ""Uncaught TypeError: Cannot read property 'clone' of undefined" when I'm trying to update the calendar with a recent...
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