-
-
Save Purush0th/7fe8665bbb04482a0d80 to your computer and use it in GitHub Desktop.
(function (api, $) { | |
'use strict'; | |
api.writeText = function (x, y, text, options) { | |
options = options || {}; | |
var defaults = { | |
align: 'left', | |
width: this.internal.pageSize.width | |
} | |
var settings = $.extend({}, defaults, options); | |
// Get current font size | |
var fontSize = this.internal.getFontSize(); | |
// Get the actual text's width | |
/* You multiply the unit width of your string by your font size and divide | |
* by the internal scale factor. The division is necessary | |
* for the case where you use units other than 'pt' in the constructor | |
* of jsPDF. | |
*/ | |
var txtWidth = this.getStringUnitWidth(text) * fontSize / this.internal.scaleFactor; | |
if (settings.align === 'center') | |
x += (settings.width - txtWidth) / 2; | |
else if (settings.align === 'right') | |
x += (settings.width - txtWidth); | |
//default is 'left' alignment | |
this.text(text, x, y); | |
} | |
})(jsPDF.API, jQuery); |
Is the justified alignment possible using code
?
Great Job Man, thanks, work for me!! It's Awesome
@JPaulPunzalan Did you manage to justify the text with this library?
Hi guys, I'm new in this field, how can I use this library within my code?
There are a lot of files, do I have to include them all?
kindly upload it to https://www.npmjs.com/ so that we can download it and use it in every technology with ease through npm.
How do I include this in my React project?
I've tried to just copy and paste in the code, but got error 'jQuery' is not defined no-undef
.
Thanks for the gist Purushoth. Great job. Works perfectly.
Thank you
can i get typescript version of the same ?
any infos somewhere about how to use this pluggin with jspdf inside angular ?
This is AWESOME! Thank you so much
how I show Textfiled value in the center
Text alignment plugin - jsPDF
This small plugin will align the given text in jsPDF
Options:
Usage: