#1439·pdfkit

Text wrapping confusing (lineBreak:false ignored)

Author: ammulderCreated Mar 23, 2023Updated Jul 11, 2026

I'm trying to print a line of text in a specific location with a specific width, and if the text is too long I'd like it to be truncated with an ellipsis and never wrap to additional lines. Based on the documentation, I thought this should work:

doc.text('some long text', 0, 1, {lineBreak: false, ellipsis: true, width: 280});

However, if I do that then the line wraps anyway, and I get part of the text on a second line. It looks like setting a height instead of using lineBreak:false makes it work:

doc.fontSize(12);
doc.text('some long text', 0, 1, {ellipsis: true, width: 280, height:15});

Maybe the docs could be clarified? It seems like lineBreak:false has no effect, and if you want to use ellipsis then you must specify a height? (And I guess a width if you don't want the default page width less margins?)

  • pdfkit version: 0.13.0
  • Node version: 18.x
  • Operating System: AWS Lambda (some kind of Linux)