troyz
troyz

Reputation: 1385

NodeJS pdfkit text width

I'm trying to do a PDF using node's pdfkit but I'm having some problems related to the text width.

The result i want is something like this.

Overall comments:              This is the comment 
                               that will display here bla bla
                               extra text here 

But what i get with my current code is this

Overall comments:              This is the comment
that will display here blab bla extra text here

To write this piece of text i use the following code:

doc.font('Courier-Bold').text(padRight('Overall Comments:',28),{continued: true});
doc.font('Courier').text(audit.comment,{width: 100,align: 'justify'});

Where audit.comment is the text on the right and padRight returns the string with a fixed size of 28, adding spaces to the right.

It seems that it's ignoring the width option or I don't know how to use it.

Upvotes: 5

Views: 2483

Answers (1)

average
average

Reputation: 1

It seems that the text options are ignored after using 'continued'. My solution was to add empty text before my actual text.

Eg.

doc.font('Courier-Bold').text(padRight('Overall Comments:',28),{continued: true});
doc.text('');
doc.font('Courier').text(audit.comment,{width: 100,align: 'justify'});

Upvotes: 0

Related Questions