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

288
Views
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 answers
Answer question

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 Report

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 Report
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!