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
Amit  TrivediAmit Trivedi 

How to display attached pdf on visualforce page when we are rendering vf page as pdf ?

Hello expert,

I am displaying all attachment on vf page, vf page set as render as pdf. It is displaying all 
the attachment if attachment is image but it doesn't displaying attached pdf. I am using iframe
for showing pdf but it is not working with render as pdf.

Please provide some solution. Thanks in advanced.
srlawr uksrlawr uk
yes, this is what I'd expect. an iFrame is like a "window" to another webpage, and the renderAs="PDF" (or however you choose to invoke it) simply renders the markup on the page that it is - so it will be trying to turn the iFrame tag into a part of the PDF, but it will have zero concept of what is actually going to be invoked in that iFrame... sadly it's not like taking a screenshot of what you see to generate the PDF, it is actually parsing the code on the page.

I don't know exactly the best way to approach this then, if you have PDFs you want to include on a page that you then render as PDF...  I'm not sure it's going to be easily possible.. could you "include" the markup that made the original PDFs in the new page, before you render it as a PDF?
Mitesh SuraMitesh Sura
Hi Amit,

Any luck with showing the PDF inside VF page rendered as PDF? I am in same boat and not finding good solution for this. Apprecaite your time.

Nikhil ArpallyNikhil Arpally
Hi Amit,
Any luck with showing the PDF in VF page which is rendered as PDF? I am not able to find a solution for this.

Suraj Tripathi 47Suraj Tripathi 47
Hi Amit,
please see the below code it will help you to render vf page as pdf.
<apex:page controller="PdfExampleController" renderAs="{!VFtype}">
  <apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!accList}" var="acc" border="2">
           <apex:column value="{!}"/>
           <apex:column value="{!acc.annualrevenue}"/>
           <apex:column value="{!acc.type}"/>
           <apex:column value="{!acc.accountnumber}"/>
           <apex:column value="{!acc.rating}"/>
      <apex:commandButton onclick="save()" value="Download pdf" id="theButton"/>

public with sharing class PdfExampleController {
    public String VFtype {get;set;}
    public List<Account> accList{get;set;}
    public PdfExampleController(){
        accList = [select id,name,type,accountnumber,annualrevenue,Rating from account limit 10];
   public PageReference save() {
        VFtype = 'pdf';
        return null;

If you find your Solution then mark this as the best answer.

Thank you!
Suraj Tripathi