Search code examples
pdfmake

Unit of size using in pdfmake library


what is the unit size used for pageSize in pdfmake :

var docDefinition = {
  // a string or { width: number, height: number }
  pageSize: {
    width: 595.28,
    height: 'auto'
  },
};

Solution

  • Pdfmake uses points (pt) as a unit of measure (this goes both for page size and margin size).

    In the source code of the library we can see that A4 paper is 595.35 x 841.995 pt. Since A4 is 210 x 297 mm or 8.3 x 11.7 in, we can easily compute the conversion ratio.

    1 mm = 2.835 pt

    1 in = approx. 71.729 pt

    See this discussion for more details.