+ Start a Discussion
MohanaGopalMohanaGopal 

Renderas ="PDF" return error index 4,size 4

Hi...
 
        In my sandbox org I got Index 4, Size 4 error when I give renderas pdf for my VF page ..
 
My VF page work fine in HTML format.. I have to render a PDF when I click a Detail page button....
 
Some records rendered a PDF correctly.. Some record I got a error index 4, Size 4.....
 
How to avoid it...  How to fix this problem...
 
 
 
 
 
JeremyKraybillJeremyKraybill
It's quite possible you are running into the issue discussed in these two threads here and here - basically renderAs=pdf changes the request cycle in a way that can break otherwise fine controller logic. Not sure without you posting your page and controller code, but check that thread out first.

Jeremy Kraybill
Austin, TX
JRTConsultJRTConsult
I am receiving the same error message when I add the tag to my page. On the same page last week, I was able to add the tag to the page and it rendered just fine, but it errors out today. I tried calling support, but they don't provide support for these errors.
MohanaGopalMohanaGopal
Hi..
 
   Thanks for ur reply...
 
 Have u resolved ur problem...
 
Some times only it give this error... How to avoid this problem...
 
Give some suggestion..
dchasmandchasman
This error is coming from a 3rd party library we use to convert the HTML generated by your VF page to PDF and usually happens when the HTML is invalid in some way (e.g. missing a close tag on a <td>). This can also manifest as something that appears to be data driven (e.g. no rows or 1 or more child rows trigger it). Can you post your page definition so we can take a look?
JRTConsultJRTConsult
Code:
<apex:page standardController="Investment_Policy_Statement__c">
>


<H4>Asset Allocation</H4>

<p>The investment objective of this account can be best met by {!Investment_Policy_Statement__c.Asset_Allocation_Language__c}. The current
target asset allocation ranges for this account are:</p>
<!--
<apex:panelGrid columns="4" style="width:700px" id="Header" border="1" >

        <apex:outputText style="width:400px" value="Asset Class"  id="h1" />
        <apex:outputText style="width:100px;" value="Minimum"  id="h2" />
        <apex:outputText style="width:100px;" value="Long-Term Target" id="h3" />
        <apex:outputText style="width:100px;" value="Maximum" id="h4" />
</apex:panelGrid>
-->
<apex:dataTable value="{!Investment_Policy_Statement__c}" var="IPS" width="700px"  id="xCandE" border="0" >
<!--    <apex:facet name="header"><b>Asset Class</b></apex:facet>
    <apex:facet name="header"><b>Minimum</b></apex:facet>
    <apex:facet name="header"><b>Long-Term Target</b></apex:facet>
    <apex:facet name="header"><b>Maximum</b></apex:facet>-->
        <apex:column breakBefore="true" id="xtd101"><b>Asset Class</b></apex:column>
        <apex:column id="xtd102"><b>Minimum</b></apex:column>
        <apex:column id="xtd103"><b>Target</b></apex:column>
        <apex:column id="xtd104"><b>Maximum</b></apex:column>        
        <apex:column breakBefore="true" id="xtd1" rendered="{!IF(Investment_Policy_Statement__c.CEMIN__c + Investment_Policy_Statement__c.CETAR__c + Investment_Policy_Statement__c.CEMAX__c > 0, 'True', 'False')}">Cash and Equivalents</apex:column>
        <apex:column value="{!Investment_Policy_Statement__c.CEMIN__c}" id="xtd2" rendered="{!IF(Investment_Policy_Statement__c.CEMIN__c + Investment_Policy_Statement__c.CETAR__c + Investment_Policy_Statement__c.CEMAX__c > 0, 'True', 'False')}"/>
        <apex:column value="{!Investment_Policy_Statement__c.CETAR__c}" id="xtd3" rendered="{!IF(Investment_Policy_Statement__c.CEMIN__c + Investment_Policy_Statement__c.CETAR__c + Investment_Policy_Statement__c.CEMAX__c > 0, 'True', 'False')}"/>
        <apex:column value="{!Investment_Policy_Statement__c.CEMAX__c}"  id="xtd4" rendered="{!IF(Investment_Policy_Statement__c.CEMIN__c + Investment_Policy_Statement__c.CETAR__c + Investment_Policy_Statement__c.CEMAX__c > 0, 'True', 'False')}"/>
        <apex:column breakBefore="true" id="xtd5" rendered="{!IF(Investment_Policy_Statement__c.EQMIN__c + Investment_Policy_Statement__c.EQTAR__c + Investment_Policy_Statement__c.EQMAX__c > 0, 'True', 'False')}">Equities</apex:column>
        <apex:column value="{!Investment_Policy_Statement__c.EQMIN__c}" id="xtd6" rendered="{!IF(Investment_Policy_Statement__c.EQMIN__c + Investment_Policy_Statement__c.EQTAR__c + Investment_Policy_Statement__c.EQMAX__c > 0, 'True', 'False')}"/>
        <apex:column value="{!Investment_Policy_Statement__c.EQTAR__c}" id="xtd7" rendered="{!IF(Investment_Policy_Statement__c.EQMIN__c + Investment_Policy_Statement__c.EQTAR__c + Investment_Policy_Statement__c.EQMAX__c > 0, 'True', 'False')}"/>
        <apex:column value="{!Investment_Policy_Statement__c.EQMAX__c}" id="xtd8" rendered="{!IF(Investment_Policy_Statement__c.EQMIN__c + Investment_Policy_Statement__c.EQTAR__c + Investment_Policy_Statement__c.EQMAX__c > 0, 'True', 'False')}"/>  
        <apex:column breakBefore="true" id="xtd9" rendered="{!IF(Investment_Policy_Statement__c.FIMIN__c + Investment_Policy_Statement__c.FITAR__c + Investment_Policy_Statement__c.FIMAX__c > 0, 'True', 'False')}">Fixed Income</apex:column>
        <apex:column value="{!Investment_Policy_Statement__c.FIMIN__c}" id="xtd10" rendered="{!IF(Investment_Policy_Statement__c.FIMIN__c + Investment_Policy_Statement__c.FITAR__c + Investment_Policy_Statement__c.FIMAX__c > 0, 'True', 'False')}"/>
        <apex:column value="{!Investment_Policy_Statement__c.FITAR__c}" id="xtd11" rendered="{!IF(Investment_Policy_Statement__c.FIMIN__c + Investment_Policy_Statement__c.FITAR__c + Investment_Policy_Statement__c.FIMAX__c > 0, 'True', 'False')}"/>
        <apex:column value="{!Investment_Policy_Statement__c.FIMAX__c}" id="xtd12" rendered="{!IF(Investment_Policy_Statement__c.FIMIN__c + Investment_Policy_Statement__c.FITAR__c + Investment_Policy_Statement__c.FIMAX__c > 0, 'True', 'False')}"/>               
        <apex:column breakBefore="true" id="xtd13" rendered="{!IF(Investment_Policy_Statement__c.RAMIN__c + Investment_Policy_Statement__c.RATAR__c + Investment_Policy_Statement__c.RAMAX__c > 0, 'True', 'False')}">Real Assets</apex:column>
        <apex:column value="{!Investment_Policy_Statement__c.RAMIN__c}" id="xtd14" rendered="{!IF(Investment_Policy_Statement__c.RAMIN__c + Investment_Policy_Statement__c.RATAR__c + Investment_Policy_Statement__c.RAMAX__c > 0, 'True', 'False')}"/>
        <apex:column value="{!Investment_Policy_Statement__c.RAMAX__c}" id="xtd15" rendered="{!IF(Investment_Policy_Statement__c.RAMIN__c + Investment_Policy_Statement__c.RATAR__c + Investment_Policy_Statement__c.RAMAX__c > 0, 'True', 'False')}"/>
        <apex:column value="{!Investment_Policy_Statement__c.RAMIN__c}" id="xtd16" rendered="{!IF(Investment_Policy_Statement__c.RAMIN__c + Investment_Policy_Statement__c.RATAR__c + Investment_Policy_Statement__c.RAMAX__c > 0, 'True', 'False')}"/>
        <apex:column breakBefore="true" id="xtd17" rendered="{!IF(Investment_Policy_Statement__c.ALTMIN__c + Investment_Policy_Statement__c.ALTTAR__c + Investment_Policy_Statement__c.ALTMAX__c > 0, 'True', 'False')}">Asset Class</apex:column>
        <apex:column value="{!Investment_Policy_Statement__c.ALTMIN__c}" id="xtd18" rendered="{!IF(Investment_Policy_Statement__c.ALTMIN__c + Investment_Policy_Statement__c.ALTTAR__c + Investment_Policy_Statement__c.ALTMAX__c > 0, 'True', 'False')}"/>
        <apex:column value="{!Investment_Policy_Statement__c.ALTMAX__c}" id="xtd19" rendered="{!IF(Investment_Policy_Statement__c.ALTMIN__c + Investment_Policy_Statement__c.ALTTAR__c + Investment_Policy_Statement__c.ALTMAX__c > 0, 'True', 'False')}"/>
        <apex:column value="{!Investment_Policy_Statement__c.ALTMIN__c}" id="xtd20" rendered="{!IF(Investment_Policy_Statement__c.ALTMIN__c + Investment_Policy_Statement__c.ALTTAR__c + Investment_Policy_Statement__c.ALTMAX__c > 0, 'True', 'False')}"/>
</apex:dataTable>
<H4>Investment Restrictions</H4>


 <apex:panelGrid columns="1" id="NoRestrictions"  rendered="{!IF(Investment_Policy_Statement__c.Account_Restriction_1__c == '' && Investment_Policy_Statement__c.Account_Restriction_2__c == '' && Investment_Policy_Statement__c.Account_Restriction_3__c == '' && Investment_Policy_Statement__c.Account_Restriction_4__c == '', 'True', 'False')}">        
    <apex:outputText value="No stipulations were requested." id="nh" />
 </apex:panelGrid>


 <apex:panelGrid columns="1" id="Restrictions"  rendered="{!IF(Investment_Policy_Statement__c.Account_Restriction_1__c != '' && Investment_Policy_Statement__c.Account_Restriction_2__c != '' && Investment_Policy_Statement__c.Account_Restriction_3__c != '' && Investment_Policy_Statement__c.Account_Restriction_4__c != "", 'True', 'False')}">        
    <apex:outputText value="The following Stipulations are requested by {!Investment_Policy_Statement__c.Client_Name__c}" id="rh" />
 </apex:panelGrid>


 <apex:panelGrid columns="1" id="rh1"  rendered="{!IF(Investment_Policy_Statement__c.Account_Restriction_1__c != '', 'True', 'False')}">        
    <apex:outputText value="{!Investment_Policy_Statement__c.Account_Restriction_1__c}" id="r1" />
</apex:panelGrid>

 <apex:panelGrid columns="1" id="rh2"  rendered="{!IF(Investment_Policy_Statement__c.Account_Restriction_2__c != '', 'True', 'False')}">        
    <apex:outputText value="{!Investment_Policy_Statement__c.Account_Restriction_2__c}" id="r2" />
</apex:panelGrid>

 <apex:panelGrid columns="1" id="rh3"  rendered="{!IF(Investment_Policy_Statement__c.Account_Restriction_3__c != '', 'True', 'False')}">        
    <apex:outputText value="{!Investment_Policy_Statement__c.Account_Restriction_3__c}" id="r3" />
</apex:panelGrid>

 <apex:panelGrid columns="1" id="rh4"  rendered="{!IF(Investment_Policy_Statement__c.Account_Restriction_4__c != '', 'True', 'False')}">        
    <apex:outputText value="{!Investment_Policy_Statement__c.Account_Restriction_4__c}" id="r4" />
</apex:panelGrid>

       <script language='javascript' type='text/javascript'>
       // alert('njs');
          setALT();
        //  setCE(); 
       // function setCE() {
        
         //   if('{!Investment_Policy_Statement__c.CEMIN__c}' == 0 AND '{Investment_Policy_Statement__c.CETAR__c}' == 0 AND '{!Investment_Policy_Statement__c.CEMAX__c}' == 0 {
         //        showCollapse('CE','hide');
         //   } else {
          //       showCollapse('CE','show');
         //   }
       // } 
        function setALT() {
        var theTest = Number('{!Investment_Policy_Statement__c.ALTMIN__c}') + Number({!Investment_Policy_Statement__c.ALTTAR__c})+ Number({!Investment_Policy_Statement__c.ALTMAX__c});
            if (theTest != 0){
                 showCollapse('ALT','show');
            } else {
                 showCollapse('ALT','hide');
            }
        }        
    function showCollapse(objid,flag) {
        //alert(objid);// debug
         if(flag == 'show') {
         
             document.getElementById(objid).style.visibility="visible";
         } else {
         
         if(isIE()) {
             document.getElementById(objid).style.visibility="hidden";
             } else {
             document.getElementById(objid).style.visibility="Collapse";
             }
         }
       } 
      function isIE() {
        return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
      } 
       
       function CommaFormatted()
{
    var delimiter = ","; // replace comma if desired
    var a = amount.split('.',2)
    var d = a[1];
    var i = parseInt(a[0]);
    if(isNaN(i)) { return ''; }
    var minus = '';
    if(i < 0) { minus = '-'; }
    i = Math.abs(i);
    var n = new String(i);
    var a = [];
    while(n.length > 3)
    {
        var nn = n.substr(n.length-3);
        a.unshift(nn);
        n = n.substr(0,n.length-3);
    }
    if(n.length > 0) { a.unshift(n); }
    n = a.join(delimiter);
    if(d.length < 1) { amount = n; }
    else { amount = n + '.' + d; }
    amount = minus + amount;
    return amount;
}

private class PrimaryAdvisorDetails
    {
        String name  = '';      
        String street  = '';
        String city  = '';
        String state  = '';
        String zip  = '';
        String bankaffiliate  = '';
            
        public void fetchDetails(String id)
        {
            Account_Application__c app = [Select a.Primary_Advisor__c From Account_Application__c a Where a.Id = :id];
            
            System.debug('APPID:'+id);
            System.debug('PRIMARY ADVISOR:'+app.Primary_Advisor__c);
            
            //a0hR00000004KDwIAM;
                User u =    [Select u.Street, u.State, u.PostalCode, u.LastName, u.Id, u.FirstName, u.Country, u.City, u.Affiliate__c From User u
                             Where u.id = :app.Primary_Advisor__c];
            
            name = u.FirstName+' '+u.LastName;
            street = u.Street;
            city = u.City;
            state = u.State;
            zip = u.PostalCode;
            bankaffiliate = u.Affiliate__c;
            
            /**
            Account_Application__c app = [Select a.Primary_Advisor__r.Name, a.Primary_Advisor__r.PostalCode, a.Primary_Advisor__r.State,
                                        a.Primary_Advisor__r.City, a.Primary_Advisor__r.Street, a.Primary_Advisor__r.Affiliate__c,
                                         a.Primary_Advisor__r.Id, a.Primary_Advisor__c
                                    From Account_Application__c a
                                    Where a.Id = :id];
            
            
            if(u.Primary_Advisor__r.Name != NULL)
                name = u.Primary_Advisor__r.Name;
            if(app.Primary_Advisor__r.Street != NULL)    
                street = app.Primary_Advisor__r.Street;
            if(app.Primary_Advisor__r.City != NULL)
                city = app.Primary_Advisor__r.City;
            if(app.Primary_Advisor__r.State != NULL)
                state =  app.Primary_Advisor__r.State;
            if(app.Primary_Advisor__r.PostalCode != NULL)
                zip = app.Primary_Advisor__r.PostalCode;
            if(app.Primary_Advisor__r.Affiliate__c != NULL)
                bankaffiliate = app.Primary_Advisor__r.Affiliate__c;
            **/
            
        }
        
        String getPrimaryAdvisorCityStateZip()
        {
            return  city +', '+ state +' '+ zip;
        }
        
        String getPrimaryAdvisorAddress()
        {
            return street + ', '+city +', '+ state +' '+ zip;
        }
    }
    


// end of function CommaFormatted()
             
</script>
<!--rendered="{!IF(Investment_Policy_Statement__c.ALTMIN__c == 0 && Investment_Policy_Statement__c.ALTTAR__c == 0 && Investment_Policy_Statement__c.ALTMAX__c == 0 , 'false', 'true')}"/-->
</apex:page>


 
mtbclimbermtbclimber
MohanaGopal ,

Can you provide an example of your page that results in the error you described? 

JRTConsult ,

Does your page compile as it stands? If so do you get warnings?

The conversion facility is fairly sensitive to markup that is not properly structured.  Also it will not do anything with javascript. Finally it appears you have apex code embedded within a script tag which isn't going to do much more than throw javascript errors in a browser, was that a copy/paste error?



sabsisabsi
Hi,
I found the same problem but I have index:1;size:1.
I checked all tags but that didn't change anything.
When I removed 'renderAs=PDF', I didn't have the message anymore and that worked verry well.
So where is the problem?

Thanks a lot
Cool_DevloperCool_Devloper

Hello Friends,

 

I was getting the same error on my page but was able to fix it up. So, thought of sharing it here.

 

As Doug pointed out above, that this error basically comes from improper use of tags in the rendered HTML which is used to convert to PDF by the 3rd party library.

 

I just commented portions of my page to check where exactly the error was propogating from. In this way i found out that it was just an <apex:outputPanel> tag which was misplaced between <tr><td> tags.

 

Once i fixed this, the error did not come. So, surely you need to check your page tags if they are properly structured or not.

 

Hope this helps!!

 

Cool_D