Tab (\t character) Substitute In Visualforce

I am having some difficulty trying to show a hierarchy within a PDF without some of the basic HTML formatting constructs. Below is an example of me trying to format the content using span tags.

I have also tried formatting the rows themselves by formatting the td tags but, it causes the PDF to fail due to the markup being invalid. So, I am running out of normal approaches to this problem. If anyone has found a solution to this is, it would be most appreciated.

Added Information

Here is the Apex class that produces the list of Strings to be printed out.

The Apex Code

this.AccountDisplay = new List>();
this.AccountHeaders = new List();

for(PresenterNode SingleNode : this.Presenters[2].PresentationNodes) { SingleNode.DisplayFields[0] = '' + SingleNode.DisplayFields[0] + ''; this.AccountDisplay.add(SingleNode.DisplayFields); }

this.AccountHeaders = this.Presenters[2].DisplayFields;


This is how it is printed out via VisualForce

The VisualForce Code

   <table width='100%' border="1" cellpadding="10" cellspacing="0"> 
           <tr>
               <apex:repeat value="{!AccountHeaders}" var="AccountHeader">
                   <th>
                       {!AccountHeader}
                   </th>
               </apex:repeat>
</tr> <apex:repeat value="{!AccountDisplay}" var="AccountInfo"> <tr> <apex:repeat value="{!AccountInfo}" var="AccountField"> <td> {!AccountField} <td> </apex:repeat> </tr> </apex:repeat>
</table>

Like I commented before @mast0r, I believe I will have to find a way to link the style to the field and do something like this.

Probable Answer Done in VisualForce Side

<span style="margin-left: "{LinkedMarginValue|StyleString}"> {!AccountField} </span>

I just can’t seem to find a decent way to do that without having jacked up VisualForce code.

Answer

The answer was the following changes:

Apex Code

         this.AccountDisplay = new List>();
         this.AccountHeaders = new List();

        for(PresenterNode SingleNode : this.Presenters[2].PresentationNodes)
        {
            Integer CellNumber = 0;
            List<String> Fields = new List<String>();
            for(String Field : SingleNode.DisplayFields)
            {
                if(CellNumber == 0)
                    Fields.add('<span style="margin-left: ' + 
                        ((AccountHierarchyPresenter.HierarchyNode)SingleNode).ChildOfNumber * 25 +
                        'px">' + SingleNode.DisplayFields[CellNumber] + '</span>');
                else
                    Fields.add('<span>' + SingleNode.DisplayFields[CellNumber] + '</span>');
                CellNumber++;
            }
            this.AccountDisplay.add(Fields);
        }

I am adding to those fields later if needed. Then under Daniel’s suggestion, in the table, I just output my fields with the following:

VisualForce

<apex:outputText value="{!AccountField}" escape="false"/>

Attribution
Source : Link , Question Author : Programmable Medley , Answer Author : Programmable Medley

Leave a Comment