+ Start a Discussion
Jerun JoseJerun Jose 

DataTable in Visual force PDF shows junk data

Hi,

 

When I use the apex:DataTable tag in my VF, it is showing some junk data.

 

The codes that I am using are:

 

VF page:

<apex:page controller="testController" showHeader="false" sidebar="false" renderAs="pdf">
<h2> test text </h2>
<apex:form >
<apex:pageBlock>
<apex:pageBlockTable value="{!AccountList}" var="Account" border="1" width="700">
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Controller class:

public class testController{

public list<Account> AccountList{get;set;}

public testController(){
AccountList = [select id,Name from Account limit 5];
}
}

 

This gives the output as

---------------------------------------------------------------------------------

 

test text

JanuaryFebruaryMarchAprilMayJuneJulyAugustSeptemberOctoberNovemberDecember

2010201120122013201420152016

MonTueWedThuFriSatSun

Today

--------------------------------------------------------------------------------- 

 

The junk data does not appear when I render the page normally.

 

Any pointers on why this is happening and how to avoid it ?

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

Cross post!

 

This is always in place for a form, but when using standard stylesheets its in a hidden layer that gets exposed via JS when you focus on a date input field.  If you don't use standard stylesheets, it just spills out at the bottom of the page because the div (or whatever) that contains it doesn't have a style that hides it any more.

All Answers

Jerun JoseJerun Jose

A small update.


These are the values that appear in the standard calendar select that is shown on SFDC detail pages. But I have no idea why it is coming here or how to remove it .

Jerun JoseJerun Jose

I removed the form tag and the junk value disappeared.

 

So I was able to work around it. But want to know the reason for this behaviour

bob_buzzardbob_buzzard

You'd normally see this at the bottom of a visualforce page if you aren't including the standard style sheets.   I suspect its because you have a form in your PDF page, so VF includes the elements that would support inputting of data.  Presumably you can remove this as you can't enter data into a PDF?

bob_buzzardbob_buzzard

Cross post!

 

This is always in place for a form, but when using standard stylesheets its in a hidden layer that gets exposed via JS when you focus on a date input field.  If you don't use standard stylesheets, it just spills out at the bottom of the page because the div (or whatever) that contains it doesn't have a style that hides it any more.

This was selected as the best answer
Jerun JoseJerun Jose

Thanks Bob

 

I actually used the form tag to render the other contents on the PDF depending on error conditions.

 

Which tag do you think would be the best for this?

 

All I need is :

 

<apex:tag rendered={!myCondition}>

//all my pdf contents which include tables, panelgrid and plain text.

</apex:tag>

 

 

bob_buzzardbob_buzzard

apex:outputPanel is a good candidate for this - its intended for grouping other components.

Jerun JoseJerun Jose

Thanks Bob.

 

Works perfectly. I'm new to VF and just getting used to the tags.

bob_buzzardbob_buzzard

Welcome to the force.  It doesn't take long to pick up the tags.  Good luck!

jasondoddsjasondodds

I am having the same problem with a VF page I am trying to render as PDF.  I have to use <apex:outputField> tags to output the contents of multiple rich text fields, so I need to have the <apex:form> tags on the page.  Is there any CSS class I can over-ride on my stylesheet to hide the html for the date picker?

jasondoddsjasondodds

I was able to find a fix for this issue thanks to my friend Google and a poster on another board:

 

standardStylesheets="false" in the <apex:page> tag

 

<apex:page controller="EmailMergeController" renderAs="PDF" standardStylesheets="false">