Set printer paper size through css Set printer paper size through css google-chrome google-chrome

Set printer paper size through css


maybe this work.

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

or

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


Last time I checked, @media print is very poorly supported by the major browsers. I had a problem similiar to yours, and after weeks of trying I had to give up and go to a server-side pdf generation library (PDF4NET). If you need typeset, printed documents- I don't think HTML is going to do the trick.


Today I'm using Chrome 32.0.1700.107 m

The W3 CSS3 standard established for page sizes works great with the "SAVE AS PDF" option directly from Chrome in the printing interface. Remember that using a printer is very different in chrome's printing interface, as it uses the printers default size, but in the case of SAVE AS PDF option it DOES take the size that CSS established.

I have had years of trouble with different interfaces and go-around solutions for different proyects (for example: generating PDF's directly from server which was too heavy in processing and messy in code, or telling users to use windows printing interface, etc). This one is a great solution for me and seems to be definitive!

Now it's possible to create PDF's with the right size of paper using only CSS3 in the site, and no need of using third party software nor other kind of tricks.

In your case the best solution is to simply change the default paper size configured in the printer, which I adviced to the users with a little floating div that gave the advice and is hidden from printing. But as you do "not wish to make any changes to printer paper size", if you want to avoid making changes on the server side, you would require one more step from the person printig: first save the PDF and then send it to the printer from the PDF just created.