Printing with javascript without header and footer: how are you?

When I print content using javascript, the browser automatically adds the header and footer (url / date / pagenr). Currently, there seems to be no way to suppress this from a webpage.

Css3 may be a solution for it (for example, using @page, @ top-left styles ), but currently does not seem to work here (winvista chrome 17.0.942.0/firefox 9.0). When should it appear in browsers?

A different solution may occur in the Chrome browser: with the above version, printdlg is not a modal-printdlg system, but is displayed on the website (there is also a checkbox to disable header + footer). Now that chrome has remade printdlg , can chrome also provide api for managing print with javascript?

Are there other solutions on the horizon? This cannot be the final state to print from a browser with full control of pdf or other plugins.

+7
source share
2 answers

Javascript is currently very limited in accessing resources "outside the browser," such as hardware and the file system, for security reasons. Emphasizing this trend, I doubt that software control is being printed to be in future Javascript. I say this because having those headers and footers (despite how ugly they are), the user’s decision must ultimately be made.

Even with CSS3, you're still talking about reaching content outside the HTML document itself. These headers and footers are set by the functions of the internal browser. However, Chrome creates a simple user interface to get rid of them when printing. A.

However, especially with Chrome, there are a lot of features in their extensions, especially if you use NDAPI plugins (although this only poses a different security risk). This route is very technical, but probably could be a “different solution”.

+1
source

Do it:

@page { margin: 0; } 

Done!

+11
source

All Articles