Alimin
Alimin

Reputation: 2717

How to set a line width in jsPDF?

I am doing following code to produce big size of line width.

doc.setLineWidth(400);

but not happen anything and the line still thin size after that.

This is my complete code

var doc = new jsPDF('p','pt','a4');

doc.line(30, 30, 560, 30); // horizontal line  

doc.setLineWidth(400); 

How to set a line width correctly?

Result and expectation

Upvotes: 3

Views: 13717

Answers (1)

Bharata
Bharata

Reputation: 14155

Because you have to understand that at first you have to set the width value and then you can use it. And you do it on the wrong way: you set it after using.

Correct example

function generatePDF()
{
    var pdf = new jsPDF('p', 'pt', 'a4');
    pdf.setLineWidth(5.0); 
    pdf.line(30, 30, 560, 30);
    pdf.save('test.pdf');
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.4.1/jspdf.min.js" crossorigin="anonymous"></script>

<button onclick="generatePDF()">Generate PDF</button>

Upvotes: 11

Related Questions