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
Zach Gavin DelacroixZach Gavin Delacroix 

PDF Rendered visualforce issue

Hi Experts,

I need help on fixing issue on my PDF rendered page.

The normal view works just fine. But when I set the page to render as PDF, then I'm having issue with the output.

Here's how it looks like, the on on the Left is Normal View of VisualForce and Right is the one Rendered as PDF which is having issue as you see.

User-added image


Here's the code..
 
<apex:page controller="accountController2" sidebar="false">
  
  <apex:variable value="{!0}" var="counter"/>
    <table style="Border:Solid 1px">
        <tr>
          <td style="Border:Solid 1px;background-color:green">
              Column 1
          </td>
          <td style="Border:Solid 1px;background-color:green">
              Column 2
          </td>
      </tr>
    <apex:repeat value="{!acc}" var="record">
        <apex:outputPanel rendered="{!mod(counter,2)=0}"> <!---->
            <apex:outputText escape="false" value="<tr>"/>
                <td style="Border:Solid 1px">{!record.name}</td>
        </apex:outputPanel>
        <apex:outputPanel rendered="{!mod(counter,2)=1}"> <!---->
                <td style="Border:Solid 1px">{!record.name}</td>
            <apex:outputText escape="false" value="</tr>"/>
        </apex:outputPanel>
        <apex:variable value="{!counter+1}" var="counter"/>
    </apex:repeat>
        <td>
        
        </td>
    </table>
</apex:page>
Then My controller..
 
public class accountController2 {
    
    public list<account> acc{get;set;}
   
   public accountController2 (){
       
       acc = new list<account> ();
       
       acc = [select name from account limit 10];
   
   }
}

Just make the Page renderAs PDF then you'll see the difference..

Thanks a lot!

-Zach
 
Dushyant SonwarDushyant Sonwar
Hi Zack,

Add layout="none" in outputPanel tag when rendering your page as pdf.
<apex:outputPanel rendered="{!mod(counter,2)==0}" layout="none"> <!---->
            <apex:outputText escape="false" value="<tr>"/>
                <td style="Border:Solid 1px">{!record.name}</td>
        </apex:outputPanel>
        <apex:outputPanel rendered="{!mod(counter,2)==1}" layout="none"> <!---->
                <td style="Border:Solid 1px">{!record.name}</td>
            <apex:outputText escape="false" value="</tr>"/>
        </apex:outputPanel>

Hope this helps.
Thanks