0

I know we can use the renderAs property to get whole vf pages as a pdf but I don't want that. I want particular tags in my pdf. I need a 'view/print pdf' button which opens the pdf in a new tab. I can use javascript or apex without any restrictions. Here is a little bit of code and screenshots for reference:

 <div class="slds-form-element" id="div1">
     <div class="slds-grid slds-gutters_small">  
          <div class="slds-col slds-has-flexi-truncate" role="listitem">
              <div class="slds-form-element slds-form-element_edit slds-hint-parent">
                   <span class="slds-form-element__label"><b>{!$ObjectType['Credit_Applicant__c'].fields['Federal_Tax_ID__c'].Label}&nbsp;:</b></span>
                        <div class="slds-form-element__control">
                             <span class="slds-form-element__static slds-border_bottom">{!creditApplicantRecord.Federal_Tax_ID__c}</span>
                                        </div>
                                    </div>
                                </div>
                    <div class="slds-col slds-has-flexi-truncate" role="listitem">
                         <div class="slds-form-element slds-form-element_edit slds-hint-parent">
                                  <span class="slds-form-element__label"><b>{!$ObjectType['Credit_Applicant__c'].fields['DUNS_Number__c'].Label}&nbsp;:</b></span>
                                        <div class="slds-form-element__control">
                                            <span class="slds-form-element__static slds-border_bottom">{!creditApplicantRecord.DUNS_Number__c}</span>
                                        </div>
                                    </div>
                                </div>

enter image description here This is the footer with the print button that should open a pdf in a new tab

0

What you need is to create a controller, and inside controller you can create dynamic apex tags (or reRender some portion of the page with new added elements) and then use following getContentAsPDF method in your controller method called via render PDF button.

getContentAsPDF

Returns the page in PDF, regardless of the apex:page component’s renderAs attribute.

  • Can yoou explain it with some code? I got the basic idea but it would help me a lot if you could elaborate it a bit more – vedant gupta Jan 8 at 10:37

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.