Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NodeJS and PDFKit: how to make first page to be landscape?

So, I've got a document:

var doc = new PDFDocument;

The docs tells me that The first page of a PDFKit document is added for you automatically, so there's no need to add it manualy. But how can I meke it to be landscape?

This one

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

works, but adds another page.

like image 676
k102 Avatar asked Jan 13 '14 11:01

k102


2 Answers

So it was quite obvious:

var doc = new PDFDocument(
        {
            layout : 'landscape'
        }
    );
like image 72
k102 Avatar answered Nov 20 '22 18:11

k102


You can disable autoFirstPage

const doc = new PDFDocument({ autoFirstPage: false });
doc.addPage({
    size: 'LEGAL',
    layout: 'landscape'
});

like image 37
Ittiunited Avatar answered Nov 20 '22 16:11

Ittiunited