0

I have a visualforce controller like this ,

public class ViewAsPDFController {

    public String TempString {get;set;}
    public List<Account> accountList {get;set;}

    public ViewAsPDFController()
    {
         accountList= [SELECT Id,Name,AccountNumber FROM Account];

        TempString ='<h1>Apex PDF Test</h1>'+
            +'<apex:repeat value="{!accountList}" var="alist" id="theRepeat">'+
            +'{!alist.Name}'+            
            +'</apex:repeat>';
    }

}

My VF page

<apex:page controller="ViewAsPDFController" renderAs="PDF">    
    <apex:outputText value="{!TempString}" escape="false"/>
</apex:page>

My output is returning as : {!alist.Name} instead of returning account name.

  • rather than using TempString, why not put the VF markup in the VF page rather than trying to inject it into the page? – cropredy Nov 16 at 6:18
  • i need to concatinate values from email template to this {!TempString} before adding apex:repet to it , i haven't include my full code here its a sample code , – Raja Sabarish Nov 16 at 6:22
  • email template? You need to elaborate more in your original question what you are trying to accomplish. Use edit, not comments. Dynamic VF is done a different way (and I've never used it) – cropredy Nov 16 at 6:28
0

Visualforce components must be in the markup in order to be executed. You can't compose them in Apex like this. You can render normal HTML, but you'll have to do the repeat stuff in Apex:

TempString = '<h1>Apex PDF Test</h1>';
for(Account record: accountList) {
    TempString += '<div>'+record.Name+'</div>';
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.