function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

On button click Generate PDF with field values

Hi All,
On click of "Generate PDF" button,I have to show VF Page in PDF format with renderAs attribute.
I am able to render VF Page in PDF format but field values are not added in pdf.How to achieve this?
Please help!!!!

VF Page:
<apex:page controller="VendorRegister" tabStyle="Vendor__c" renderAs="PDF" >
    <!-- Javascript -->
    <script type="text/javascript">

    function validate()
        if(document.getElementById('{!$Component.frm.pb.pbs.pbsi1.vendorcompname}').value == '')
            alert("Vendor name is mandatory");
        if(document.getElementById('{!$Component.frm.pb.pbs.pbsi2.amountperevent}').value == '')
            document.getElementById('{!$Component.frm.pb.pbb.sendemail}').disabled = true;
        if(document.getElementById('{!$}').value == '' && 
           document.getElementById('{!$}').value == '')
           document.getElementById('{!$Component.frm.pb.pbb.pdfbutton}').disabled = true;
<!-- Javascript -->
    <apex:form title="Vendor Registration Form" id="frm">
        <apex:pageBlock id="pb">
            <apex:pageBlockSection id="pbs" >
                <apex:pageBlockSectionItem > 
                    <apex:outputLabel >Vendor Company Name</apex:outputLabel>
                <apex:pageBlockSectionItem id="pbsi1">
                    <apex:inputText value="{!vendorcompname}" id="vendorcompname" />
                <apex:outputLabel >Vendor Contact Person</apex:outputLabel><br/>
                <apex:inputText value="{!vendorconperson}"/><br/>
                 <apex:pageBlockSectionItem >
                <apex:outputLabel >Amount per Event</apex:outputLabel><br/>
                <apex:pageBlockSectionItem id="pbsi2">
                <apex:inputText value="{!amountperevent}" id="amountperevent"/><br/>
                 <apex:pageBlockSectionItem >
                <apex:outputLabel >City</apex:outputLabel><br/>
                 <apex:pageBlockSectionItem id="pbsi3">
                <apex:inputText value="{!city}" id="city"/><br/>
                <apex:pageBlockSectionItem >
                <apex:outputLabel >Country</apex:outputLabel><br/>
                 <apex:pageBlockSectionItem id="pbsi4">
                <apex:inputText value="{!country}" id="country"/><br/>
            <apex:pageBlockButtons id="pbb" location="bottom">
        <apex:commandButton id="sendemail" value="Send Email"
        <apex:commandButton value="Reset" />                                        
        <apex:commandButton id="pdfbutton" value="Generate PDF"  />                                          

Thank you Suraj !!
User-added image
I am getting PDF like this.....I am not seeing field values like Vendor Company Name,Vendor Contact Person etc added into the PDF......
How to get the values also in the PDF when the button is clicked?
I am stuck here.....pls help!!!!

Sanjay Vinayak TSanjay Vinayak T
Have you found any solution to the above problem?/
If so kindly share the solution it will be so helpfull.