Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property '0' of undefined when parsing pdf #64

Closed
petterroea opened this issue May 23, 2016 · 7 comments
Closed

Cannot read property '0' of undefined when parsing pdf #64

petterroea opened this issue May 23, 2016 · 7 comments

Comments

@petterroea
Copy link

petterroea commented May 23, 2016

PDF it fails on: http://www.novasoftware.se/ImgGen/schedulegenerator.aspx?format=pdf&schoolid=60410/nb-no&type=-1&id=2eda&period=&week=21&mode=0&printer=0&colors=32&head=0&clock=0&foot=0&day=0&width=1880&height=371&maxwidth=1880&maxheight=371

Stack trace:

(while reading XRef): TypeError: Cannot read property '0' of undefined
XRefParseException
    at XRefParseExceptionClosure (eval at <anonymous> (/home/petterroea/Dropbox/div-projects/bot/node_modules/pdf2json/lib/pdf.js:64:6), <anonymous>:379:34)
    at eval (eval at <anonymous> (/home/petterroea/Dropbox/div-projects/bot/node_modules/pdf2json/lib/pdf.js:64:6), <anonymous>:384:3)
    at Object.<anonymous> (/home/petterroea/Dropbox/div-projects/bot/node_modules/pdf2json/lib/pdf.js:64:1)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/petterroea/Dropbox/div-projects/bot/node_modules/pdf2json/pdfparser.js:8:10)
Error
    at InvalidPDFExceptionClosure (eval at <anonymous> (/home/petterroea/Dropbox/div-projects/bot/node_modules/pdf2json/lib/pdf.js:64:6), <anonymous>:330:35)
    at eval (eval at <anonymous> (/home/petterroea/Dropbox/div-projects/bot/node_modules/pdf2json/lib/pdf.js:64:6), <anonymous>:334:3)
    at Object.<anonymous> (/home/petterroea/Dropbox/div-projects/bot/node_modules/pdf2json/lib/pdf.js:64:1)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/petterroea/Dropbox/div-projects/bot/node_modules/pdf2json/pdfparser.js:8:10)

Code:

        var pdfParser = new PDFParser();
        console.log("Downloaded timeschedule.");
        pdfParser.on("pdfParser_dataReady", pdfData => {
        console.log("Got pdf data");
        console.log(pdfData);
        });
        pdfParser.loadPDF("temp.pdf");

Node -v:

v5.11.1

It might be a poorly generated pdf(2000's consultant work apparently), but other readers support it fine.

modesty pushed a commit that referenced this issue Jul 2, 2016
@modesty
Copy link
Owner

modesty commented Jul 2, 2016

the testing pdf is downloaded and save in test/pdf/misc/ as i64_schedule_generator.pdf. Then run cmd line: node pdf2json.js -f test/pdf/misc/i64_schedule_generator.pdf -o test/target/misc/

it parses then writes out i64_schedule_generator.json correctly.

node -v:
v4.4.0

@petterroea
Copy link
Author

I will re-test with my environment at home and re-try.

@jonstuebe
Copy link

@petterroea did you figure out what the issue was? I'm getting the same error

@Emrio
Copy link

Emrio commented Oct 28, 2018

Hello, I am facing the same issue with node v10.8.0 and pdf2json 1.1.7.
I am using pdf2json to parse multiple PDFs but when I run the script, some of them (not always the same) get the (while reading XRef): TypeError: Cannot read property '0' of undefined error

Stack trace same as @petterroea 's

@zouhair94
Copy link

zouhair94 commented Jul 3, 2019

Hello, I am facing the same issue with node v10.8.0 and pdf2json 1.1.7.
I am using pdf2json to parse multiple PDFs but when I run the script, some of them (not always the same) get the (while reading XRef): TypeError: Cannot read property '0' of undefined error

Stack trace same as @petterroea 's

facing same error

@ana108
Copy link

ana108 commented Dec 30, 2021

I second this; I got this error randomly.
Same pdf worked fine on the next iteration (version: ^1.2.1)

modesty added a commit that referenced this issue Nov 10, 2023
@modesty modesty closed this as completed Jun 15, 2024
@petterroea
Copy link
Author

This issue has grown up with me since high school and I'm now a professional software engineer, haha! Thanks for fixing and closing the issue, reminding me of it! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants