Is it possible to render a VF page as a PDF inside the same page in specific section ?
for example I have page with the following hierarchy, And the PDF will display in the second pageblock, is there iframe or something can use ? or using VF components ? or including VF page ?
<apex:page> <apex:pageBlock title="Select Account"> // here the select options for available accounts. </apex:pageBlock> <apex:pageBlock title="Account Information"> // reRenderAs PDF here with account info, according to the selected Account. </apex:pageBlock> </apex:page>
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I just tested this and it’s some what possible, but very limited. It will involve you separating the components you want to render to different visualforce pages. The code is shown below, but please keep in mind, this is very limited. For example, if you are running any sort of logic after your constructor, rerender, etc, it will not display the changes. This will only display what ever is done at the time your page loads / constructor runs.
Apex VF page Test1:
<apex:page standardController="Account" > <apex:detail relatedList="false" title="false"/> <iframe src="/apex/Test2?id={!Account.Id}" height="800px" width="800px"/> </apex:page>
Apex VF page Test2:
<apex:page standardController="Account" renderAs="pdf" > <apex:pageBlock> <apex:pageBlockSection> <apex:outputField value="{!Account.Name}" /> </apex:pageBlockSection> </apex:pageBlock> </apex:page>
Method 2
It work only with :
If we used
<
apex:pageBlock> and <apex:pagesection> It will not show desired output.The entire page load as pdf and content of two pages will show in pdf format. <iframe src="/apex/Test2?id={!Account.Id}" height="800px" width="800px"/>
just pass the id of any account on URL
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0