+ Start a Discussion
Supriyo Ghosh 5Supriyo Ghosh 5 

Unable to generate pdf report

Hi,

I am trying download a vf page as pdf by button click.But unable to get the report.Please help.

Controller

public class EmpMasterReport
{
   public Transient Date datename{set;get;}  
   public List<Employee_Master__c> EmpList {get;set;}
   
    public EmpMasterReport(ApexPages.StandardController stdController) 
    {
        EmpList = new     List<Employee_Master__c>();
        EmpList = [ SELECT Name,Address__c,Date_Of_Birth__c,Date_Of_Joining__c,Date_of_Leaving__c,Thumbnail__c FROM Employee_Master__c where Active__c=true and Photo__c !=null];
    }
    
    public EmpMasterReport()
    {
        EmpList = new     List<Employee_Master__c>();
        EmpList = [ SELECT Name,Address__c,Date_Of_Birth__c,Date_Of_Joining__c,Date_of_Leaving__c,Thumbnail__c FROM Employee_Master__c where Active__c=true and Photo__c !=null];
    }
    
    Public pageReference exportReport()
    {
        pageReference newPage;
        String Br='EmpMasterReport';
        if(datename==null)
        {
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.INFO,'Please select the Date');
            ApexPages.addMessage(myMsg);
            
        }else
        {
            newPage = new pageReference('/apex/EmpMaster_Report');
            Blob pdfpageblob;
            pdfpageblob = newpage.getcontentAsPdf();
            
             insert Blob;
        }
        
        return newPage ;
    }
   
}

Please help.
venkat-Dvenkat-D
in the visual force page irself do renderas="pdf" and redirect to that page