RelaxedJS / ReLaXed

Create PDF documents using web technologies
ISC License
11.8k stars 428 forks source link

How to make pdf pages in horizontal orientation? #184

Open Beathoven1 opened 4 years ago

Beathoven1 commented 4 years ago

I am writing in html and ran into a problem. I want pages in landscape orientation, and they are displayed in vertical orientation. How and in which file can the orientation of the resulting pdf be edited?

Zulko commented 4 years ago

You can set the document dimensions in the CSS with the @page syntax, except -page-width and -page-height had to be replaced by -relaxed-page-width -relaxed-page-height, unfortunately, due to a limitation of the Pupetteer API.

See this ReLaXed example for horizontal (poster) dimensions:

https://github.com/RelaxedJS/ReLaXed-examples/tree/master/examples/poster

Here is the relevant bit from the SCSS file:

$page_width: 46.8in;
$page_height: 33.1in;
$margin: 1.2in;

@page {
  size: $page_width $page_height;
  -relaxed-page-width: $page_width;
  -relaxed-page-height: $page_height;
}