Set printer paper size through css

Irene Ling picture Irene Ling · Nov 10, 2013 · Viewed 65.9k times · Source

My printer default size is A4,and I need to print payslip in size 8.5inx5.5in using the old dot matrix printer. I tried to set every payslip DIV in a fixed height,

width: 175.6mm;
height:123.7mm;
margin-left:auto;
margin-right:auto;

Although it fit the payslip size perfectly,but after printed,the paper will keep rolling until end of it because payslip paper are all joined unlike A4. And I do not wish to make any changes to printer paper size,so I set:

@media print 
{
   @page
   {
    size: 8.5in 5.5in;
    size: portrait;
  }
}

but the print preview of Google Chrome still showing this:

enter image description here

Actually is it possible to do so?Or is there any way to force printer stop printing after payslip printed to prevent it from keep rolling the paper?(which I think should be not possible)

P.S. I am using Google Chrome only.

**Updated:

I noticed the paper size will change after I choose to "Save as PDF",if I choose back my default printer,the paper size is incorrect again.

Answer

pixparker picture pixparker · Jun 22, 2015

maybe this work.

@media print 
{
   @page
   {
    size: 8.5in 5.5in;
    size: landscape;
  }
}

or

@media print 
{
   @page
   {
    size: 5.5in 8.5in ;
    size: landscape;
  }
}