1 |
new jsPDF('p', 'pt', [ 595.28, 841.89]) |
In the sourcecode on GitHub you can see the supported units (relative proportions to pt), and you can also see the default page formats (with
their sizes in pt).
A4 pixel dimensions: 793.706 x 1,122.52
pixels
Use this helper function to convert jsPDF points to other units (based on @lmerlo’s answer and the original source)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
function convertPointsToUnit(points, unit) { // Unit table from https://github.com/MrRio/jsPDF/blob/ddbfc0f0250ca908f8061a72fa057116b7613e78/jspdf.js#L791 var multiplier; switch(unit) { case 'pt': multiplier = 1; break; case 'mm': multiplier = 72 / 25.4; break; case 'cm': multiplier = 72 / 2.54; break; case 'in': multiplier = 72; break; case 'px': multiplier = 96 / 72; break; case 'pc': multiplier = 12; break; case 'em': multiplier = 12; break; case 'ex': multiplier = 6; default: throw ('Invalid unit: ' + unit); } return points * multiplier; } |