+ Start a Discussion
Aruna VasahanAruna Vasahan 

Add header to all the pages when printing a visualforce page

I want to print dynamic header in all the pages of a visualforce paage rendered document. By using CSS styles I am able to get header in visualforce page when rendered as pdf but header is not coming when printed using window.print().
Here is my code:
<apex:page controller="Template" showHeader="false" standardStylesheets="false"  sidebar="false" action="{!renderTemplate}" 
           renderAs="{!chooserender}" applyHtmlTag="false" applyBodyTag="false" >
            <style type="text/css" media="print">
                @page {
                    padding-top: 40px;
                    @top-center {
                        content: element(header);
                div.header {
                    padding :10px;
                    position: running(header);
            <apex:form id="renderContentForm">
                <div class="header">

                    <apex:outputText id="htmlHeaddddd" value="{!htmlHead}" >   </apex:outputText> 
                <div id='content'>

                    <apex:outputText id="htmlText" value="{!htmlCode}" ></apex:outputText>  
In render as="Pdf" I am getting "header"n all pages but when tried to "print" I am not getting the "header". Do anyone know how to do this?
Dushyant SonwarDushyant Sonwar
I don't think this issue is related to code as you said that you are clicking standard print button when pdf is generated.
Please review the below article for this issue.
Aruna VasahanAruna Vasahan
@Dushyant, that page doen't have answer for me. I was not able to find the options mentioned in that page in my printer settings. I want something in my code that makes my code to work.