function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vivek singh08481200707119766vivek singh08481200707119766 

Hi i have a class and have a pdf how to make pdf value in the class

public class insertionOrderPdf {
public String OppId;
public String OpportunityNumber{get;set;}
Public boolean site{get;set;}
Public integer discount{get;set;}
public String SiteType{get;set;}
Public List<OpportunityLineItem> lstOpplineItem{get;set;}
Public Opportunity PrimaryOpp{get;set;}
public insertionOrderPdf()
    {
        OppId           = Apexpages.currentPage().getParameters().get('OppId');
        SiteType        = Apexpages.currentPage().getParameters().get('SiteType');
       
        if(OppId != Null && SiteType!= Null)
        {
                PrimaryOpp              =       new Opportunity();
                lstOpplineItem  =       new List<OpportunityLineItem>();
                lstOpplineItem  =   [
                                                        select
                                                        Opportunity.Billing_Notes__c,
                                                        Opportunity.Billing_Terms__c,
                                                        Opportunity.Name,
                                                        Opportunity.Client_PO_Number__c,
                                                        Opportunity.Activity_Start_Date__c,
                                                        Opportunity.Activity_End_Date__c,
                                                        Opportunity.Description,
                                                        Opportunity.Account.Name,
                                                        Opportunity.Account.billingPostalcode,
                                                        Opportunity.Account.Billing_Email__c,
                                                        Opportunity.Account.BillingStreet,
                                                        Opportunity.Account.BillingCity,
                                                        Opportunity.Account.BillingCountry,
                                                        Opportunity.Account.BillingState,
                                                        Opportunity.Buyer__r.Name,
                                                        Opportunity.Buyer__r.Email,
                                                        Opportunity.Buyer__r.Phone,
                                                        Opportunity.Buyer__r.Title,
                                                        Opportunity.Vendor__r.name,
                                                        Opportunity.Success_metrics__c,
                                                        Opportunity.Agency_Discount_Percentage__c,
                                                        Opportunity.Order_Notes__c,
                                                        PricebookEntry.Product2.Name,
                                                        Opportunity.Opp_Number__c,
                                                        Description,
                                                        Start_Date__c,
                                                        End_Date__c,
                                                        Geo_Target__c,
                                                        Quantity,
                                                        ListPrice,
                                                        Gross__c,
                                                        UnitPrice,
                                                        TotalPrice,    
                                                        Site__c
                                                        from    OpportunityLineItem
                                                        where OpportunityId =:OppId
                                                        and      Site__c =:SiteType
                                                        ];
                                                       
                if(lstOpplineItem.size() > 0)
                {
                        if(lstOpplineItem[0].site__c.tolowercase() == 'inform')
                        {
                            Site = true;
                        }
                        PrimaryOpp = lstOpplineItem[0].Opportunity;
                        if(PrimaryOpp.Opp_Number__c!= null)
                        {
                            if(PrimaryOpp.Opp_Number__c.contains('-'))
                            {
                             String[] s = new String[]{};
                             s = PrimaryOpp.Opp_Number__c.split('-');
                             OpportunityNumber = s[1];
                            }
                        } 
                                            
                        if(PrimaryOpp.Agency_Discount_Percentage__c == '10%')
                        {
                            discount = 10;
                        }else if(PrimaryOpp.Agency_Discount_Percentage__c == '15%')
                        {
                            discount = 15;
                        }
                        else if(PrimaryOpp.Agency_Discount_Percentage__c == '20%')
                        {
                            discount = 20;
                        }
                        else
                        {
                            discount = 0;
                        }
                }
        }
    }

}
Shashank SrivatsavayaShashank Srivatsavaya
Hi,

You can user renderAs="pdf" attribute in the apex:page component in your visualforce page to render a page as PDF.

Thanks,
Shashank 
ShashForceShashForce
Hi,

You can user renderAs="pdf" attribute in the apex:page component in your visualforce page to render a page as PDF.

Thanks,
Shashank