currently i'm displaying encoded signature in my apex page in this way :

<apex:image value="data:image;base64,{!Call.Signature__c}" />

Now i want this encoded signature to be saved in attachment object and then reference it in the visualforce page for a successful renderas pdf. please provide me detail technical solutions

1 Answer 1


Saving data as an attachment is basically as simple as:

Attachment record = new Attachment(ParentId = call.Id, Body = EncodingUtil.base64Decode(call.Signature__c), ContentType = 'image/jpeg');
insert record;

Note that you need to know the data type of the file more than just "image", so you'll probably want to store that in a separate field.

Once saved, you can use this answer to generate the appropriate URL for viewing/downloading/including the image.

  • but the problem is there are some text field values too, like {!Call.Account__c} which i also need to store inside the attachment along with the encoded signature, socan you give me details how to incorporate those texts inside that attachment body? Aug 11, 2014 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.