In Salesforce, we may come up with requirement where the data which was visible in visualforce pages need to be converted into PDF so that user can download that file. In such condition we have to render the Visualforce page as PDF. Here i am telling you how to achieve this functionality.
As we all know that the parent tag of a visualforce page is apex:page which binds the visualforce page with your controller. In apex:page we have a parameter renderAs and if you initialize this parameter as pdf then the visualforce page will render as PDF file.
Code for making VF Page render as PDF :
<apex:page standardController="Product2" renderAs="pdf" > </apex:page>
Note : I recommend you to use html tags instead of visualforce tags when you are rendering as PDF.
Leave a Reply