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

TypeError: Cannot read property 'length' of null #47

Closed
RobWC opened this issue Nov 3, 2011 · 1 comment
Closed

TypeError: Cannot read property 'length' of null #47

RobWC opened this issue Nov 3, 2011 · 1 comment

Comments

@RobWC
Copy link

RobWC commented Nov 3, 2011

/Users/rcameron/node_modules/pdfkit/lib/mixins/line_wrapper.coffee:63
len = words.length;
^
TypeError: Cannot read property 'length' of null
at LineWrapper.wrap (/Users/rcameron/node_modules/pdfkit/lib/mixins/line_wrapper.coffee:63:20)
at PDFDocument.text (/Users/rcameron/node_modules/pdfkit/lib/mixins/text.coffee:46:17)
at /Users/rcameron/pdfMaker/node-test.js:90:8
at IncomingMessage. (/Users/rcameron/pdfMaker/node-test.js:61:4)
at IncomingMessage.emit (events.js:81:20)
at HTTPParser.onMessageComplete (http.js:133:23)
at CleartextStream.ondata (http.js:1231:22)
at CleartextStream._push (tls.js:303:27)
at SecurePair.cycle (tls.js:577:20)
at EncryptedStream.write (tls.js:96:13)

I am seeing this issue when adding text via the doc.text method. I changed the pdfkit module to test if words was null before testing length on line 54 of line_wrapper.coffee.

if !!text.match(WORD_RE)
words = text.match(WORD_RE)

This solved the issue.

@faridnsh
Copy link

I had that issue, happened when I passed a number instead of string to doc.text. Just convert it to a string.

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

No branches or pull requests

3 participants