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
Pawan Kumar 32Pawan Kumar 32 

How to dispaly content of PDF on VF page.

Hi All,

I  want to display content of PDF on vf page. I have stored PDF in Notes & Attachments related list of account object. My requirement is I want to show footer message on Vf Page. Then after I want to show all content of Vf page in PDF(renderAs ="PDF") Here in the below code I am using iframe. But it is not working. It is showing blank. Please help.
<apex:page controller="ViewPdf" renderAs="PDF">
    <iframe src="data:{!att.ContentType};base64,{!pdf}" >
    <div class="footer">
        <div>This document is internal use only</div>
     </div>
    </iframe>
</apex:page>
public class ViewPdf {
    public Attachment att {
        get {
            if (att == null) {
                att = [SELECT Body, ContentType, Name FROM Attachment WHERE ID = '00P280000018FlA'];
            }
            return att;
        }
        private set;
    }
    public String pdf {
        get {
            return EncodingUtil.Base64Encode(att.body);
        }
    }
}


 
Pawan Kumar 32Pawan Kumar 32
But here my requirement is different. I want to show all contents od attached pdf and div contents on new PDF. see below code: It is not working
<apex:page controller="ViewPdf" renderAs="PDF" >
   <apex:iframe src="/servlet/servlet.FileDownload?file={!att.Id}"/>
    <div class="footer">
        <div>This document is internal use only</div>
     </div>
</apex:page>

 
AnjithKumarAnjithKumar
Hello Pawan,

Sorry , Missed the actual requirement. 
Bharath Kumar ThotaBharath Kumar Thota
Hi Pawan,
Try this link:
https://help.salesforce.com/articleView?id=000328622&type=1&mode=1 (https://help.salesforce.com/articleView?id=000328622&type=1&mode=1)

Thanks,
Bharath Kumar Thota