Question

I am using pdfkit module to create pdf documents in node js. I could not change the page size of pdf document. i tried the following code.. Even its not working.

var PDFDocument = require('pdfkit');
var doc = new PDFDocument;
doc.addPage
  size: 'legal'
  layout: 'landscape'

doc.addPage
  size: [612.00  * 1008.00]
  layout: 'landscape'

Please suggest some idea for this problem..

Was it helpful?

Solution

doc.addPage({
    size: 'LEGAL'
    layout: 'landscape'
});

Above code worked for me.

OTHER TIPS

R J.'s answer will work for newly created pages. But to change the size, margin and layout of the automatically created page(and whole document), you need to pass page options object as arguements to the PDFDocument constructor. And it will set the page size for whole document, which can be overridden by passing a new page option object to doc.addPage().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top