Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
PDFkit new page changes content position

I am fully aware that my problem most likely has something to do with me doing something wrong, but I can't seem to figure it out. Here is my code:

for (let i = 0; i < formContentArray.length; i++) {
    rowPosition = doc.y
    columnPosition = doc.x

    if (formContentArray[i].type == 'text' ) {
        doc
        .fill('#89cff0')
        .fontSize(13)
        .text(formContentArray[i].text, columnPosition, rowPosition, { align: "left" });
        if (i == 0) {
            doc.text('Done/Not Done',  columnPosition, rowPosition, {align: 'right'})
        }
    } 
    else {
        doc
        .fill('#212121')
        .fontSize(11)
        .text(formContentArray[i].text,columnPosition, rowPosition, { align: "left" })
        if (formContentArray[i].value) {
            doc.text('Done',  columnPosition, rowPosition, {align: 'right'})
        }
        else {
            doc.text('Not Done', columnPosition, rowPosition, {align: 'right'} )
        }
    }
}

This works perfectly until the data fills out the page at which point PDFkit makes a new page. The next time it loops, it only does one loop, adds one line of text at the top of the 2nd page, and then adds a 3rd page. The loop then works perfectly on the 3rd page, finishing off the data. This obviously leaves the 2nd page though that is almost completely empty. I don't understand? It has something to do with my rowPosition and columnPosition, I think. However, I need those in order to align text on the right-hand side with that on the left

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!