Print to PDF and PNG



I am new to electron. I was trying out the print to PDF feature.
I have couple of questions on this.

My input is html and the content is huge.

  1. When I set print to PDF, it created multiple pages. How can I shrink it to one page PDF? i.e. can I use any API to say shrink the entire content to one PDF page?
  2. If html has table, my content is getting cut (only the initial few columns of table appear in the PDF). Can you please let me know what settings I can try so that it doesn’t get cut?
  3. I also want to output to PNG. Any code pointers for this?

Thank you so much in advance for your inputs.


I’m not an expert, but:

  1. I think CSS might help here. You could even do transform: scale(0.9); or something

  2. Does the CSS page-break-inside: avoid; help on table cells?

  3. Look like capturePage returns a nativeImage which can be output as a PNG.


Thanks for the quick response.

I am not sure if transform will work for my case. I have content thats long on width and height wise.
I tried using page-break to overcome the column cut and row cut problem but it doesn’t work.
I will try the capturePage to PNG and see if that works as expected.


Can someone please share a capturePage example code?