I have a Visualforce page that renders perfectly as a PDF that I'd like to attach to an opportunity record and to attach to an email.
Whenever the code gets to getContent(), I keep getting an error saying
Too many nested getContent calls
Below, you can see the code is very simple. Just pulls data to fit into the VF page in the substitution blanks then tries to create the PDF. Looking at the debug log, the call to getContent() only happens once.
I'm stumped!
Thanks for your ideas...
public with sharing class GenerateThankYouLetterAsPDF {
// a handful of fields that are {!field} substitutions on the VF page
public id oppID {get; set;}
public string giftAmount {set; get;}
public string giftDate {set; get;}
// etc...
public GenerateThankYouLetterAsPDF() {
id oppID = id.valueof( ApexPages.currentPage().getParameters().get('id') );
// set the values of field substituions
string filename = 'donation.pdf';
// Generate the PDF
PageReference pdf = ApexPages.currentPage();
system.debug ('calling getContent...');
blob b = pdf.getContent();
}
}