Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

specify PDF page size using pdfkit in node js

Tags:

node.js

pdfkit

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()
like image 256
Hareesh Kumar K Avatar asked Aug 01 '16 15:08

Hareesh Kumar K


1 Answers

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
        }
})
like image 97
Hareesh Kumar K Avatar answered Nov 02 '22 19:11

Hareesh Kumar K