Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set printer paper size through css

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.

like image 827
Irene Ling Avatar asked Nov 10 '13 17:11

Irene Ling


People also ask

How do I change the page size to A4 in CSS?

Just change min-height: 297mm into max-height: 296mm; in the . page class. This will sort the double page issue.

How do I set my printer paper size?

Click Start, point to Settings, and the click Printers. Right-click the appropriate printer, and then click Properties. Click the Paper tab, and then click the paper size you want to use in the Paper Size box. Click OK, and then close the Printers folder.

Can we apply CSS to page for printing?

You can use CSS to change the appearance of your web page when it's printed on a paper. You can specify one font for the screen version and another for the print version. You have seen @media rule in previous chapters.


1 Answers

maybe this work.

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

or

@media print 
{
   @page
   {
    size: 5.5in 8.5in ;
    size: landscape;
  }
}
like image 67
pixparker Avatar answered Sep 22 '22 08:09

pixparker