문제

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