devongovett/pdfkit — Issue #47: TypeError: Cannot read property 'length' of null
Author: RobWC
Created: 2011-11-03 06:40:19+00:00
State: open

/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.