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
Aneesh AllumallaAneesh Allumalla 

Passing values from one vf page to other as pdf

Hi,
My requirement is I have to create a simple vf page with one input field and one button. on clicking the button the value entered in the input field of the first page should be displayed in a pdf page.
Here is my code:
Controller:
public class PDFpage {
    Public String x{get;set;}
    Public String y{get;set;}
    Public PDFpage(){}
    Public pagereference submit(){
        y=x;
        PageReference pr = new PageReference('https://c.ap4.visual.force.com/apex/PDFpage2') ;  
        pr.setRedirect(true);
        return pr;
    }    
}

VFpage1:
<apex:page controller="PDFpage" >
    <apex:form >
        <apex:pageblock >
                <apex:pageBlockSection>
                    <apex:inputText label="Name" value="{!x}"/>
                </apex:pageBlockSection>
            <apex:pageBlockSection >
                <apex:commandButton action="{!submit}" value="submit"/>
            </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>

Vfpage2:

<apex:page controller="PDFpage" >
    <apex:form >
        <apex:pageblock >
                <apex:pageBlockSection>
                    <apex:outputText value="{!y}"/>
                </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>
When I click the button after entering the value, it is creating an empty PDF without any value displaying  in it.
Can anyone help how to get the value on to the PDF page.
 
KrishnaAvvaKrishnaAvva
Hi Aneesh,

This is solved here : https://developer.salesforce.com/forums/?id=9060G000000Xj73QAC
You would need a global class which exposes the logic as a webservice to generate the PDF and pass values to it.

Please mark it SOLVED if it helped you. Thanks!

Regards,
Krishna Avva
Raj VakatiRaj Vakati
You can do it three different ways 

Option 1 : On the page load of the visualforce page, create an attachment and pass the Id to the second page .. 

On a load of the second page you can able to get the attachment deils 

Option 2 : - create a Rest API and Send the data between two pages 

Opttion 3: Use SOAP API