Detect Printer's Page Size in CSS or JavaScript -


question summary: want able detect user's printer's page size can send different page layout based on printer's page size.

example use case: our users businesses. user's want print basic receipts (and have small printers) , users want print invoices (i.e. normal 8" * 11" pages). based on printer's page size can recognize format should sent printer.

css specification: ideally there css media setting different page sizes. css standards have been working on this, , in css 2.1 spec says

however, printer should guided page size value supplied css size property when choosing media print on.

the css 3 spec appears offer solution.

/* style sheet "a4" printing */  @media print , (width: 21cm) , (height: 29.7cm) {     @page {        margin: 3cm;     }  }   /* style sheet "letter" printing */  @media print , (width: 8.5in) , (height: 11in) {     @page {         margin: 1in;     }  } 

real world implementation: how being implemented across major browsers. has implemented this? browsers work in? code works?

additional information: it looks working in few browsers. work page size , not landscape / portrait.

@media print { @page {size: landscape } } 

the following media query has been working reliably me receipt printers:

@media print , (max-width: 10cm) { } 

on related note: unfortunately, isn't working (customers have manually set margins none or minimal)

@page { margin: 0; } 

happy coding


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -