+ Start a Discussion
Sindhu AmbarkarSindhu Ambarkar 

How to download pdf page automatically using render as pdf

Hi,

I want to download the pdf automatically using render as pdf i tried using contenttype attribute.Its throwing error

Thanks & Regards,
Sindhu Ambarkar.
Tarun_KhandelwalTarun_Khandelwal
Hi Sindhu,

renderAs="pdf" authomatically download your pdf. If you are using Google chorme browser, it will open pdf. But if using Firefox browser, hitting URL will automatically download page.

Thanks
Sindhu AmbarkarSindhu Ambarkar
Hi Tarun,

If i want to download in chrome browser then what needs to be done.

Thanks & regards,
Sindhu Ambarkar.
 
Tarun_KhandelwalTarun_Khandelwal
No, There is no way. Because chorme has ability to open pdf. It's not related to salesforce. Its related to browser. If there is any way, so that chrome stops opening pdf, then use this. Else in chorme, open pdf and use Ctrl + S option. :)

Thanks.
Sindhu AmbarkarSindhu Ambarkar
Thanks Tarun.
I have used 
<body style="border:1px solid black;  bgcolor:green; font-family: Italic; font-size: 20px;">
                Testpage
</body>
But background color is getting reflected.

Thanks & regards,
Sindhu Ambarkar.
Brandon Chang 9Brandon Chang 9
You can achieve this with two files. 

1) RenderPDF.vfp
<apex:page showHeader="false" applyBodyTag="false" renderAs="PDF" standardController="Lead">
    Hello PDF
</apex:page>

2) ExportToPDF.vfp
<!--Override to ALWAYS download -->
<apex:page contentType="application/vnd.ms-pdf#output.pdf">   
    <apex:include pageName="RenderPDF"/>        
</apex:page>

One page renders the PDF, the other one includes and downloads.