Printing in print using javascript - landscape mode

Print the web page in landscape mode using javascript. During printing, I want:

  • Set fields
  • Landscape mode
+4
source share
1 answer

You can mark the size and margins of a printed page using the @page rule:

 /* In CSS, not JavaScript */ @page { size: A4 landscape; margin: 42pt 12pt; } @media print { /* Define print-specific styles here, for example toning down the decoration of hyperlinks and removing the navigation. */ a {color: inherit !important; text-decoration: none !important;} nav {display: none;} } 

However , browser support is spotty - in addition to Prince XML , only IE8 + and Opera are supported. If you need precise cross-browser control over printing, consider the PDF output mechanism (usually server-side).

+10
source

All Articles