+ 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
Hi,

Do u want in same page or another page .


Regards,
Harish.R
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:form>

<apex:page:block>

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

<apex:page:block>


</apex:form>
</apex:page>



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>
30</apex:page>



Regards,
Harish.R.
Harish RamachandruniHarish Ramachandruni
Hi,

Did you resolve probleam .

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

Regards,
Ajay Mishra
jakin prajapatijakin prajapati
Hi Sankar,

Please try to follow below concept.

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

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


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

https://appexchange.salesforce.com/listingDetail?listingId=a0N300000016Zn3EAE
 
SamirKhanSamirKhan
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(){
        if(render==null){
            render='pdf';
    }
    
}
}
and vf page is 
<apex:page renderAs="{!render}" id="rer" controller="vfpagetopdfformate" >
    <apex:form>
        the transforming vf page to pdf formate 
  <apex:commandButton value="convertopdf" action="{!pdfpage}" />
    </apex:form>
</apex:page>
  I Hope this is help full for u if you are problem is solved make this is best answer
thanks 
sandeep