That's basically it. Somehow, the javascript in Google Docs can turn off the default headers and footers showing the URL, date, page numbering, etc.
This only works in Google Chrome. When Google Docs is running from another browser it will print the headers/footers unless removed manually through the print configuration dialog. In Safari, it seems to generate a PDF server-side which of course will print outside of the browser.
I've searched around the web and have found nothing on how this is done. The javascript in the page is of course minified and obfuscated so it's difficult to get any insights from there.
So before I'm forced to dive into that spaghetti, I'd like to know if anybody has any ideas of how this is done.
That's basically it. Somehow, the javascript in Google Docs can turn off the default headers and footers showing the URL, date, page numbering, etc.
This only works in Google Chrome. When Google Docs is running from another browser it will print the headers/footers unless removed manually through the print configuration dialog. In Safari, it seems to generate a PDF server-side which of course will print outside of the browser.
I've searched around the web and have found nothing on how this is done. The javascript in the page is of course minified and obfuscated so it's difficult to get any insights from there.
So before I'm forced to dive into that spaghetti, I'd like to know if anybody has any ideas of how this is done.
Share Improve this question asked Mar 12, 2012 at 18:31 Sebastian FerreyraSebastian Ferreyra 5912 gold badges4 silver badges13 bronze badges 2- are you sure? i've several times had to reprint a doc because i forgot to turn off the header/footers settings. But i also noticed that afterwards, they stay off. maybe Chrome remembers it (per site? per URL?) and you don't remember having turned it off initially. – Javier Commented Mar 12, 2012 at 18:36
- Well, at least in the latest version of Chrome (I have no idea about the behaviour of previous versions), in the print preview dialog, clicking on the 'Headers and footers' checkbox has no effect at all. The headers/footers will not e up whatever the state of the checkbox, when printing with Google Docs that is. – Sebastian Ferreyra Commented Mar 12, 2012 at 18:42
1 Answer
Reset to default 13After delving into some source code I found on a web page that has also resolved the issue (not Google Docs), the secret is the following CSS:
@page
{
margin:0;
}
This only works on Chrome, and perhaps Opera though I have to verify if the latter is true as it's printing the background color by default while chrome prints with a white background and the colored background in my page might be just obscuring the header/footer text.
Other browsers give differing results:
- Firefox and Safari ignore the margins apparently and print the headers/footers anyway.
- IE9 makes a mess of things and the contents print overlapped with the header/footer text. Poor browser always gets all the heat...
In conclusion, bining this with silent printing ing out in Chrome 18 kiosk mode will make for some interesting functionality, such as mail merge capabilities right from the browser though I still have to research how secure kiosk mode is though, as navigating to a malicious page runs the risk of exhausting printer ink and paper.
Navigation should be restricted to a URL white-list in this case.