What is pixel width and length for jspdf's default 'a4' format?

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).

Hope this could help,

Laura.


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)

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;
}