+ Start a Discussion
Ganesh HegdeGanesh Hegde 

Add image and signature to PDF


I am generating a PDF on case insert using trigger. I need to add an image and signature to it. Is it possible?
I am generating pdf like this

String pdfContents = '<html>';
pdfContents += UserInfo.getUserName();
pdfContents += '<div>';
pdfContents += '</body>';
pdfContents += '</html>';

Blob pdfBlob = Blob.toPDF(pdfContents);
Ankit Maini.Ankit Maini.
Hi Ganesh,

I am not sure but you can try this:

You have to get the timestamp value of static resource in which your image is placed.
StaticResource s = [Select Id, SystemModstamp from StaticResource where Name = 'Static Resource Name'];
String timestamp = String.valueOf(s.SystemModstamp.getTime());

After that you can use in pdfContent with this url:
pdfContent += '<img src="/resource/'+ timestamp+ '/Images/myImage.png"' />

Hope this will work.
Ganesh HegdeGanesh Hegde

Is it possible to add a digital signature to PDF?
Ganesh HegdeGanesh Hegde
Hi Ankit,

Is it working for you? I have tried but i am still getting this error -"Error: Invalid Data. 
Review all error messages below to correct your data.
An error occurred while parsing the input string."

Please suggest

Ankit Maini.Ankit Maini.
I think '<' and '>' symbols creates the problem, You have to see how you gonna sort out.

Ganesh HegdeGanesh Hegde
I did this using Process Builder.