I have different ways in my organization to generate my invoice pdf and attach it to my records. My PDF includes a logo stored in a public StaticResource. It works perfectly everywhere except when I generate my pdf from Apex REST, it doesn't display my logo :
Some Code :
@RestResource(urlMapping='/invoicereq/*')
global without sharing class InvoiceTemplateController
{
@HttpGet
global static void generateInvoiceAttachment()
{
....
//1. Generate & insert Invoice as an attachment
PageReference pdf = new Pagereference('/apex/InvoicePDF?id=' + header.Id);
Blob body = pdf.getContentAsPDF();
Attachment attachment = new Attachment();
attachment.Body = body;
attachment.Name = 'Invoice ' + header.Name + '.pdf';
attachment.IsPrivate = false;
attachment.ParentId = header.Id;
insert attachment;
...
}
}
HTML
<img src="{!URLFOR($Resource.MyLogo)}" />
However if I use my logo as a Document with the same code, it works perfectly.
Any ideas why ?