You need to sign in to do that
Don't have an account?

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('{!$Component.frm.pb.pbs.pbsi3.city}').value == '' &&
document.getElementById('{!$Component.frm.pb.pbs.pbsi4.country}').value == '')
{
document.getElementById('{!$Component.frm.pb.pbb.pdfbutton}').disabled = true;
}
}
</script>
<!-- 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>
<apex:pageBlockSectionItem id="pbsi1">
<apex:inputText value="{!vendorcompname}" id="vendorcompname" />
</apex:pageBlockSectionItem>
<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>
<apex:pageBlockSectionItem id="pbsi2">
<apex:inputText value="{!amountperevent}" id="amountperevent"/><br/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >City</apex:outputLabel><br/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem id="pbsi3">
<apex:inputText value="{!city}" id="city"/><br/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Country</apex:outputLabel><br/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem id="pbsi4">
<apex:inputText value="{!country}" id="country"/><br/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockButtons id="pbb" location="bottom">
<apex:commandButton id="sendemail" value="Send Email"
onclick="validate();"
/>
<apex:commandButton value="Reset" />
<apex:commandButton id="pdfbutton" value="Generate PDF" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
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('{!$Component.frm.pb.pbs.pbsi3.city}').value == '' &&
document.getElementById('{!$Component.frm.pb.pbs.pbsi4.country}').value == '')
{
document.getElementById('{!$Component.frm.pb.pbb.pdfbutton}').disabled = true;
}
}
</script>
<!-- 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>
<apex:pageBlockSectionItem id="pbsi1">
<apex:inputText value="{!vendorcompname}" id="vendorcompname" />
</apex:pageBlockSectionItem>
<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>
<apex:pageBlockSectionItem id="pbsi2">
<apex:inputText value="{!amountperevent}" id="amountperevent"/><br/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >City</apex:outputLabel><br/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem id="pbsi3">
<apex:inputText value="{!city}" id="city"/><br/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Country</apex:outputLabel><br/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem id="pbsi4">
<apex:inputText value="{!country}" id="country"/><br/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockButtons id="pbb" location="bottom">
<apex:commandButton id="sendemail" value="Send Email"
onclick="validate();"
/>
<apex:commandButton value="Reset" />
<apex:commandButton id="pdfbutton" value="Generate PDF" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Hi,
You can take references from the below link.
http://www.interactiveties.com/blog/2015/visualforce-button-pdf.php
https://developer.salesforce.com/forums/?id=906F0000000Ai0XIAS
Thanks
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!!!!
Thanks
Have you found any solution to the above problem?/
If so kindly share the solution it will be so helpfull.
Thanks.