Salesforce随笔: 将Visualforce Page渲染为PDF文件(Render a Visualforce Page as a PDF File)

参照 : Visualforce Developer Guide 第60页 <Render a Visualforce Page as a PDF File>

你可以用PDF渲染服务生成一个可以下载或者打印为PDF 文件的 Visualforce Page.

通过更改<apex:page>标签属性将页面转换为PDF。

1 <apex:page renderAs="pdf">

已经被渲染为PDF文件的VF Page,是被显示在浏览器页面中还是被下载成为文件,这个行为取决于浏览器设置,不受Visualforce控制.

下记是包含Account情报且渲染为PDF文件的页面代码:

 1 <apex:page standardController="Account" renderAs="pdf">
 2 <apex:stylesheet value="{!URLFOR($Resource.Styles,'pdf.css')}"/>
 3 <h1>Welcome to Universal Samples!</h1>
 4 <p>Thank you, <b><apex:outputText value=" {!Account.Name}"/></b>, for
 5 becoming a new account with Universal Samples.</p>
 6 <p>Your account details are:</p>
 7 <table>
 8 <tr><th>Account Name</th>
 9 <td><apex:outputText value="{!Account.Name}"/></td>
10 </tr>
11 <tr><th>Account Rep</th>
12 <td><apex:outputText value="{!Account.Owner.Name}"/></td>
13 </tr>
14 <tr><th>Customer Since</th>
15 <td><apex:outputText value="{0,date,long}">
16 <apex:param value="{!Account.CreatedDate}"/>
17 </apex:outputText></td>
18 </tr>
19 </table>
20 </apex:page>
例2

A Visualforce Page Rendered as a PDF File

原文地址:https://www.cnblogs.com/qiaosx/p/10330241.html