2

I want to use Blob.toPDF() method to create attachment body, currently using:

attachmentPDF.Name = account.Name + '.pdf';
 attachmentPDF.body = Blob.toPDF(pdfContent);`

Inside pdfContent I want to incorporate image and some text in this way pdfContent=EncodingUtil.base64Decode(call.Signature__c) and some text fileds too pdfContent=pdfContent+ call.Account__c. Please suggest some technical solutions using the Blob.toPDF() method

2 Answers 2

2

Blob.toPDF() should work with a simple HTML input string. So you might do something like the following (untested):

<html><body><img src="data:image/jpeg;base64,dGVzdA==" /><p>Additional Content</body></html>

Please be aware, that Blob.toPDF() has always been very buggy in the interpretaion of the HTML, that you may throw on it. But i don't know if that does hold true for API 31.

1
  • Hi Alexander, i've tried this out, throwing me some error 'Review all error messages below to correct your data. An error occurred while parsing the input string.' please suggest. I've used pdfContent= pdfContent + FORM_HTML_START ; pdfContent ='<img src=\"data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAApAAAACQgAAEIQAACAxH4tk54VvKzMTEIQAACEGiBwH8BsgK34VJMUqcAAAAASUVORK5CYII=\"/>'; pdfContent= pdfContent+FORM_HTML_END ; Aug 12, 2014 at 12:19
0

Now that time has passed a bit...

I'm trying to use a trigger generate a custom PDF and attach it to an email. Since PageReference.getContent() is not trigger-friendly, I'm using blob.toPDF(). It's working perfectly - except for choking on the image I'd like to include.

So...any more thoughts on the topic?

Thanks

You must log in to answer this question.

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