+ Start a Discussion

How do i override the renderas tag?

Hi I have a visual force page with a ton of logics on it with code behind.

I have been asked to add a button that takes the second phase of the page and saves it as pdf.


now i know theres the renderas="pdf" tag, however i need to be able to call it from a button... meaning this scenario:


A. User comes in to the page does a few things and clicks next.

B. The results are displayed.

C. He clicks on a new button that i create, and he expects to see the same results only in pdf...


any idea of how to do it ? i basiclly want when the user clicks on the button to take the currents page state (after i have run all the logics to get the results) and make it a pdf...


its important to say there are a lot of logics and i cant simply redirect him to another page with the results because there is too much logic to be copied to a new page just for the pdf..



Thanks in advance!


I usually move the entire contents of the page into a component, ending up with a page containing just this component, and then create a second version of the page that is rendered as PDF.  That way the logic appears in a single place.


I think you can use renderas = "{!fun}" and on click of the button you can call that function and which returns the value as Pdf