Swarup
Swarup

Reputation: 105

window.print() - Can you set the paper size?

We have a printer-friendly version of a web page that we want to print. The problem is we want it to print on a 4"*6" size paper by default.

Is this possible?

Upvotes: 4

Views: 21330

Answers (3)

Arvind
Arvind

Reputation: 49

Yes, we can.

Just add this css and page size will be adjusted in mm Page Sizes in mm.

@page {
    size: 80mm 170mm;
}

If you are using Angular or React etc., then you can add this CSS in respective component.

Upvotes: 0

Guga Nemsitsveridze
Guga Nemsitsveridze

Reputation: 751

You can set Paper size using CSS:

@page {
    size: auto;
    size: A3;
    margin: 0mm;
}

Upvotes: 4

Koen
Koen

Reputation: 288

What you could try is to put everything in a div with certain width, given in mm or in. Printing this will not select a certain paper size, but it will guarantee to fit, widthwise that is.

Upvotes: 5

Related Questions