Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

240
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda