9

I read in pdfkit manual that pdf page can be sized using size[width,height].But when i tried the following code its not working

var PDFDocument = require('pdfkit');

var doc = new PDFDocument;
doc.size=[50,50];
doc.end()
Hareesh Kumar K
  • 389
  • 1
  • 3
  • 8

2 Answers2

28

After exploration i found the following code is working for me to create PDF document of any size with width,height and margins as variables

 var PDFDocument = require('pdfkit');

    var fs = require("fs");
    var doc=new PDFDocument({
        size: [width,height],
        margins : { // by default, all are 72
            top: 10,
           bottom:10,
            left: 10,
          right: 10
        }
})
Hareesh Kumar K
  • 389
  • 1
  • 3
  • 8
1

It works :)

Dimension are in PostScript points 1 cm = 28.3465 pt