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

298
Visualizações
PDFkit (Node): How to create paragraph indents?

I'm trying to create paragraph indents in PDFkit. The PDFkit docs state that the indent attribute is "to indent each paragraph of text". While trying this, only the first line has an indent.

const doc = new PDFDocument({ size: "A4" });
doc.pipe(fs.createWriteStream('output2.pdf'));
doc.addPage()
doc.text('fdgfdgfg fggfdgfdg fgfdg fdg dfgdfgdfg dfgfdg fgfgfdg fdgdfgdfg', { indent: 30 })
doc.end();

The code delivers an indent only in the first line of the paragraph. How can I indent the whole paragraph?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I moved from PDFKit to pdfmake (which is based on PDFKit), which handles indents for my case way better than PDFkit itself. For my use case it's also better since I use JSON output from my markdown lexer which can easily transformed to the input for pdfmake.

about 4 years ago · Juan Pablo Isaza Relatório

0

You need to doc.text and doc.moveDown if you want consecutive paragraphs.

const doc = new PDFDocument({ size: "A4" });
doc.pipe(fs.createWriteStream('output2.pdf'));
doc.addPage()
doc.text('This is the start of paragraph 1', { indent: 30 });
doc.moveDown();
doc.text('This is the start of paragraph 2', { indent: 30 });
doc.moveDown();
doc.text('This is the start of paragraph 3', { indent: 30 });
doc.end();


about 4 years ago · Juan Pablo Isaza Relatório
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