How to Remove Header and Footer from Visualforce Page in Print Preview Screen?
Sample Code:
Visualforce Page:
<apex:page controller="SampleController" showHeader="false">
<head>
<style type="text/css">
@page{
size: auto A4 landscape;
margin: 3mm;
}
</style>
</head>
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!listofAcct}" var="a">
<apex:column value="{!a.Id}"/>
<apex:column value="{!a.Name}"/>
</apex:pageBlockTable>
<apex:pageBlockButtons >
<apex:commandButton value="Print" onclick="window.print()"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
public class SampleController{
public List < Account > listofAcct {get;set;}
public SampleController() {
listofAcct = [ SELECT Id, Name FROM Account ];
}
}
Follow Us