How to find a paper size / printable size and set the header and footer on print?

≡放荡痞女 提交于 2020-01-06 09:04:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!