Adjust PDF options for PhantomJS
Rasterize.js is a very basic example of screen capture. There are some default values in this example that you can change to your needs.
Simulates the size of the window like in a traditional browser. In rasterize.js, it's { width: 600, height: 600 }
; not a common resolution and you may need to change this.
Defines the size of the web page when rendered as a PDF. There are two modes : Manual (given a width and a height) or automatic (given a format). Do not hesitate to read the webpage documentation and the wiki page.
In your case, orientation: 'Letter'
is invalid.
Supported formats are 'A3', 'A4', 'A5', 'Legal', 'Letter', 'Tabloid'.
Supported orientation are 'portrait' and 'landscape'.
Take a look at the source code and change it to your needs !
Related videos on Youtube
Oleksandr IY
Updated on September 23, 2022Comments
-
Oleksandr IY over 1 year
I use PhantomJS for PDF generation.
This is my command:
./phantomjs rasterize.js <someurl> test.pdf
It generates pdf file but:
- The PDF looks nothing like the original website
- I can't set the page orientation
- Also is there any other options I can use for pdf generation?
The following change to rasterize.js also doesn't seem to work:
{ format: system.args[3], orientation: 'Letter', margin: '1cm' }