+ Start a Discussion
Amita TatarAmita Tatar 

create pdf of standard detail page

Hi ,

I want to generate a pdf of standard detail page for order object. How to do it? Please help

Naresh YadavNaresh Yadav
Hi Amita 

You need to add a button on the detail page. From that button you need to pass id of that record and then query that record in your custom controller. 
On that button click you need to open your custom page.

Mark it as solution if it helps you out.
Amita TatarAmita Tatar
Hi Naresh. 

This is my Apex class
Public with sharing class RerenderPDF
public order order{get;set;}
public Id getId{get;set;}

private ApexPages.StandardController stdCtrl;
public rerenderPDF(ApexPages.StandardController std)
 order = new order();
 getId = ApexPages.currentPage().getParameters().get('id');
 system.debug('***********************************getId ***********'+getId);
 order = [SELECT AccountId,OrderNumber ,RecordTypeId , Type,Asset__c,Order_Reason__c,Case__c,PoDate,PoNumber,EffectiveDate,Status FROM Order where id =:getId ];


VF Page
<apex:page standardController="Order" extensions="RerenderPDF" renderAs="PDF">
<apex:form >

<apex:pageblock >
<apex:pageBlockSection title="Order Information">
<apex:inputField value="{!order.RecordTypeId}"/>
<apex:inputField value="{!order.AccountId}"/>
<apex:inputField value="{!order.OrderNumber}"/>
<apex:inputField value="{!order.PoDate}"/>
<apex:inputField value="{!order.PoNumber}"/>
<apex:inputField value="{!order.Type}"/>
<apex:inputField value="{!order.Order_Reason__c}"/>
<apex:inputField value="{!order.Asset__c}"/>
<apex:inputField value="{!order.EffectiveDate}"/>
<apex:inputField value="{!order.Status }"/>



Please check. The format of pdf is not rendered correctly
Naresh YadavNaresh Yadav

You cannot use input field or input in the PDF.
You can only show the output of that record. And you need to style your PDF by adding custom CSS in the PDF page.
Amita TatarAmita Tatar
Hi Naresh,

Yes, i have done that change. Thank you. I will apply the Style .
Naresh YadavNaresh Yadav
mark it as solution. If it helps you out