Skip to main content
added 1032 characters in body
Source Link

Visualforce:

     <apex:page standardController="Opportunity" extensions="testpportunity1"   showHeader="false" sidebar="false"  docType="html-5.0" applyBodyTag="false" applyHtmlTag="false" renderAs="PDF">
/////Method 1//////////
         <html lang="en-us" dir="ltr">
            <head>
                <style>
                    @page {
                        @top-center {
                            content: "Opportunity PDF";
                            background: url("{!$Resource.IconSample}");
                        }
                         @top-left {
                            background: url("{!$Resource.IconSample}");
                        }
                        
                        @bottom-center {
                            content: "Page " counter(page) " of " counter(pages);
                        }
                    }
/////Method 1 ends//////////
/////Method 2 begins//////////
     div.header {
                    background: url("{!$Resource.IconSample}") ;
                    margin-top: 30px;
                    height: 130px;
                    width: 715px;
                    text-align: center;
                    position: running(header);
                }
    /////Method 2 ends//////////
    </style>
    
                </head>
                <body>
                </body>
              <div class="header"></div>   
         </html>
         
          <!--<apex:image url="{!$Resource.IconSample}"  width="220" height="150" />-->
        <br/>
         <apex:outputText style="text-align:left; width : 100%;font-size: 16px;" value="Address"></apex:outputText><br/>
         <apex:outputText style="text-align:left; width : 100%;font-size: 16px; " value="Street"></apex:outputText><br/>
          <apex:outputText style="text-align:left; width : 100%;font-size: 16px; " value="City"></apex:outputText><br/>
        
        <apex:form >
        <apex:pageBlock >
        <table>
                    <tr>
                    <td colspan="4">
                      <html lang="en-us" &nbsp;dir="ltr">
                    </td><head>
                  <style  <type="text/tr>
                    <tr>
                    <td colspan="4">
                        &nbsp;
                   css" </td>media="print">
                   @page </tr>{
                    </table>
                      <apex:pageblocksection columns="1" title=" Opportunity Information">
            <table width="100%" style="font-family: Arial, Helvetica, sans@bottom-serif;">
                  <apex:repeatcenter value="{!oppList}" var="opp">
                <tr>
                   <tr>
                    <td align="right" style="colorcontent: #808080;">
                  "Page " counter(page) " of " OpportunityOwnercounter(pages);
                    </td>
                    <td>}
                        {!opp.Ownerdiv.Name}header{
                    </td>
                    <td align="right" style="colorposition: #808080;">
                        OpportunityName
                    </td>
                    <td>running(header);
                        {!opp.Name}
                    </td>
                </tr>
                
                <tr>
                    <td align="right" style="color: #808080; ">
                        Account Name
                    </td>
                    <td>
                        {!opp.Account.Name}
                    </td>
                    <td align="right" style="color: #808080;">
                        Type
                    </td>
                    <td>
                         {!opp.Type}
                    </td>
                </tr>
                <tr>
                    <td align="right" style="color: #808080; ">
                        StageManagement
                    </td>
                    <td>
                         {!opp.Stage_Management__c}
                    </td>
                    <td align="right" style="color: #808080; ">
                        Stage
                    </td>
                    <td>
                        {!opp.StageName}
                    </td>
                </tr>
                <tr>
                    <td align="right" style="color: #808080;  ">
                        CloseDate
                    </td>
                    <td>
                        {!opp.CloseDate}
                    </td>
                    <td align="right" style="color: #808080;  ">
                        Probability
                    </td>
                    <td>
                        {!opp.Probability}
                    </td>
                </tr> 
                    
                </tr>
               
                <tr>
                    <td colspan="4">
                        &nbsp;
                    </td>
                </tr>
                </apex:repeat>style>
            </table>head>
            </apex:pageblocksection><body>
            </apex:pageBlock>
             body>
             
     </html>
      <div class="header">
        <img src="{!$Resource.IconSample}" width="25%" />
      </div>
                  <!--<apex:pageBlockimage url="{!$Resource.IconSample}"  width="220" height="150" />-->
                <br/>
                 <apex:pageblocksectionoutputText columns="1"style="text-align:left; title="width Product: Details">100%;font-size: 16px;" value="Address"></apex:outputText><br/>
                 <apex:outputText style="text-align:left; width : <table100%;font-size: width="800px"16px; height="1200px"" value="Street"></apex:outputText><br/>
                  <apex:outputText style="text-align:left; <apexwidth :variable value="{!1}100%;font-size: 16px; " var="i"value="City"></apex:outputText><br/>
                 
        <tr style="background-color       <apex:{!IF(mod(i,2)==0,form '>
 #C0C0C0', '#C0C0C0')};">              <apex:pageBlock >
                <table>
            <th>Product Name<               <tr>
                            <td colspan="4">
                                &nbsp;
                            </th>td>
                            <th>Quantity<</th>tr>
                            <th>Unit<tr>
 Price</th>                           <td colspan="4">
                            <th>Total Price<   &nbsp;
                            </th>td>
                            </tr>
                            </table>
                              <apex:variablepageblocksection value="{!i+1}"columns="1" var="i"title=" />Opportunity Information">
                    <table width="100%" style="font-family: Arial, Helvetica, sans-serif;">
                          <apex:repeat value="{!prodList oppList}" var="prod">var="opp">
                        <apex<tr>
                           <tr>
                            <td align="right" style="color:variable value="#808080;">
                                OpportunityOwner
                            </td>
                            <td>
                                {!1opp.Owner.Name}" 
 var="i"                           </>td>
                            <tr<td style="background-coloralign="right" style="color: #808080;">
                                OpportunityName
                            </td>
                            <td>
                                {!IF(mod(i,2)==0,opp.Name}
 ' #C0C0C0', '#C0C0C0')};">                         </td>
                        </tr>
                        
                        <tr>
                            <td align="right" style="color: #808080; ">
                                Account Name
                            </td>
                            <td>
                                {!prod.pricebookentryopp.product2Account.nameName}
                            </td>
                            <td align="right" style="color: #808080;">
                                Type
                            </td>
                            <td>
                                 {!prodopp.quantityType}
                            </td>
                        </tr>
                        <tr>
                            <td align="right" style="color: #808080; ">
                                StageManagement
                            </td>
                            <td>
                                 {!prodopp.quantityStage_Management__c}
                            </td>
                            <td align="right" style="color: #808080; ">
                                Stage
                            </td>
                            <td>
                                {!prodopp.TotalPriceStageName}
                            </td>
                        </tr>
                        <tr>
                            <td align="right" style="color: #808080;  ">
                                CloseDate
                            </tr>td>
                            <td>
    <apex                            {!opp.CloseDate}
                            </td>
                            <td align="right" style="color:variable value="#808080;  ">
                                Probability
                            </td>
                            <td>
                                {!i+1opp.Probability}" 
 var="i"                           </td>
                        </>tr> 
                            
                        </tr>
                       
                        <tr>
                            <td colspan="4">
                                &nbsp;
                            </td>
                        </tr>
                        </apex:repeat>
                    </table>
                    </apex:pageblocksection>
                    </apex:pageBlock>
                     
                     
                      <apex:pageBlock >
                       <apex:pageblocksection columns="1" title=" Product Details">
                            <table width="800px" height="1200px" >
                            <apex:variable value="{!1}" var="i"/>
                                <tr style="background-color:{!IF(mod(i,2)==0, ' #C0C0C0', '#C0C0C0')};">
                                    <th>Product Name</th>
                                    <th>Quantity</th>
                                    <th>Unit Price</th>
                                    <th>Total Price</th>
                                 </tr>
                                  <apex:variable value="{!i+1}" var="i" />
                                   <apex:variable value="{!1}" var="i"/>
                                <apex:repeat value="{!prodList }" var="prod">
                               <tr style="background-color:{!IF(mod(i,2)==0, ' #C0C0C0', '#C0C0C0')};">
                                        <td>{!prod.pricebookentry.product2.name}</td>
                                         <td> {!prod.quantity}</td>
                                            <td> {!prod.quantity}</td>
                                            <td> {!prod.TotalPrice}</td>
                                        </tr>
                                        <apex:variable value="{!i+1}" var="i" />
                                </apex:repeat>
                            </table>
                            </apex:pageblocksection>
                        </apex:pageBlock>
                        <style>
                
                </style>
                   </apex:form>
                   <apex:outputText >xyz</apex:outputText><br/><br/>
                   <apex:outputText value="order:" style="text-align:center; width : 100%;font-size: 16px; font-weight: bold ;  color :#000000"> </apex:outputText> <apex:outputText >Salsforce</apex:outputText><br/>
                 <apex:outputText > Visualforce</apex:outputText><br/>
                 <br/><apex:outputText style="text-align:left;font-weight: bold;" value="Best Regards,"></apex:outputText><br/>
                 <br/><div style="text-align:center;font-size: 15px;">
                            <apex:outputText style="text-align:center;font-weight:bold;"  value="Thank you"></apex:outputText></div>
                            <br/><br/><div style="text-align:center;font-size: 25px;">
                            <apex:outputText style="text-align:center;font-weight:bold;"  value="SALESFORCE"></apex:outputText></div>
                            
                   <p class="par">
                         
                            This is Opportunity page.
                            
                            </p>        
                            
                  </apex:page>

Controller:

public class testpportunity1{
 public List <Opportunity> oppList{get;set;}
  public List <OpportunityLineItem> prodList{get;set;} 
  public user cuser{get;set;}
  
   
public testpportunity1(ApexPages.StandardController controller) {
 oppList = new List <Opportunity>();
        oppList = [SELECT name, owner.name,Account.Name, stagename, amount,ExpectedRevenue,NextStep,LeadSource,Probability, CloseDate,Type,Stage_Management__c
                               FROM Opportunity
                               WHERE id = '789456123'];
    System.debug('opportunity list------->'+oppList);
    prodList =new List <OpportunityLineItem>();
     prodList = [SELECT PricebookEntry.Product2.Name, quantity, unitprice, totalprice
                                                    FROM OpportunityLineItem
                                                    WHERE OpportunityID='789456123'];
      cuser=[select id,Username,Signature__c from user where id=:UserInfo.getUserId()];
       System.debug('User list------->'+cuser);

    }
    
  }
     <apex:page standardController="Opportunity" extensions="testpportunity1"   showHeader="false" sidebar="false"  docType="html-5.0" applyBodyTag="false" applyHtmlTag="false" renderAs="PDF">
/////Method 1//////////
         <html lang="en-us" dir="ltr">
            <head>
                <style>
                    @page {
                        @top-center {
                            content: "Opportunity PDF";
                            background: url("{!$Resource.IconSample}");
                        }
                         @top-left {
                            background: url("{!$Resource.IconSample}");
                        }
                        
                        @bottom-center {
                            content: "Page " counter(page) " of " counter(pages);
                        }
                    }
/////Method 1 ends//////////
/////Method 2 begins//////////
     div.header {
                    background: url("{!$Resource.IconSample}") ;
                    margin-top: 30px;
                    height: 130px;
                    width: 715px;
                    text-align: center;
                    position: running(header);
                }
    /////Method 2 ends//////////
    </style>
    
                </head>
                <body>
                </body>
              <div class="header"></div>   
         </html>
         
          <!--<apex:image url="{!$Resource.IconSample}"  width="220" height="150" />-->
        <br/>
         <apex:outputText style="text-align:left; width : 100%;font-size: 16px;" value="Address"></apex:outputText><br/>
         <apex:outputText style="text-align:left; width : 100%;font-size: 16px; " value="Street"></apex:outputText><br/>
          <apex:outputText style="text-align:left; width : 100%;font-size: 16px; " value="City"></apex:outputText><br/>
        
        <apex:form >
        <apex:pageBlock >
        <table>
                    <tr>
                    <td colspan="4">
                        &nbsp;
                    </td>
                    </tr>
                    <tr>
                    <td colspan="4">
                        &nbsp;
                    </td>
                    </tr>
                    </table>
                      <apex:pageblocksection columns="1" title=" Opportunity Information">
            <table width="100%" style="font-family: Arial, Helvetica, sans-serif;">
                  <apex:repeat value="{!oppList}" var="opp">
                <tr>
                   <tr>
                    <td align="right" style="color: #808080;">
                        OpportunityOwner
                    </td>
                    <td>
                        {!opp.Owner.Name}
                    </td>
                    <td align="right" style="color: #808080;">
                        OpportunityName
                    </td>
                    <td>
                        {!opp.Name}
                    </td>
                </tr>
                
                <tr>
                    <td align="right" style="color: #808080; ">
                        Account Name
                    </td>
                    <td>
                        {!opp.Account.Name}
                    </td>
                    <td align="right" style="color: #808080;">
                        Type
                    </td>
                    <td>
                         {!opp.Type}
                    </td>
                </tr>
                <tr>
                    <td align="right" style="color: #808080; ">
                        StageManagement
                    </td>
                    <td>
                         {!opp.Stage_Management__c}
                    </td>
                    <td align="right" style="color: #808080; ">
                        Stage
                    </td>
                    <td>
                        {!opp.StageName}
                    </td>
                </tr>
                <tr>
                    <td align="right" style="color: #808080;  ">
                        CloseDate
                    </td>
                    <td>
                        {!opp.CloseDate}
                    </td>
                    <td align="right" style="color: #808080;  ">
                        Probability
                    </td>
                    <td>
                        {!opp.Probability}
                    </td>
                </tr> 
                    
                </tr>
               
                <tr>
                    <td colspan="4">
                        &nbsp;
                    </td>
                </tr>
                </apex:repeat>
            </table>
            </apex:pageblocksection>
            </apex:pageBlock>
             
             
              <apex:pageBlock >
               <apex:pageblocksection columns="1" title=" Product Details">
                    <table width="800px" height="1200px" >
                    <apex:variable value="{!1}" var="i"/>
                        <tr style="background-color:{!IF(mod(i,2)==0, ' #C0C0C0', '#C0C0C0')};">
                            <th>Product Name</th>
                            <th>Quantity</th>
                            <th>Unit Price</th>
                            <th>Total Price</th>
                         </tr>
                          <apex:variable value="{!i+1}" var="i" />
                        <apex:repeat value="{!prodList }" var="prod">
                        <apex:variable value="{!1}" var="i"/>
                            <tr style="background-color:{!IF(mod(i,2)==0, ' #C0C0C0', '#C0C0C0')};">
                                <td>{!prod.pricebookentry.product2.name}</td>
                                 <td> {!prod.quantity}</td>
                                    <td> {!prod.quantity}</td>
                                    <td> {!prod.TotalPrice}</td>
                                </tr>
                                <apex:variable value="{!i+1}" var="i" />
                        </apex:repeat>
                    </table>
                    </apex:pageblocksection>
                </apex:pageBlock>
                <style>
        
        </style>
           </apex:form>
           <apex:outputText >xyz</apex:outputText><br/><br/>
           <apex:outputText value="order:" style="text-align:center; width : 100%;font-size: 16px; font-weight: bold ;  color :#000000"> </apex:outputText> <apex:outputText >Salsforce</apex:outputText><br/>
         <apex:outputText > Visualforce</apex:outputText><br/>
         <br/><apex:outputText style="text-align:left;font-weight: bold;" value="Best Regards,"></apex:outputText><br/>
         <br/><div style="text-align:center;font-size: 15px;">
                    <apex:outputText style="text-align:center;font-weight:bold;"  value="Thank you"></apex:outputText></div>
                    <br/><br/><div style="text-align:center;font-size: 25px;">
                    <apex:outputText style="text-align:center;font-weight:bold;"  value="SALESFORCE"></apex:outputText></div>
                    
           <p class="par">
                 
                    This is Opportunity page.
                    
                    </p>        
                    
          </apex:page>

Visualforce:

<apex:page standardController="Opportunity" extensions="testpportunity1"   showHeader="false" sidebar="false"  docType="html-5.0" applyBodyTag="false" applyHtmlTag="false" renderAs="PDF">
        
  <html lang="en-us" dir="ltr">
        <head>
            <style  type="text/css" media="print">
                @page {
                   
                    @bottom-center {
                        content: "Page " counter(page) " of " counter(pages);
                     }
                     div.header{
                        position:running(header);
                    }
                
                }
               
           </style>
            </head>
            <body>
            </body>
             
     </html>
      <div class="header">
        <img src="{!$Resource.IconSample}" width="25%" />
      </div>
                  <!--<apex:image url="{!$Resource.IconSample}"  width="220" height="150" />-->
                <br/>
                 <apex:outputText style="text-align:left; width : 100%;font-size: 16px;" value="Address"></apex:outputText><br/>
                 <apex:outputText style="text-align:left; width : 100%;font-size: 16px; " value="Street"></apex:outputText><br/>
                  <apex:outputText style="text-align:left; width : 100%;font-size: 16px; " value="City"></apex:outputText><br/>
                 
                <apex:form >
                <apex:pageBlock >
                <table>
                            <tr>
                            <td colspan="4">
                                &nbsp;
                            </td>
                            </tr>
                            <tr>
                            <td colspan="4">
                                &nbsp;
                            </td>
                            </tr>
                            </table>
                              <apex:pageblocksection columns="1" title=" Opportunity Information">
                    <table width="100%" style="font-family: Arial, Helvetica, sans-serif;">
                          <apex:repeat value="{!oppList}" var="opp">
                        <tr>
                           <tr>
                            <td align="right" style="color: #808080;">
                                OpportunityOwner
                            </td>
                            <td>
                                {!opp.Owner.Name} 
                            </td>
                            <td align="right" style="color: #808080;">
                                OpportunityName
                            </td>
                            <td>
                                {!opp.Name}
                            </td>
                        </tr>
                        
                        <tr>
                            <td align="right" style="color: #808080; ">
                                Account Name
                            </td>
                            <td>
                                {!opp.Account.Name}
                            </td>
                            <td align="right" style="color: #808080;">
                                Type
                            </td>
                            <td>
                                 {!opp.Type}
                            </td>
                        </tr>
                        <tr>
                            <td align="right" style="color: #808080; ">
                                StageManagement
                            </td>
                            <td>
                                 {!opp.Stage_Management__c}
                            </td>
                            <td align="right" style="color: #808080; ">
                                Stage
                            </td>
                            <td>
                                {!opp.StageName}
                            </td>
                        </tr>
                        <tr>
                            <td align="right" style="color: #808080;  ">
                                CloseDate
                            </td>
                            <td>
                                {!opp.CloseDate}
                            </td>
                            <td align="right" style="color: #808080;  ">
                                Probability
                            </td>
                            <td>
                                {!opp.Probability} 
                            </td>
                        </tr> 
                            
                        </tr>
                       
                        <tr>
                            <td colspan="4">
                                &nbsp;
                            </td>
                        </tr>
                        </apex:repeat>
                    </table>
                    </apex:pageblocksection>
                    </apex:pageBlock>
                     
                     
                      <apex:pageBlock >
                       <apex:pageblocksection columns="1" title=" Product Details">
                            <table width="800px" height="1200px" >
                            <apex:variable value="{!1}" var="i"/>
                                <tr style="background-color:{!IF(mod(i,2)==0, ' #C0C0C0', '#C0C0C0')};">
                                    <th>Product Name</th>
                                    <th>Quantity</th>
                                    <th>Unit Price</th>
                                    <th>Total Price</th>
                                 </tr>
                                  <apex:variable value="{!i+1}" var="i" />
                                   <apex:variable value="{!1}" var="i"/>
                                <apex:repeat value="{!prodList }" var="prod">
                               <tr style="background-color:{!IF(mod(i,2)==0, ' #C0C0C0', '#C0C0C0')};">
                                        <td>{!prod.pricebookentry.product2.name}</td>
                                         <td> {!prod.quantity}</td>
                                            <td> {!prod.quantity}</td>
                                            <td> {!prod.TotalPrice}</td>
                                        </tr>
                                        <apex:variable value="{!i+1}" var="i" />
                                </apex:repeat>
                            </table>
                            </apex:pageblocksection>
                        </apex:pageBlock>
                        <style>
                
                </style>
                   </apex:form>
                   <apex:outputText >xyz</apex:outputText><br/><br/>
                   <apex:outputText value="order:" style="text-align:center; width : 100%;font-size: 16px; font-weight: bold ;  color :#000000"> </apex:outputText> <apex:outputText >Salsforce</apex:outputText><br/>
                 <apex:outputText > Visualforce</apex:outputText><br/>
                 <br/><apex:outputText style="text-align:left;font-weight: bold;" value="Best Regards,"></apex:outputText><br/>
                 <br/><div style="text-align:center;font-size: 15px;">
                            <apex:outputText style="text-align:center;font-weight:bold;"  value="Thank you"></apex:outputText></div>
                            <br/><br/><div style="text-align:center;font-size: 25px;">
                            <apex:outputText style="text-align:center;font-weight:bold;"  value="SALESFORCE"></apex:outputText></div>
                            
                   <p class="par">
                         
                            This is Opportunity page.
                            
                            </p>        
                            
                  </apex:page>

Controller:

public class testpportunity1{
 public List <Opportunity> oppList{get;set;}
  public List <OpportunityLineItem> prodList{get;set;} 
  public user cuser{get;set;}
  
   
public testpportunity1(ApexPages.StandardController controller) {
 oppList = new List <Opportunity>();
        oppList = [SELECT name, owner.name,Account.Name, stagename, amount,ExpectedRevenue,NextStep,LeadSource,Probability, CloseDate,Type,Stage_Management__c
                               FROM Opportunity
                               WHERE id = '789456123'];
    System.debug('opportunity list------->'+oppList);
    prodList =new List <OpportunityLineItem>();
     prodList = [SELECT PricebookEntry.Product2.Name, quantity, unitprice, totalprice
                                                    FROM OpportunityLineItem
                                                    WHERE OpportunityID='789456123'];
      cuser=[select id,Username,Signature__c from user where id=:UserInfo.getUserId()];
       System.debug('User list------->'+cuser);

    }
    
  }
added 6143 characters in body
Source Link
     <apex:page standardController="Opportunity" extensions="testpportunity1"   showHeader="false" sidebar="false"  docType="html-5.0" applyBodyTag="false" applyHtmlTag="false" renderAs="PDF">
/////Method 1//////////
         <html lang="en-us" dir="ltr">
            <head>
                <style>
                    @page {
                        @top-center {
                            content: "Opportunity PDF";
                            background: url('"{!$Resource.IconAjiIconSample}'");
                        }
                         @top-left {
                            background: url('"{!$Resource.IconAjiIconSample}'");
                        }
                        
                        @bottom-center {
                            content: "Page " counter(page) " of " counter(pages);
                        }
                    }
/////Method 1 ends//////////
/////Method 2 begins//////////
     div.header {
                    background: url("{!$Resource.IconSample}") ;
                    margin-top: 30px;
                    height: 130px;
                    width: 715px;
                    text-align: center;
                    position: running(header);
                }
    /////Method 2 ends//////////
    </style>
    
                </head>
                <body>
                </body>
              <div class="header"></div>   
         </html>
         
          <!--<apex:image url="{!$Resource.IconSample}"  width="220" height="150" />-->
        <br/>
         <apex:outputText style="text-align:left; width : 100%;font-size: 16px;" value="Address"></apex:outputText><br/>
         <apex:outputText style="text-align:left; width : 100%;font-size: 16px; " value="Street"></apex:outputText><br/>
          <apex:outputText style="text-align:left; width : 100%;font-size: 16px; " value="City"></apex:outputText><br/>
        
        <apex:form >
        <apex:pageBlock >
        <table>
                    <tr>
                    <td colspan="4">
                        &nbsp;
                    </td>
                    </tr>
                    <tr>
                    <td colspan="4">
                        &nbsp;
                    </td>
                    </tr>
                    </table>
                      <apex:pageblocksection columns="1" title=" Opportunity Information">
            <table width="100%" style="font-family: Arial, Helvetica, sans-serif;">
                  <apex:repeat value="{!oppList}" var="opp">
                <tr>
                   <tr>
                    <td align="right" style="color: #808080;">
                        OpportunityOwner
                    </td>
                    <td>
                        {!opp.Owner.Name}
                    </td>
                    <td align="right" style="color: #808080;">
                        OpportunityName
                    </td>
                    <td>
                        {!opp.Name}
                    </td>
                </tr>
                
                @bottom-center<tr>
                    <td align="right" style="color: #808080; ">
                        Account Name
                    </td>
                    <td>
                        {!opp.Account.Name}
                    content</td>
                    <td align="right" style="color: "Page#808080;">
 " counter(page) " of " counter(pages);                  Type
                    </td>
                    <td>
                         {!opp.Type}
                    </td>
                </tr>
                <tr>
                    <td align="right" style="color: #808080; ">
                        StageManagement
                    </td>
                    <td>
                         {!opp.Stage_Management__c}
             div       </td>
                    <td align="right" style="color: #808080; ">
                        Stage
                    </td>
                    <td>
                        {!opp.headerStageName}
                    </td>
                </tr>
                <tr>
                    <td align="right" style="color: #808080;  ">
                        CloseDate
                    </td>
                    <td>
                        {!opp.CloseDate}
                background    </td>
                    <td align="right" style="color: url("#808080;  ">
                        Probability
                    </td>
                    <td>
                        {!$Resourceopp.IconAjiProbability}") 
 no-repeat center center;                 </td>
                margin-top</tr> 
                    
                </tr>
               
                <tr>
                    <td colspan="4">
                        &nbsp;
                    </td>
                </tr>
                </apex:repeat>
 30px;           </table>
            </apex:pageblocksection>
      height      </apex:pageBlock>
 130px;            
              
    width          <apex:pageBlock 715px;>
               <apex:pageblocksection textcolumns="1" title=" Product Details">
                    <table width="800px" height="1200px" >
                    <apex:variable value="{!1}" var="i"/>
                        <tr style="background-aligncolor:{!IF(mod(i,2)==0, center;' #C0C0C0', '#C0C0C0')};">
                position            <th>Product Name</th>
                            <th>Quantity</th>
                            <th>Unit Price</th>
                            <th>Total Price</th>
                         </tr>
                          <apex:variable runningvalue="{!i+1}" var="i" />
                        <apex:repeat value="{!prodList }" var="prod">
                        <apex:variable value="{!1}" var="i"/>
                            <tr style="background-color:{!IF(headermod(i,2);==0, ' #C0C0C0', '#C0C0C0')};">
                                <td>{!prod.pricebookentry.product2.name}</td>
                                 <td> {!prod.quantity}</td>
                                    <td> {!prod.quantity}</td>
                                    <td> {!prod.TotalPrice}</td>
                                </tr>
                                <apex:variable value="{!i+1}" var="i" />
                        </apex:repeat>
                    </table>
                    </apex:pageblocksection>
                </apex:pageBlock>
                <style>
        
        </style>
           </head>apex:form>
        <body>   <apex:outputText >xyz</apex:outputText><br/><br/>
           <apex:outputText value="order:" style="text-align:center; width : 100%;font-size: 16px; font-weight: bold ;  color :#000000"> </body>apex:outputText> <apex:outputText >Salsforce</apex:outputText><br/>
         <div<apex:outputText class="header"><> Visualforce</apex:outputText><br/>
         <br/><apex:outputText style="text-align:left;font-weight: bold;" value="Best Regards,"></apex:outputText><br/>
         <br/><div style="text-align:center;font-size: 15px;">
                    <apex:outputText style="text-align:center;font-weight:bold;"  value="Thank you"></apex:outputText></div>
                    <br/><br/><div style="text-align:center;font-size: 25px;">
                    <apex:outputText style="text-align:center;font-weight:bold;"  value="SALESFORCE"></apex:outputText></div>
                    
           <p class="par">
                 
                    This is Opportunity page.
                    
                    </html>`p>        
                    
          </apex:page>
<apex:page standardController="Opportunity" showHeader="false" sidebar="false"  docType="html-5.0" applyBodyTag="false" applyHtmlTag="false" renderAs="PDF">
 <html lang="en-us" dir="ltr">
    <head>
        <style>
            @page {
                @top-center {
                    content: "Opportunity PDF";
                    background: url('{!$Resource.IconAji}');
                }
                 @top-left {
                    background: url('{!$Resource.IconAji}');
                }
                
                @bottom-center {
                    content: "Page " counter(page) " of " counter(pages);
                }
            }
             div.header {
                background: url("{!$Resource.IconAji}") no-repeat center center;
                margin-top: 30px;
                height: 130px;
                width: 715px;
                text-align: center;
                position: running(header);
            }
        </style>
        </head>
        <body>
        </body>
         <div class="header"></div>
 </html>`
     <apex:page standardController="Opportunity" extensions="testpportunity1"   showHeader="false" sidebar="false"  docType="html-5.0" applyBodyTag="false" applyHtmlTag="false" renderAs="PDF">
/////Method 1//////////
         <html lang="en-us" dir="ltr">
            <head>
                <style>
                    @page {
                        @top-center {
                            content: "Opportunity PDF";
                            background: url("{!$Resource.IconSample}");
                        }
                         @top-left {
                            background: url("{!$Resource.IconSample}");
                        }
                        
                        @bottom-center {
                            content: "Page " counter(page) " of " counter(pages);
                        }
                    }
/////Method 1 ends//////////
/////Method 2 begins//////////
     div.header {
                    background: url("{!$Resource.IconSample}") ;
                    margin-top: 30px;
                    height: 130px;
                    width: 715px;
                    text-align: center;
                    position: running(header);
                }
    /////Method 2 ends//////////
    </style>
    
                </head>
                <body>
                </body>
              <div class="header"></div>   
         </html>
         
          <!--<apex:image url="{!$Resource.IconSample}"  width="220" height="150" />-->
        <br/>
         <apex:outputText style="text-align:left; width : 100%;font-size: 16px;" value="Address"></apex:outputText><br/>
         <apex:outputText style="text-align:left; width : 100%;font-size: 16px; " value="Street"></apex:outputText><br/>
          <apex:outputText style="text-align:left; width : 100%;font-size: 16px; " value="City"></apex:outputText><br/>
        
        <apex:form >
        <apex:pageBlock >
        <table>
                    <tr>
                    <td colspan="4">
                        &nbsp;
                    </td>
                    </tr>
                    <tr>
                    <td colspan="4">
                        &nbsp;
                    </td>
                    </tr>
                    </table>
                      <apex:pageblocksection columns="1" title=" Opportunity Information">
            <table width="100%" style="font-family: Arial, Helvetica, sans-serif;">
                  <apex:repeat value="{!oppList}" var="opp">
                <tr>
                   <tr>
                    <td align="right" style="color: #808080;">
                        OpportunityOwner
                    </td>
                    <td>
                        {!opp.Owner.Name}
                    </td>
                    <td align="right" style="color: #808080;">
                        OpportunityName
                    </td>
                    <td>
                        {!opp.Name}
                    </td>
                </tr>
                
                <tr>
                    <td align="right" style="color: #808080; ">
                        Account Name
                    </td>
                    <td>
                        {!opp.Account.Name}
                    </td>
                    <td align="right" style="color: #808080;">
                        Type
                    </td>
                    <td>
                         {!opp.Type}
                    </td>
                </tr>
                <tr>
                    <td align="right" style="color: #808080; ">
                        StageManagement
                    </td>
                    <td>
                         {!opp.Stage_Management__c}
                    </td>
                    <td align="right" style="color: #808080; ">
                        Stage
                    </td>
                    <td>
                        {!opp.StageName}
                    </td>
                </tr>
                <tr>
                    <td align="right" style="color: #808080;  ">
                        CloseDate
                    </td>
                    <td>
                        {!opp.CloseDate}
                    </td>
                    <td align="right" style="color: #808080;  ">
                        Probability
                    </td>
                    <td>
                        {!opp.Probability} 
                    </td>
                </tr> 
                    
                </tr>
               
                <tr>
                    <td colspan="4">
                        &nbsp;
                    </td>
                </tr>
                </apex:repeat>
            </table>
            </apex:pageblocksection>
            </apex:pageBlock>
             
              
              <apex:pageBlock >
               <apex:pageblocksection columns="1" title=" Product Details">
                    <table width="800px" height="1200px" >
                    <apex:variable value="{!1}" var="i"/>
                        <tr style="background-color:{!IF(mod(i,2)==0, ' #C0C0C0', '#C0C0C0')};">
                            <th>Product Name</th>
                            <th>Quantity</th>
                            <th>Unit Price</th>
                            <th>Total Price</th>
                         </tr>
                          <apex:variable value="{!i+1}" var="i" />
                        <apex:repeat value="{!prodList }" var="prod">
                        <apex:variable value="{!1}" var="i"/>
                            <tr style="background-color:{!IF(mod(i,2)==0, ' #C0C0C0', '#C0C0C0')};">
                                <td>{!prod.pricebookentry.product2.name}</td>
                                 <td> {!prod.quantity}</td>
                                    <td> {!prod.quantity}</td>
                                    <td> {!prod.TotalPrice}</td>
                                </tr>
                                <apex:variable value="{!i+1}" var="i" />
                        </apex:repeat>
                    </table>
                    </apex:pageblocksection>
                </apex:pageBlock>
                <style>
        
        </style>
           </apex:form>
           <apex:outputText >xyz</apex:outputText><br/><br/>
           <apex:outputText value="order:" style="text-align:center; width : 100%;font-size: 16px; font-weight: bold ;  color :#000000"> </apex:outputText> <apex:outputText >Salsforce</apex:outputText><br/>
         <apex:outputText > Visualforce</apex:outputText><br/>
         <br/><apex:outputText style="text-align:left;font-weight: bold;" value="Best Regards,"></apex:outputText><br/>
         <br/><div style="text-align:center;font-size: 15px;">
                    <apex:outputText style="text-align:center;font-weight:bold;"  value="Thank you"></apex:outputText></div>
                    <br/><br/><div style="text-align:center;font-size: 25px;">
                    <apex:outputText style="text-align:center;font-weight:bold;"  value="SALESFORCE"></apex:outputText></div>
                    
           <p class="par">
                 
                    This is Opportunity page.
                    
                    </p>        
                    
          </apex:page>
Source Link

Header Image in Visualforce PDF not displayed

Image not getting displayed in PDF though I tried doing this.Can Anyone Please correct me what is wrong? I tried using it both in div.header and in @page.Both doesn't work fine?

<apex:page standardController="Opportunity" showHeader="false" sidebar="false"  docType="html-5.0" applyBodyTag="false" applyHtmlTag="false" renderAs="PDF">
 <html lang="en-us" dir="ltr">
    <head>
        <style>
            @page {
                @top-center {
                    content: "Opportunity PDF";
                    background: url('{!$Resource.IconAji}');
                }
                 @top-left {
                    background: url('{!$Resource.IconAji}');
                }
                
                @bottom-center {
                    content: "Page " counter(page) " of " counter(pages);
                }
            }
             div.header {
                background: url("{!$Resource.IconAji}") no-repeat center center;
                margin-top: 30px;
                height: 130px;
                width: 715px;
                text-align: center;
                position: running(header);
            }
        </style>
        </head>
        <body>
        </body>
         <div class="header"></div>
 </html>`