function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Brijesh KumarBrijesh Kumar 

Javascript to print without header and footer information

Hi All,


I want to print a report(visualforce page) by using window.print().In printed page,it prints some extra information like header as URL and Footer as page information and date information.I don't wamt to print these extra information.How can i hide header and footer from printed page.

Please reply me as soon as possible It's very urgent for my project.

 

Thanks & Regards,

Brijesh Baser



 

SatgurSatgur

Window.print() function prints complete web page, but when we need to print the content of VF page only then we first need to get the IFrame Id of the VF page, then need to make small changes in our code to print IFrame content only.

 

First we need to find the Iframe id dynamically using

 

window.frameElement.id

 Then we need to make few changes in our JavaScript code as...

 

<script> function iprint(ptarget) { ptarget.focus(); ptarget.print(); } </script>

 

 Hope this helps.

 

Thanks,

Satgur

 

 

 

Gaurav pathak 23Gaurav pathak 23
I am also having same kind of task in Visualforce. 
you can do with the help of CSS , before print set the CSS of the page .
 
<style type="text/css">
@media print{
  body{ background-color:#FFFFFF; background-image:none; color:#000000 }
  .bPageHeader{ display:none;}   //For HeaderHide
  #AppBodyHeader{ display:none;}

  .bPageFooter{ display:none;}    //For Footer Hide
   .noTableFooter{ display:none;}
   .btn btn-primary{ display:none;}  //For button Hide
   #btn1{ display:none;}   //For button Hide
}
</style>




IF you are asking about browser specific settings like print date and time , then i think it is not possible through code.