+ Start a Discussion
Itayb34Itayb34 

Save and Email PDF

Hello

 

I created a visualforce page create a PDF of Invoice and Invoice Line Items (Similar to the standard Quote functionality)

I would like to enhance it and be able to add "Save PDF" and "Email PDF" buttons into the PDF screen. I know it's possible via iframe, but I'm not sure what to do there...

 

Generate PDF:

 

<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.CompanyLogo)}' 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>

 

Any help will be great

 

Itay