Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

241
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda