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
Curry-ManCurry-Man 

page.GetContent() is returning incorrect values

I've created a simple visualforce page that references a custom object (Quote__c) and renders the content as a PDF.  I have a custom controller that references the page and I'm attempting to send the PDF as an email attachment, which works, but is sending the wrong information in the pdf body.

 

Here is my concept page:

 

 

<apex:page standardController="Quote__c" extensions="addProducts" showheader="false" id="quote" renderAs="pdf">
<apex:stylesheet value="/resource/1269370798000/ContractStyles" />
<h3>{!Quote__c.ID}</h3>
<h3>{!Quote__c.name}</h3>
<h3>{!Quote__c.SOW__c}</h3>
</apex:page>

 

and here is my controller:

 

	public addProducts(apexpages.standardcontroller controller){
	    quote = (Quote__c)controller.getRecord();
	}
	
	public PageReference SendDocument(){	
			PageReference pdf =  Page.PackagePreview;
		pdf.getParameters().put('id',quote.id); 
		pdf.setRedirect(true);
		
		Blob b = pdf.getContentAsPDF();
		
		Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
			efa.setFileName('attachment.pdf');
			efa.setBody(b);

			Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
				String[] toAddresses = new String[]{'danielc@schoolcenter.com'};
				mail.setToAddresses(toAddresses);
				mail.setSaveAsActivity(true);
				mail.setSenderDisplayName('SchoolCenter');
				mail.setSubject(quote.subject__c);
				mail.setPlainTextBody(quote.body__c);
				mail.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
			Messaging.SendEmailResult[] mailresults = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
			for(Messaging.SendEmailResult mailresult : mailResults){
				system.debug(mailresult);
			}
	}

 

Any suggestions on how to get the PDF to pull the correct information into it as an email attachment?