سؤال

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

هل كانت مفيدة؟

المحلول

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

Above code worked for me.

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top