You need to sign in to do that
Don't have an account?
Bhargav krishna 1
How to create a custom PDF page
Hi everyone,
How to create a custom vfpage as PDF page. I have the component reanderedAS="PDF", but i was to see the field values in the genenrated PDF. Can anyone help me over here.
Regards,
Bhargav.
How to create a custom vfpage as PDF page. I have the component reanderedAS="PDF", but i was to see the field values in the genenrated PDF. Can anyone help me over here.
Regards,
Bhargav.
<head> <style type="text/css"> body { font-family: Arial Unicode MS; } </style> </head> <h1>Account Information</h1> <apex:panelGrid columns="2" border="1" cellspacing="0" cellPadding="5" width="100%">
<apex:outputText value="{!$ObjectType.Account.fields.Name.label}" />
<apex:outputText value="{!Account.Name}" />
<apex:outputText value="{!$ObjectType.Account.fields.AccountNumber.label}" />
<apex:outputText value="{!Account.AccountNumber}" />
<apex:outputText value="{!$ObjectType.Account.fields.WebSite.label}" />
<apex:outputText value="{!Account.WebSite}" /> <apex:outputText value="…" />
<apex:outputText value="…" />
</apex:panelGrid>
</apex:page>
controller--
public class AccountPDFController
{
public AccountPDFController(ApexPages.StandardController controller)
{
Account acc = (Account)controller.getRecord();
String accNum = acc.AccountNumber;
//Assign "Account_[Ac].pdf" as a file name
String fileName = 'Account_' + accNum + '.pdf'; Apexpages.currentPage().getHeaders().put('content-disposition', 'attachment; filename=' + fileName);
} }
All Answers
<head> <style type="text/css"> body { font-family: Arial Unicode MS; } </style> </head> <h1>Account Information</h1> <apex:panelGrid columns="2" border="1" cellspacing="0" cellPadding="5" width="100%">
<apex:outputText value="{!$ObjectType.Account.fields.Name.label}" />
<apex:outputText value="{!Account.Name}" />
<apex:outputText value="{!$ObjectType.Account.fields.AccountNumber.label}" />
<apex:outputText value="{!Account.AccountNumber}" />
<apex:outputText value="{!$ObjectType.Account.fields.WebSite.label}" />
<apex:outputText value="{!Account.WebSite}" /> <apex:outputText value="…" />
<apex:outputText value="…" />
</apex:panelGrid>
</apex:page>
controller--
public class AccountPDFController
{
public AccountPDFController(ApexPages.StandardController controller)
{
Account acc = (Account)controller.getRecord();
String accNum = acc.AccountNumber;
//Assign "Account_[Ac].pdf" as a file name
String fileName = 'Account_' + accNum + '.pdf'; Apexpages.currentPage().getHeaders().put('content-disposition', 'attachment; filename=' + fileName);
} }