-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Printing list item with line break fails with Unsupported Number: NaN
#1486
Comments
filecage
added a commit
to filecage/pdfkit
that referenced
this issue
Dec 20, 2023
filecage
added a commit
to filecage/pdfkit
that referenced
this issue
Dec 20, 2023
filecage
added a commit
to filecage/pdfkit
that referenced
this issue
Dec 20, 2023
blikblum
pushed a commit
that referenced
this issue
Dec 22, 2023
* adds test case with line-breaks in list items reproduces #1486 * use LineBreaker per item and only draw `firstLine` once fixes #1486 * boyscout: consistent naming * boyscout: test multiple line break versions * update changelog for fix of #1486 --------- Co-authored-by: David <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
Description of the problem
When using
doc.list()
to print list items, the process fails if one list item contains a line break (newline or return carriage characters both affected).This is due to the internal
flatten()
of the text mixin calculates the amount of levels based on the number of list items given here:pdfkit/lib/mixins/text.js
Lines 124 to 142 in 6338314
But the
firstLine
event is emitted per actual line, causing the event handler to access anundefined
level item here:https://github.com/foliojs/pdfkit/blob/6338314daf44f7f188e4cc6cb4d70fc2f2698fca/lib/mixins/text.js#L179-182
Which then results in
diff
beingNaN
and the consecutive variablesthis.x
andwrapper.lineWidth
as well.From my knowledge of the library, I can't tell whether
flatten()
should produce the levels based on the actual lines or thefirstLine
event should only be emitted once per list item.Code sample
With any PDFKit document, call
Your environment
The text was updated successfully, but these errors were encountered: