How can we set header, footer off while printing a php webpage?

Discussion in 'CSS' started by tejasluvs, Jun 28, 2010.

  1. #1
    There is an invoice preview webpage. I want to set header and footer information off while printing it. I know we can edit the page setup settings. But I wanted to know if we can do something without changing the default page setup settings. With default setting inside page setup, webpage title and webpage path are displayed for header and footer respectively.

    Thanks
     
    tejasluvs, Jun 28, 2010 IP
  2. wab

    wab Member

    Messages:
    57
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    try with jquery:
    
     $("#printButton").click(function() {
        $("#header").remove();
        $("#footer").remove();
        window.print();
    });
    
    Code (markup):
     
    wab, Jun 28, 2010 IP
  3. tejasluvs

    tejasluvs Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the above code. But I Need to remove Title from a print out which is header under page setup and URL that acts as a footer by default. Can you help?
     
    tejasluvs, Jun 28, 2010 IP
  4. wab

    wab Member

    Messages:
    57
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #4
    I think you cannot access the printer's settings with Javascript or css
     
    wab, Jun 29, 2010 IP
  5. bvraghav

    bvraghav Member

    Messages:
    123
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    33
    #5
    It can be modified by accessing the print settings of the browser or may be page setup
     
    bvraghav, Jun 29, 2010 IP
  6. Asgeco

    Asgeco Member

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #6
    All you need to do is to make another css file and add some css.
    You need to include your print styles with media attribute set to "print" like this
    <link rel="stylesheet" type="text/css" media="print" href="print.css" />
    then for example if you want to hide some website parts while printing you just need to write something like

    #element{
    display:none;
    }
    Code (markup):
    to your print.css file.
     
    Asgeco, Jun 29, 2010 IP
  7. wab

    wab Member

    Messages:
    57
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #7
    it's not possible with javascript (Hopefully! I wouldn't like my settings or something else modified by a page without my permission), but apparently that can be done with some ActiveX. You can easily find some scripts already done on the web, that can allow you to modify some settings like orientation or margins.
     
    wab, Jun 29, 2010 IP
  8. tejasluvs

    tejasluvs Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks for the note..
     
    tejasluvs, Jun 29, 2010 IP