question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trying to print outside of margins causes pdfkit to hang (infinite loop)

See original GitHub issue

Example:

doc = new PDFDocument({size: 'A4', margin: 20});
doc.text("29.12.2015", 600, 20);

Pdfkit get stuck in LineWrapper.prototype.eachWord, because this.spaceLeft is negative:

while (w > this.spaceLeft) {
    w = this.wordWidth(word.slice(0, --l));
}

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
pmaouicommented, Mar 6, 2016

I have the same issue. The expected behavior would be to just ignore the command as it would be printed outside the doc.

1reaction
jkoepckecommented, Sep 6, 2018

As described in #479 - use {lineBreak: false} as a workaround

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why PDFKit doesn't work well with margins? - Stack Overflow
I tried different combinations of margins, paddings and heights and nothing: when I just add margins or paddings, the PDF gets crazy. (Note: ......
Read more >
@foliojs-fork/pdfkit | Yarn - Package Manager
PDFKit is a PDF document generation library for Node and the browser that makes creating complex, multi-page, printable documents easy.
Read more >
why are pdf documents printing out with left side partially cut off?
1 Correct answer. There are no margin controls. What you have is a choice of two ways of printing: 1.
Read more >
WebCore/ChangeLog - external/Webkit - Git at Google
Fix for hang when incorrectly trying to add before/after content to. a <select>. ... This caused an infinite loop in RenderFlow::destroy(). This patch....
Read more >
Print To Screen and Then Print To Printer causing infinite loop
support@digital-metaphors.com. ... infinite state where page after empty page prints forever. There are a few items to check when this occurs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found