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
Justin MitchellJustin Mitchell 

Need help passing multi-line textarea value from one visualforce page to an embedded visualforce page

I have two visualforce pages.
Page #1 has an editable apex:inputTextArea field on it, on the left side.
Page #2 is rendered as a pdf, and it is embedded into page #1 on the right side. Displayed in page #2 there is a Visualfore component. The component needs to include the text from the inputTextArea on page #1.
There is a button on page #1 (Generate Preview) that should update page #2 with any changes made in the text area.

How can I do this?

Here's what I've tried:
-Passing the text area as a variable in the url does not work, as page breaks in the are not maintained
-I am able to get the desired result by creating a PageReference method in the controller, then having the button action use that method, but that redirects me to page #2 when I click the button, as opposed to letting me reload it as an iframe inside page #1

Here's my super simplified code:

Page #1:
<apex:page showHeader="true" sidebar="true" controller="pdfTest_Class" applyBodyTag="false" tabstyle="opportunity" title="PDF Test">
	<apex:form >
		<apex:pageblock >
			<apex:pageBlockButtons location="top" >
				<apex:commandButton value="Generate Preview" reRender="preview" />
			</apex:pageBlockButtons>

			<apex:outputPanel layout="block">
				<div style="width:50%; float:left;">
					<apex:pageblock mode="edit">
						<apex:pageblocksection columns="1" >	 
			                <apex:pageBlockSectionItem >
			                     <apex:outputlabel value="Company Name" /> 
			                    <apex:inputText value="{!companyName}" />
			                </apex:pageBlockSectionItem>

			                <apex:pageBlockSectionItem >
			                     <apex:outputlabel value="Description"  /> 
			                    <apex:inputTextarea value="{!description}" cols="30" rows="5"  />
			                </apex:pageBlockSectionItem>		
		                </apex:pageblocksection>
	                </apex:pageblock>
                </div>
                
                <div style="width:50%; float:right;" >
                	<apex:pageBlock id="preview">
                		<apex:pageBlockSection columns="1">
                			<apex:iframe src="pdfTest_PreviewPage?companyName={!URLENCODE(companyName)}&description={!URLENCODE(description)}" height="300"/>
                		</apex:pageBlockSection>
            		</apex:pageBlock>
        		</div>
            </apex:outputPanel>
        </apex:pageblock>
    </apex:form>
</apex:page>
Controller:
public with sharing class pdfTest_Class {
	public String companyName {get; set;}
	public String description {get; set;}

    public pdfTest_Class() {
    	companyName = '<enter company name>';
    	description = '<enter description>'
    }

}
Page #2:
<apex:page showHeader="false" sidebar="false" applyBodyTag="false" renderAs="pdf">
	<c:pdfTest_Component 
	companyName="{!$CurrentPage.parameters.companyName}"
	description="{!$CurrentPage.parameters.description}" 
	/>
</apex:page>

Component:
<apex:component >
	<apex:attribute name="companyName" description="Company Name" type="String" />
	<apex:attribute name="description" description="Description" type="String" />

	The name of the company is {!companyName}
	<br />
	Description:
    <br />
	{!description}
</apex:component>

There's GOT to be a better way to do this but this is the only way I know how, and now that I need text area fields, it doesn't even work. Help!