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.

Texts are always inserted into new pages after the 2nd page.

See original GitHub issue

The following code snippets will generate a PDF file with 931 pages. The first page has y=0 to y=69. Starting from y=70, each line is printed on another page.

const fs = require('fs');
const PDFDocument = require('pdfkit');

const doc = new PDFDocument({
    size: 'A4',
    margin: 0
const stream = doc.pipe(fs.createWriteStream('./test/test.pdf'));
stream.on('finish', function() {

for (let y = 0; y < 1000; y++) {
    doc.text(`Line=${y}: doc_pos=(${doc.x}, ${doc.y});specified_pos=(10, ${y*12})`, 10, y * 12);

This is how it looks likes. image

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:2
  • Comments:11

github_iconTop GitHub Comments

xtucommented, Apr 8, 2021

Sorry @rahim3070 . It has been too long since I raised this and I cannot find what I have done. The idea was to control the pages by yourself. When the content is too large to fit in the page, call doc = doc.addPage() and the remaining content will be rendered on the new page.

rahim3070commented, Apr 7, 2021

@lnufnu Thanks a lot! This is exactly what I have been using as the workaround for this issue.

Dear @xtu, I meant your complete code sample what you have done, please

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Stop Next Page Content from Moving When Adding ...
Step 1. Click in the document where the text on one page ends. The cursor should insert before the next page to keep...
Read more >
How do I prevent text from moving down on page 2 when ...
I want the text on page 2 at the top of the page to stay put and not move down. I have a...
Read more >
Link text boxes in Pages on Mac - Apple Support
You can link two or more text boxes so that text can flow from one text box to the next. For example, if...
Read more >
How to Stop Paragraphs from Splitting Between Pages in Word
... pages in Word, it's best to use the Keep with next or Keep lines together paragraph formats rather than inserting manual page...
Read more >
310. Why does my text wrap to the next line before reaching ...
This happens if you accidentally change the paragraph indentation for the document. ... Ensure that Indentation, both before and after text, are set...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found