Skip to main content
Tweeted twitter.com/#!/StackSalesforce/status/492197479048544256
edited title
Link
Boris Bachovski
  • 16.3k
  • 8
  • 50
  • 88

want to display Display header and footersfooter in all PdfPDF pages using vfVF

deleted 1446 characters in body
Source Link
Boris Bachovski
  • 16.3k
  • 8
  • 50
  • 88
 <apex:page renderAs="pdf" Controller="testpdf1">
    
            <head>
    
                    <style type="text/css" media="print">
                           @page {
                          {
                size: 8.5in 11in;/* width height */
                                     }
                           
                           @page {
    
                                     {
                                     @top-center {
    
                       {
                    content: element(header);
    
                                     }
    
                      
                @bottom-left {
    
                     {
                    content: element(footer);
    
                                     }
    
                                }
    
                              
            div.header {
    
                          {
                padding: 10px;
    
                                          position: running(header);
    
                               }
                
            div.footer {
    
                    {
                display: block;
    
                                 padding: 5px;
    
                                   position: running(footer);
    
                          }
    
                                         .pagenumber:before {
    
                            {
                content: counter(page);
    
                           }
    
                            
            .pagecount:before {
    
                 {
                content: counter(pages);
    
                            }
    
                        </style>
    
                  </head>
    
    
    
               <div class="header">
    
                  <div align="right">Header</div>
    
               </div>
    
               <div class="footer">
    
                    <div>Page <span class="pagenumber"/> of <span class="pagecount"/></div>
    
              </div>
    
              <div class="content">
    
       <p>
            <p><apex<apex:repeat value="{!opp}" var="item">
                <tr>
                    <td class="tableContent">{!item.Name}</td>
                   
                </tr>
            </apex:repeat></p>
    repeat>
              </div>p>
    </div>
    </apex:page>

controllerController

public class testpdf1
{
    public list<Account> opp{get;set;}

    public testpdf1()
    {
           opp=[SELECT Name  from Account limit 50];
       
          
    }
 
}
 <apex:page renderAs="pdf" Controller="testpdf1">
    
            <head>
    
                    <style type="text/css" media="print">
                           @page {
                                          size: 8.5in 11in;/* width height */
                                     }
                           
                           @page {
    
                                     
                                     @top-center {
    
                                           content: element(header);
    
                                     }
    
                                     @bottom-left {
    
                                         content: element(footer);
    
                                     }
    
                                }
    
                                         div.header {
    
                                          padding: 10px;
    
                                          position: running(header);
    
                               }
                           div.footer {
    
                                    display: block;
    
                                 padding: 5px;
    
                                   position: running(footer);
    
                          }
    
                                         .pagenumber:before {
    
                                            content: counter(page);
    
                           }
    
                                       .pagecount:before {
    
                                 content: counter(pages);
    
                            }
    
                        </style>
    
                  </head>
    
    
    
               <div class="header">
    
                  <div align="right">Header</div>
    
               </div>
    
               <div class="footer">
    
                    <div>Page <span class="pagenumber"/> of <span class="pagecount"/></div>
    
              </div>
    
              <div class="content">
    
                   <p><apex:repeat value="{!opp}" var="item">
                <tr>
                    <td class="tableContent">{!item.Name}</td>
                   
                </tr>
            </apex:repeat></p>
    
              </div>
    
    </apex:page>

controller

public class testpdf1
{
    public list<Account> opp{get;set;}

    public testpdf1()
    {
           opp=[SELECT Name  from Account limit 50];
       
          
    }
 
}
<apex:page renderAs="pdf" Controller="testpdf1">
    <head>
        <style type="text/css" media="print">
            @page 
            {
                size: 8.5in 11in;/* width height */
            }
             
            @page 
            {
                @top-center 
                {
                    content: element(header);
                }
                 
                @bottom-left 
                {
                    content: element(footer);
                }
            }
             
            div.header 
            {
                padding: 10px;
                position: running(header);
            }
 
            div.footer 
            {
                display: block;
                padding: 5px;
                position: running(footer);
            }

            .pagenumber:before 
            {
                content: counter(page);
            }
             
            .pagecount:before 
            {
                content: counter(pages);
            }
        </style>
    </head>

    <div class="header">
            <div align="right">Header</div>
    </div>
    
    <div class="footer">
        <div>Page <span class="pagenumber"/> of <span class="pagecount"/></div>
    </div>
    
    <div class="content">
        <p>
            <apex:repeat value="{!opp}" var="item">
                <tr>
                    <td class="tableContent">{!item.Name}</td>
                </tr>
            </apex:repeat>
        </p>
    </div>
</apex:page>

Controller

public class testpdf1
{
    public list<Account> opp{get;set;}

    public testpdf1()
    {
        opp=[SELECT Name  from Account limit 50];
    }
}
Source Link
PavanFoxPro
  • 1.2k
  • 3
  • 23
  • 40

want to display header and footers in all Pdf pages using vf

My vf page

 <apex:page renderAs="pdf" Controller="testpdf1">
    
            <head>
    
                    <style type="text/css" media="print">
                           @page {
                                          size: 8.5in 11in;/* width height */
                                     }
                           
                           @page {
    
                                     
                                     @top-center {
    
                                           content: element(header);
    
                                     }
    
                                     @bottom-left {
    
                                         content: element(footer);
    
                                     }
    
                                }
    
                                         div.header {
    
                                          padding: 10px;
    
                                          position: running(header);
    
                               }
                           div.footer {
    
                                    display: block;
    
                                 padding: 5px;
    
                                   position: running(footer);
    
                          }
    
                                         .pagenumber:before {
    
                                            content: counter(page);
    
                           }
    
                                       .pagecount:before {
    
                                 content: counter(pages);
    
                            }
    
                        </style>
    
                  </head>
    
    
    
               <div class="header">
    
                  <div align="right">Header</div>
    
               </div>
    
               <div class="footer">
    
                    <div>Page <span class="pagenumber"/> of <span class="pagecount"/></div>
    
              </div>
    
              <div class="content">
    
                   <p><apex:repeat value="{!opp}" var="item">
                <tr>
                    <td class="tableContent">{!item.Name}</td>
                   
                </tr>
            </apex:repeat></p>
    
              </div>
    
    </apex:page>

controller

public class testpdf1
{
    public list<Account> opp{get;set;}

    public testpdf1()
    {
           opp=[SELECT Name  from Account limit 50];
       
          
    }

}

I am getting all records in pdf format but able to get header in first page only and i am not getting header from second pages how can i display header to all pages.