質問

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