+ Start a Discussion
Sankar Landa 15Sankar Landa 15 

I want to get output vf page as pdf when i click a button.can any one explain me how can i do this

Harish RamachandruniHarish Ramachandruni

Do u want in same page or another page .

Sankar Landa 15Sankar Landa 15
Hi Harish,
      I have pdf button in first vf  output page and I want the same to be displayed in pdf by clicking the button in first page
Harish RamachandruniHarish Ramachandruni
Hi ,

Use Same Controller for to vf pages And Add which Data U required in pdf page In page tag add Render As pdf tag . In side Button Write Page instance .

<apex:page   controllere = "harishrao" sidebar="false" >


:apex:commoundbutton value= "show" action = "{!show}" />



2 page 

<apex:page renderAs="pdf" showHeader="false"   controllere = "harishrao" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false">
02    <html>
03    <head>
04        <style>
05            @page {
06                size: letter;
07                margin: 25mm;
08                @top-center {
09                    content: "Sample";
10                }
11                @bottom-center {
12                    content: "Page " counter(page) " of " counter(pages);
13                }
14            }
15            .page-break {
16                display:block;
17                page-break-after:always;
18            }
19            body {
20                font-family: Arial Unicode MS;
21            }
22        </style>
23    </head>
24    <body>
25    <div class="page-break">Page A</div>
26    <div class="page-break">Page B</div>
27    <div>Page C</div>
28    </body>
29   </html>

Harish RamachandruniHarish Ramachandruni

Did you resolve probleam .

Ajay mishraAjay mishra
<apex:page renderAs="pdf">
Using above attribute inside the Page Tag(<apex:Page>) of your VF Page.

Ajay Mishra
jakin prajapatijakin prajapati
Hi Sankar,

Please try to follow below concept.

VfPage - Page1
<apex:page renderAs="pdf" >
            set output that you wan't in pdf

VfPage - page2
<apex:page >
            <apex:commandButton action="/apex/page1" />

Thanks & Cheers !!
Prashant Pandey07Prashant Pandey07
you can get without any code if you can use appexchange product as below

Please use renderAs attribute like this -
<apex:page renderAs="pdf">
Currently PDF is the only supported content converter. Setting this attribute to "pdf" renders the page as a PDF.
If the PDF fails to display all the characters, adjust the fonts in your CSS to use a font that supports your needs.
For example, add the following style definition to your page's styles:
body { font-family: 'Arial Unicode MS'; }
This is my first answer here.So please correct me if am wrong somewhere :)

Thanks and Regards,
Samir Khan
sandeep reddy 37sandeep reddy 37
use this coad
controller class
public class vfpagetopdfformate {
    public boolean pdfpage {set;get;}
    public string render{set;get;}
    public void pdfpage(){
and vf page is 
<apex:page renderAs="{!render}" id="rer" controller="vfpagetopdfformate" >
        the transforming vf page to pdf formate 
  <apex:commandButton value="convertopdf" action="{!pdfpage}" />
  I Hope this is help full for u if you are problem is solved make this is best answer