1

I would like to create a functionality similar to the "Preview PDF" on Quotes, only on custom object (Invoice). I created a visualforce page that generates a PDF (see below), but I want to create a "Parent" visualforce page so I will be able to add custom buttons ("save to attachments" and "Email").

How can I achieve that?

    <apex:page standardController="Invoice1__c" showHeader="false" renderas="pdf"> 


<table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
<tr>
    <td>
        <img src='{!URLFOR($Resource.Logo)}' title="logo" />
    </td>
   <td  align="right"><font face="Arial" >
    <b>Invoice for {!Invoice1__c.Opportunity__r.Account.Name}</b></font><br/>
   </td> 


</tr>

<hr/>

</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%" id="table1">
<tr>    <td><font face="Arial" >
        {!$Organization.Name}<br/>
        {!$Organization.Street}<br/>
        {!$Organization.PostalCode} {!$Organization.City}<br/>
        {!$Organization.Country}<br/>
        </font></td> 
        <td width="60%">&nbsp;</td>
   <td ><font face="Arial">Invoice number: "{!Invoice1__c.Name}" </font><br/>


   <font face="Arial">Invoice Date: "{!Invoice1__c.Invoice_Date__c}" </font>  
   </td>    

</tr>
</table>
<br/>
<hr/>
<p><b><font face="Arial" color="#000080">Address Information</font></b></p>

<table border="0" width="100%" id="table2">
<tr>
       <td colspan="3">
           <font face="Arial">Account name: {!Invoice1__c.Opportunity__r.Account.Name} <br/><br/></font>
       </td>
</tr>
  <tr>
      <td>          
           <font face="Arial">Bill To:<br/>
                             {!Invoice1__c.Opportunity__r.Account.BillingStreet}<br/>
                             {!Invoice1__c.Opportunity__r.Account.BillingPostalCode} {!Invoice1__c.Opportunity__r.Account.BillingCity}
           </font>
        </td>
        <td width="50%"></td>
        <td >
           <font face="Arial">Ship To:<br/>
                              {!Invoice1__c.Opportunity__r.Account.ShippingStreet}<br/>
                              {!Invoice1__c.Opportunity__r.Account.ShippingPostalCode} {!Invoice1__c.Opportunity__r.Account.ShippingCity}
           </font>
        </td>
</tr>    
</table>  
<br/>
<hr/>
<p><b><font color="#000080" face="Arial">Products</font></b></p>
<table border="0" width="100%" id="table4">
<tr>
       <td bgcolor="#C0C0C0"><font face="Arial">Product</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Quantity</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Unit Price</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Discount</font></td>
       <td bgcolor="#C0C0C0"><font face="Arial">Total Price</font></td>
</tr>
<tr>
       <apex:repeat value="{!Invoice1__c.Invoice_Line_Items__r}" var="line">
          <tr>
             <td>{!line.Product_Name__c}</td>
             <td>{!line.Quantity__c}</td>
             <td><apex:OutputField value="{!line.Unit_Price__c}"/></td>
             <td><apex:OutputField value="{!line.Discount__c}"/></td>
             <td><apex:OutputField value="{!line.Total_Price__c}"/></td>
          </tr>
       </apex:repeat>  
</tr>
<tr>
       <td bgcolor="#C0C0C0" align="right" colspan="6">
       <font face="Arial"><b>Total:</b>&nbsp;<apex:OutputField value="{!Invoice1__c.Opportunity__r.Amount}"/></font></td>
</tr>
</table>
<br/>
<hr/>
<p><b><font color="#000080" face="Arial">Terms and Conditions</font></b></p>
<table border="0" width="100%" id="table3">
<tr>


        <td><font face="Arial">
          Payment Method:&nbsp;<apex:OutputField value="{!Invoice1__c.Opportunity__r.QuotePaymentMode__c}"/><br/> 
          Payment Terms:&nbsp; <apex:OutputField value="{!Invoice1__c.Opportunity__r.QuotePaymentTime__c}"/><br/> 
            </font>
       </td>
</tr>
</table>
<br/>

<br/>
<hr/>
<table width="100%" id="table5">
Special Terms:
</table>
<p>&nbsp;</p>
<hr/>
<p align="center"><font face="Arial"><i>Copyright {!$Organization.Name}.</i></font></p> 
</apex:page>

2 Answers 2

3

You can include another visualforce page in your parent visualforce page by using the include tag :

<apex:include pageName="Your Child Page Name"/>
2

<apex:include> tag? Or you could convert your preview code into a reusable component so it can be also used in Visualforce email templates for example.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .