Electron: Print with custom pageSize

Created on 28 May 2016  路  1Comment  路  Source: electron/electron

  • Electron version: 0.36.1
  • Operating system: Windows 10 x64

Hi, Is it possible to print with a custom page size? I wanted to generate a 3inch x 5inch PDF document.

I checked out web-contents.js and it seems it defaults to A4 and only from a set of discrete values.

This PR suggested that it was possible to have custom dimensions.

I was wondering If I just change those lines in a custom build and pass my own set of dimensions will that work?

componenprinting enhancement

Most helpful comment

Was able to find a work around.

It seems if you add this CSS to your page:

@page {
  size: 3in 5in;
}

Then the CSS is able to change the page layout and printToPDF works as expected. Found a test case in Blink using custom page sizes by the above method.

>All comments

Was able to find a work around.

It seems if you add this CSS to your page:

@page {
  size: 3in 5in;
}

Then the CSS is able to change the page layout and printToPDF works as expected. Found a test case in Blink using custom page sizes by the above method.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lealife picture lealife  路  3Comments

DanielDignam picture DanielDignam  路  3Comments

rhnorskov picture rhnorskov  路  3Comments

ThorstenHans picture ThorstenHans  路  3Comments

christiangenco picture christiangenco  路  3Comments