Stop browser from adding headers and footers when printing page

SuzzyR Suzzyr
SuzzyR Suzzyr used Ask the Experts™
on
I need to be able to print off worksheets from my web pages, but i dont want the page titles and urls to be printed at top and bottom of the page, is there a way to stop this information being printed

the site is built in ASP classic,  will  use jquery/javascript to accomplish this if that is the way to go

Alternatively can you send options to the print preview screen to remove these from the page instead of having to change them in the print preview screen
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
David FavorFractional CTO
Distinguished Expert 2018

Commented:
You have no control over this.

Browser settings determine exact format of print out.

All you can do is change how a page prints locally for you.
ZeropointNRGHedge Fund Manager

Commented:
I heard if you use Edge browser, the header and footer is off by default?
David FavorFractional CTO
Distinguished Expert 2018

Commented:
I think what this person is asking is how to effect this from the server side, which is impossible.

Every new browser release, the browser may change their default printing template.

Also many users, like me, change all their browser print templates to custom templates, so again...

There's no way to effect this from the server side, as each local browser instances + user customizations can be different.
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

ZeropointNRGHedge Fund Manager

Commented:
Ah righto.

Author

Commented:
thats fine... wanted to do this server side if i could, but i do have controll of all the PC's that will be using the site so i could set them up

is it possible to save the print setting per domain on windows?
ZeropointNRGHedge Fund Manager

Commented:
Is it your website? If it is, can't you use a custom stylesheet with media print settings?

Author

Commented:
it is, but thats an area i didnt even know existed
ZeropointNRGHedge Fund Manager

Commented:
Try this

@media print {
    .footer,
    #non-printable {
        display: none !important;
    }
    #printable {
        display: block;
    }
}

Open in new window

Hi,

A solution will be to generate a PDF instead of directly printing.
I'm using Html2PDF script with server side language, It let you add your own page header & footer or you can leave it blank.
This can be anything you want, for example I put product name in header and paging in the footer.

Script: https://github.com/spipu/html2pdf
Demo: https://html2pdf.fr/en/default

I'm using it in all my application and it work very well.

*Note @media print won't work with print header / footer of a page because it is a browser setting, it cannot be controlled by CSS and it is not a part of your html page.
** Note printer may have hardcoded margin (not really related to your question, but good to know)
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
Based on your recent question about a print que, My second option would do the trick https://www.experts-exchange.com/questions/29153257/Creating-a-print-cue-on-a-web-site.html#a42912262. You can create a pdf and print the pdf in the same manner. If you print the pdf from a browser, you will still get the info you don't want. And the pdf will take up space. I wouldn't create a pdf unless you need to store it for some reason because you can just as easily recreate it from the database and your coding.
Hi @scott my solution is not printing as a PDF but generate a PDF file on the fly which is different.
Using HTML2PDF does this not required to save a generated PDF it can only output the result.
Different way to output:
https://github.com/spipu/html2pdf/blob/master/doc/output.md#examples

So using HTML2PDF will not output the browser header / footer, we use these to set custom data or leave it empty
<page_header></page_header> 
<page_footer></page_footer>

Open in new window


https://github.com/spipu/html2pdf/tree/master/doc
If you have control over all of the computers that will be using this site, and the computers are on a domain, there may be some GPO admin templates you can implement that will control the default print setting for Google Chrome.
https://cloud.google.com/chrome-enterprise/browser/download/

If you use Firefox, I believe Group Policies can also be implemented by manipulating the Firefox config.
https://addons.mozilla.org/en-US/firefox/addon/enterprise-policy-generator/
Thank you all, the benefit of this at the moment doesnt warrant the work involved so i have put this on the todo list

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial