Pdfkit: Is it possible to specify the page format?

Created on 9 Sep 2014  路  8Comments  路  Source: foliojs/pdfkit

Hello,

I just came across PDFKit which sounds very interesting, but I noticed that the outputted pdf's dimensions are 215,9x279,4mm. As I'd like to produce printable pdfs, I'd like to know if it is possible to specify custom dimensions, like A4 format for example?

Thanks for your answer,
Fran莽ois

Most helpful comment

The units are PDF points (there are 72 per inch). Sorry about the 404, you can find the predefined paper sizes here.

All 8 comments

Yes you can do what you want, constructor of PdfKit accepts :

new PDFDocument({
     size: [width,height],
     margins : { // by default, all are 72
         top: 72, 
         bottom: 72,
         left: 72,
         right: 72
     },
     layout: 'portrait', // can be 'landscape'
     info: {
         Title: 'title', 
         Author: 'author', // the name of the author
         Subject: '', // the subject of the document
         Keywords: 'pdf;javascript'; // keywords associated with the document
         CreationDate: 'DD/MM/YYYY', // the date the document was created (added automatically by PDFKit)
         ModDate: 'DD/MM/YYYY' // the date the document was last modified
     }
})

Thank you for your answer, which unit is used for the width/height?
In the docs, there's a link to the "predefined paper sizes" but it's a 404... http://pdfkit.org/docs/paper_sizes.html

The units are PDF points (there are 72 per inch). Sorry about the 404, you can find the predefined paper sizes here.

Thanks a lot!

Please fix the 404 for the predefined page sizes!

The 404 should be fixed in #704 if it is merged. In the master branch, that page already exists.

I believe the correct link is this one

Is there the potential to specify a custom shape rather than an A4? From an svg outline for example?

Was this page helpful?
0 / 5 - 0 ratings