问题
This is some what difficult me. My client require to print the data's with header and footer on each page.
There is a chance to use a A4, A3, A5
and Landscape
papers. How can i able to set the header and footer on each of the page?
And how can i able to set a data length according to the page? is there a way to create print template?
I am using underscore-template
in Backbone
.
Any one suggest me a way please?
回答1:
For your issue no difference which template engine you use.
For doing something with javascript before HTML Document has been printed you could use:
For Firefox and InternetExplorer - window.onbeforeprint.
Workaround for other browser - window.matchMedia('print').
The better way for having nice look when user tries to print page is to use CSS's media queries, which will apply particular rules when user want to print the HTML Document:
<link rel="stylesheet" media="print" href="print.css" />
or add media query to your css file:
@media screen {
body {font-family:verdana, arial, sans-serif;} // this will apply to printed page
}
来源:https://stackoverflow.com/questions/26772069/how-to-find-a-paper-size-printable-size-and-set-the-header-and-footer-on-print