How to remove the URL from the printing page?

HtmlPrintingFooter

Html Problem Overview


I want to remove the URL that gets printed on the bottom of the page.

like:

yomari.com/.../main.php?sen_n

How can it be omitted or prevent from getting printed?

To be more specific, is there any way I can prevent the page URL, date and the page title being printed along, while printing the web page?

Html Solutions


Solution 1 - Html

Following code sample will work for you,

<style type="text/css" media="print">
@page {
    size: auto;   /* auto is the initial value */
    margin: 0;  /* this affects the margin in the printer settings */
}
</style>

see the answer on https://stackoverflow.com/questions/1960939/disabling-browser-print-options-headers-footers-margins-from-page

and specification of the @page

Solution 2 - Html

i found something in the browser side itself.

Try this steps. here i have been mentioned the Steps to disable the Header and footer in all the three major browsers.

Chrome Click the Menu icon in the top right corner of the browser. Click Print. Uncheck Headers and Footers under the Options section.

Firefox Click Firefox in the top left corner of the browser. Place your mouse over Print, the click Page Setup. Click the Margins & Header/Footer tab. Change each value under Headers & Footers to --blank--.

Internet Explorer Click the Gear icon in the top right corner of the browser. Place your mouse over Print, then click Page Setup. Change each value under Headers and Footers to -Empty-.

Solution 3 - Html

Having the URL show is a browser client preference, not accessible to scripts running within the page (let's face it, a page can't silently print themselves, either).

To avoid "leaking" information via the query string, you could submit via POST

Solution 4 - Html

If you set the margin for a page using the code below the header and footers are omitted from the printed page. I have tested this in FireFox and Chrome.

<style media="print">
 @page {
  size: auto;
  margin: 0;
       }
</style>

Solution 5 - Html

This helped me: Print page without links

@media print {
    a[href]:after {
        content: none !important;
    }
}

Solution 6 - Html

Browser issue but can be solved by these:

<style type="text/css" media="print">
      @media print
      {
         @page {
           margin-top: 0;
           margin-bottom: 0;
         }
         body  {
           padding-top: 72px;
           padding-bottom: 72px ;
         }
      } 
</style>

Solution 7 - Html

I am telling you about Mozilla Firefox ( I hope it should be same way in other browsers also).

Click on Firefox menu , Go to Print , Select Page Set Up from sub menu of Print. A pop will come up on your screen, there go to "Margin & Header /Footer" tab.

In that select "BLANK" for header / footer as per requirement before printing. You can check the preview for confirmation.

I hope this will help.

Solution 8 - Html

Nowadays, you can use history API to modify the URL before print, then change back:

var curURL = window.location.href;
history.replaceState(history.state, '', '/');
window.print();
history.replaceState(history.state, '', curURL);

But you need to make a custom PRINT button for user to click.

Solution 9 - Html

You can remove the url dispalying on the printed document via your browser settings.You just click file->page setup->header and footer set all things as blank.if you hav ie,you just remove &U from footer textbox.hopefully this will help you

Solution 10 - Html

I do not know if you are talking about a footer within your actual graphic or the url the print process within the browser is doing.

If its the url the print process is doing its really up to the browser if he has a feature to turn that off.

If its the footer information i would recommend using a print stylesheet and within that stylesheet to do

display: none;

For the particular ID or class of the footer.

To do a print stylesheet, you need to add this to the head.

<link rel="stylesheet" type="text/css" href="/css/print.css" media="print" />

Solution 11 - Html

@media print { a[href]:after { content: none !important; } }

Solution 12 - Html

This is working fine for me using jquery

<style>
  @media print { @page { margin: 0; } 
   body { margin: 1.6cm; } }
</style>

Solution 13 - Html

In Google Chrome, this can be done by setting the margins to 0, or if it prints funky, then adjusting it just enough to push the unwanted text to the non-printable areas of the page. I tried it and it works :D

enter image description here

Solution 14 - Html

On Chrome 57 the following worked for me, if you have control of the HTML page that needs to be printed (in my case I needed to print a small 3x1 inch label):

  • remove the HTML title element from header (either temporarily using jquery or permanently if that page does not really need a title)
  • set the @page margin to 0 as mentioned by @Chamika Sandamal

This resulted in printing a page that only contained the body text, no URLs, no page #s etc.

Solution 15 - Html

I would agree with most of the answers saying that its a browser settings but still you can achieve what you want via COM. Keep in mind that most browsers will still have issue with that and even IE will raise the COM security bar to users. So unless its not something you are offering within organisation, don't do it.

Solution 16 - Html

I have the same problem. I wonder if it is possible to create the HTML for printing via a jquery plugin: http://www.recoding.it/?p=138

Then send the HTML to a php script (using an ajax call), generate a pdf with http://www.xhtml2pdf.com/ or http://code.google.com/p/wkhtmltopdf/.

Afterwards the pdf could be displayed (by setting the appropriate content type and direct rendering) or displayed by a http-Redirect to the generated pdf.

The generated pdfs in the pfd_for_printing-folder could act as cache and be deleted by a job once a day.

Solution 17 - Html

<style type="text/css" media="print">
  @page {
    size: auto;  
    margin: 0;  
  }
</style>
//now set manual padding to body
<style>
  body{
    padding-left: 1.3cm;
    padding-right: 1.3cm; 
    padding-top: 1.1cm;
  }
</style>

Solution 18 - Html

Chrome headless now supports an extra options --print-to-pdf-no-header which removed header and footer from the printed PDF file

Solution 19 - Html

Perhaps you could try chrome (Probably Safari also)

The url & the page number in the header & footer is not visible when I print to pdf on OSX with Google Chrome.

Sorry not sure if this applies to windows

Solution 20 - Html

I have a trick to remove it from the print page in Firefox. Use this:

<html moznomarginboxes mozdisallowselectionprint>

In the html tag you have to use moznomarginboxes mozdisallowselectionprint. I am sure it will help you a lot.

Solution 21 - Html

@media print {
    #Header, #Footer { display: none !important; }
}

Check this link

Solution 22 - Html

This will be the simplest solution. I tried most of the solutions in the internet but only this helped me.

@print {
    @page :footer {
        display: none
    }

    @page :header {
        display: none
    }
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjarusView Question on Stackoverflow
Solution 1 - HtmlChamika SandamalView Answer on Stackoverflow
Solution 2 - HtmlJah YusuffView Answer on Stackoverflow
Solution 3 - HtmlRowland ShawView Answer on Stackoverflow
Solution 4 - HtmlDenver ChiwakiraView Answer on Stackoverflow
Solution 5 - HtmlmihaelaView Answer on Stackoverflow
Solution 6 - HtmlMd. Hasibul HuqView Answer on Stackoverflow
Solution 7 - HtmlMitravind GargView Answer on Stackoverflow
Solution 8 - HtmlJames YangView Answer on Stackoverflow
Solution 9 - HtmlAnjuView Answer on Stackoverflow
Solution 10 - HtmlÓlafur WaageView Answer on Stackoverflow
Solution 11 - HtmlRashid KhitilovView Answer on Stackoverflow
Solution 12 - HtmlMugeesh HusainView Answer on Stackoverflow
Solution 13 - HtmlArdee AramView Answer on Stackoverflow
Solution 14 - HtmlJohnnyView Answer on Stackoverflow
Solution 15 - HtmlhashView Answer on Stackoverflow
Solution 16 - HtmlchrisView Answer on Stackoverflow
Solution 17 - HtmlRajiv ChaturvediView Answer on Stackoverflow
Solution 18 - HtmlSanteView Answer on Stackoverflow
Solution 19 - HtmlPhilDView Answer on Stackoverflow
Solution 20 - HtmlAryanView Answer on Stackoverflow
Solution 21 - HtmlLien VuView Answer on Stackoverflow
Solution 22 - HtmlZanyar J.AhmedView Answer on Stackoverflow