Home > front end >  How to give space between words in drawText pdf-lib method in nodejs
How to give space between words in drawText pdf-lib method in nodejs

Time:11-18

I want to give space between word in my text while I'm creating a PDF document but I do not know how I can do this.

This is my code:

firstPage.drawText(`2 5 5 5 5 5 5 5`, {
  x: 274,
  y: 655,
  font: courierBoldFont,
  size: 15,
  color: rgb(0, 0.5, 1),
});

I want space between word while adding string into it but I do not know. I want result like this 5 5 5 5 5 5 5 but string is displaying too close in the PDF like this 55555555555555

CodePudding user response:

Using courier font the inter character spacing should be perfectly even as it is monospaced, just add extra spacing to suit as you have done.

Your code should look spaced out like this, however I suspect your font definition courierBoldFont, may be wrong

enter image description here

Wrong definition of courier bold is not the same large spaces

enter image description here

  • Related