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
AkashAkash 

PDF in visualforce

I have developed two pages in visual force and passing one page values to next page which is rendered as PDF. The values from first page are not being displayed on the PDF but when I remove the <renderAs="pdf"> tag my values are correctly displayed in HTML form.
 
Can you please help me know why my values are not being displayed in PDF?
 
Thanks
Jon Mountjoy_Jon Mountjoy_
Posting a little of your Visualforce page source code will help debug your problem. Can you do that?
AkashAkash

Page 1

<apex:page controller="MyController" showHeader="true" tabStyle="account" sidebar="false" >

<apex:form id="form1">
<apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel" >
<apex:tab label="Project Status Report Criteria" id="tabdetails">
<br/>
<br/>
<table width="70%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td >
<apex:outputLabel value="@Period Ending" styleClass="sample"></apex:outputLabel>
</td>
<td>
<apex:inputText id="periodending" value="{!periodending}"> </apex:inputText>
</td>

</tr>

</table>

<apex:commandButton value="Generate" action="{!getProject}" onclick="return isDateValid()"></apex:commandButton>
<apex:commandButton value="Cancel"></apex:commandButton>
</apex:tab>


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

 

Page 2:

<apex:page controller="MyController" renderAs="pdf" showHeader="true" tabStyle="account" sidebar="false"  >

<apex:form >
<apex:pageBlock title="Project Status Report">

<table>
<tr>
<td>
<apex:outputLabel value="Period Ending:"></apex:outputLabel>
<apex:outputLabel value="{!periodending}"></apex:outputLabel>
</td>
</tr>
 
</table>

 

 
The user inputs the value of periodending in a text box in page 1 and it is retrieved in Page 2. When I do it without using the tag <renderAs = "pdf"> in page 2 i get the data but when rendering the page as pdf the data is not displayed.
 
Can you please help me find a solution?
 
Thanks
Akash


Message Edited by Jon Mountjoy_ on 07-28-2008 12:48 AM
Ron HessRon Hess
in your Apex controller, does getProject use setRedirect?

if so, you may be clearing the value that you want to keep.
AkashAkash
I am not using setRedirect but the code for getProject() is:
 
public PageReference getProject()
{
PageReference p;
periodending = System.currentPageReference().getParameters().get('periodending');
p = Page.PSR;
return p;
}
 
Please let me know.
 
Thanks
dchasmandchasman
renderAs="PDF" does not currently support apex:input* components. PDF generation is targeted at producing read only documents - e.g. things like quotes, proposals, etc - and not reproducing the salesforce UI as a PDF.
AkashAkash
I am not using input components in the second page which is rendered as PDF. The second page code is as follows:

<apex:page controller="MyController" renderas="pdf"  showHeader="true" tabStyle="account" sidebar="false"  >
<apex:form>
<apex:pageBlock title="Project Status Report">

<table>
<tr>
<td>
<apex:outputLabel value="Period Ending:"></apex:outputLabel>
<apex:outputLabel value="{!periodending}"></apex:outputLabel>
</td>
</tr>
</table>

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

Here I am not using any input component on the second page.

Thanks
Ron HessRon Hess
try outputText instead of outputLabel
AkashAkash

Hi !!

Thanks for the reply. I used outputText instead of OutputLabel still it didnt work.

some more help required please.

Thanks

AkashAkash
Hi,
 
Please reply to this..Its very urgent as my client is waiting on this.
 
Thanks
Akash
dchasmandchasman
Please post exactly what you have for both your controller and your page including the modifications to use outputText
MiddhaMiddha
Even i tried the same and it doesnt works, the value inserted in textbox on page 1 doesnt comes on page 2, if the 2nd page is rendered as PDF. In case the 2nd page is rendered as HTML, it works fine,  below is my code:

VF TestPage1

Code:
<apex:page controller="test">
<apex:form >
 <apex:inputText value="{!abc}"/>
 <apex:commandButton action="{!move}" value="Move"/>
</apex:form>
</apex:page>

 VF TestPage2
Code:
<apex:page controller="test" renderas="pdf">
   {!abc}
</apex:page>

Controller: test


Code:
public class test
{
 String a = '';
 public String getABC(){
  return a;
 }
 public void setABC(String a){
  this.a = a;
 }
 public PageReference move(){
  return Page.test2;
 }
}

 
 Please advise if somethings wrong in this code!!

GM


MiddhaMiddha
Can you please confirm if its a code issue or some visualforce bug?

GM
VikasVikas
Hey guys,

I am having a similar problem, can anybody help please?

Thank you,



Ron HessRon Hess
I can confirm that this does not work as expected, there is a bug filed for this issue.
Ron HessRon Hess
Here is a workaround that you may consider

The issue appears to be that values in the controller viewstate are not delivered to the PDF render process, however, values in the page parameters are.


Here is my version, no change here:
Code:
apex:page controller="test">
<apex:form >
 <apex:inputText value="{!abc}"/>
 <apex:commandButton action="{!move}" value="Move"/>
</apex:form>
</apex:page>


This page uses parameters instead of a getter:
 
Code:
<apex:page controller="test" renderas="pdf">
   {!$CurrentPage.parameters.test}
</apex:page>

 
This controller sets the parameter by reading the viewstate :
Code:
public class test
{
 String a = '';
 public String getABC(){
  return a;
 }
 public void setABC(String a){
  this.a = a;
 }
 public PageReference move(){
  pagereference p = Page.TestPage2;
  p.getParameters().put('test',a);
  return p;
 }
}

 

The resulting PDF page does have the content from the first page. 
Hope this workaround will allow you to build your pages.

AkashAkash
thanks for this solution. It worked for me. Now I am having another issue that CSS is not being applied on PDF. Can we apply CSS on the generated PDF?

Please let me know.

Thanks
AkashAkash
Hi !!
 
Please treat this as urgent and reply back. The code that I am writing for attaching style in column header is as follows:
 
<apex:column headerClass="tbl_greyhdr" headerstyle="color:#000000;font-family:Arial, Helvetica, sans-serif;font-size:12px;font-weight:bold;text-align:center;background-color:#d6d6d6;"  style="color:#000000;font-family:Arial, Helvetica, sans-serif;font-size:11px;font-weight:normal;text-align:center;">
 
Thanks
Ron HessRon Hess
here is an example of how CSS can be applied to PDF

http://wiki.apexdevnet.com/index.php/Visualforce_CaseHistoryTimeline

change the renderas="html" to "pdf" and the css should be applied