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
Nihar SharmaNihar Sharma 

How to insert visualforce pdf page to quote document ?

Hey folks,

I am generating pdf using visualforce page which is renderAs = 'PDF' and i have conditional pageblocktable are available in this pdf.

How can i insert this visualforce pdf in quote document ? However, i tried the following code but i am not able to save it conditional base.
 
public PageReference SaveQuoteDocument() {
                
        PageReference thePDF =  Page.PDFrecordPage;
        thePDF.getParameters().put('id',(String)this.Quote.Id);
        thePDF.setRedirect(true);


        if(!test.isrunningtest()){
            quotedocument qd = new quotedocument();
            qd.document = thePDF.getContentasPDF();
            qd.quoteId = this.Quote.Id;
            insert qd;
        }
        PageReference quotePage = new PageReference('/apex/DetailPage?id='+ this.Quote.Id);
        quotePage.setRedirect(true);
        return quotePage;
}

Can anyone please help me out !!
AvaneeshAvaneesh
Hi Nihar Sharma,

first I want to see your visualforce page and Let me tell you pageblocktable will not work when you renderas='pdf' so in these conditions you have to use html tags <table>

see this link will help you. 
https://salesforce.stackexchange.com/questions/123441/pageblocktable-to-be-rendered-as-table-in-pdf


Thank you 
Avaneesh Singh
 
Nihar SharmaNihar Sharma
Hi Avaneesh,

Thanks for reply, please see below visualforce code which is rendered conditional.
 
<apex:repeat value="{!PT.PBEList}" var="PBE" rendered="{!IF(AND(PT.TempProductSelection.Quantity__c == 0, $CurrentPage.parameters.removeitem == 'true'),false, true)}">
	<tr style="{!IF(PBE.Part_Number__c == NULL, 'display:none', '')}">                                                        
		<td style="text-align:left;width:15%;">{!PBE.Part_Number__c}</td>
		<td style="text-align:left;width:35%;">
			<apex:outputField value="{!PT.TempProductSelection.Product__r.name}" rendered="{!Quote.Quotation_PDF_in__c != 'Spanish'}"/>
			<apex:outputField value="{!PT.TempProductSelection.Product__r.Spanish_Product_Name__c}" rendered="{!Quote.Quotation_PDF_in__c == 'Spanish'}"/>    
			<br/>
			<apex:outputField value="{!PT.TempProductSelection.Description__c}" rendered="{!IF(AND(PT.TempProductSelection.Description__c != '', Quote.Quotation_PDF_in__c != 'Spanish'), true, false)}" />
			<apex:outputField value="{!PT.TempProductSelection.Product__r.Spanish_Product_Description__c}" rendered="{!IF(AND(PT.TempProductSelection.Product__r.Spanish_Product_Description__c != '', Quote.Quotation_PDF_in__c == 'Spanish'), true, false)}" />
		</td>
		<td style="width:10%;">{!PT.TempProductSelection.Quantity__c}</td>
		<td style="text-align:right;width:10%; {!IF(($CurrentPage.parameters.removepricing == 'true'), 'display:none;', '')}">
			<apex:outputText rendered="{!userLocale != 'de_DE'}" value="{0, number, ###,##0.00}">
				<apex:param value="{!PT.TempProductSelection.Unit_Price__c}"/>
			</apex:outputText>
		</td>
		<td style="{!IF(($CurrentPage.parameters.includediscount == 'true'),'','display:none')} ;width:10%;">{!PT.TempProductSelection.Discount__c}%</td>
		<td style="text-align:right;width:12%; {!IF(($CurrentPage.parameters.removepricing == 'true'), 'display:none;', '')}">                                          
			<apex:outputText rendered="{!userLocale != 'de_DE'}" value="{0, number, ###,##0.00}">
				<apex:param value="{!PT.TempProductSelection.Extended_Price__c}"/>
			</apex:outputText>
		</td>
	</tr>
</apex:repeat>

 
Nihar SharmaNihar Sharma
Avaneesh,

I did not used pageblocktable in my pdf