jsPDF 2.3 Align text

I am using the latest version of jdPDF (2.3.0). In the documentation, it says that to center text, passed an object in the 4th parameter with the align: ‘center’ option, but that doesn’t work. I also don’t understand why I should specify an X if I want my text to be centered.

Here is my code :

const pdf = new window.jspdf.jsPDF();
pdf.text(`Hello world`, null, 20, { align: 'center'} );
pdf.save("TEST");

jsPDF text documentation : http://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html#text

I’m using jsPDF from CDN link.

63 thoughts on “jsPDF 2.3 Align text”

Leave a Comment