I am creating a mobile app using Salesforce MobileSDK with Hybrid approach (using phonegap and Jquery Mobile). I have a need to generate Quotes programmatically. I know how to do this. But, I am not able to figure out how to create quote pdf document, given Quote ID / Quote Name, PDF Template programmatically. Basically need programmatic access to generate PDF given Quote ID, PDF template name etc.,

2 Answers 2


A bit of reverse engineering and the code behind the Create PDF button on the Standard Quote page reveals that it invokes


Pasting this into the Browser sure enough renders the Quote similar to how it is rendered on clicking the Create PDF Button.

Also, if doing this in VF, you can tap into the Create PDF Action {!$Action.Quote.CreatePdf} wrapped inside a URLFOR.


Not sure if this will help:

PageReference pr = new PageReference('/quote/quoteTemplateDataViewer.apexp?id=<QUoteId>&summlid=<TemplateId>'); // link from answer by techtrekker
Blob pdfBlob = pr.getContentAsPdf();

You can then either create an attachment by assigning pdfBlob as the body, or you may be able to render the PDF in the current page using something like:

<embed src="data:application/pdf;base64,{!base64EncodedPDF} type="application/pdf"/> 

Where base64EncodedPDF is a string created as follows:

String base64EncodedPDF = EncodingUtil.base64Encode(pdfBlob);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .