What I'm doing is retrieving a PDF and save that PDF into the notes & attachment of my current object. Everything works fine, I'm able to get the base 64 encoding of the PDF, convert it and save as the file.
Now from what I have understood, when uploading a PDF manually, Salesforce operates on it, being then able to preview it directly on the website. This does not happen with my programmatically created PDF.
Any idea on how to force Salesforce to load the preview by code? I have already found that the user can force reload the preview, but what I want is to create the preview with my files.
The code currently looks like this:
String test = webserviceOut.SI_Quotation_Out('0020015480'); //Blob txtBlob = Blob.valueOf(test); //Convert it to a blob Blob txtBlob = EncodingUtil.base64Decode(test); Attachment attach = new Attachment(); //Make an attachment attach.Name ='text.pdf'; attach.Body = txtBlob; attach.ContentType= 'application/pdf'; //Signal what the file's MIME type is attach.ParentID = id; insert attach;
Edit1: To show what the actual difference is, prova is a PDF loaded by the UI of salesforce, while text.pdf is one generated by my code.
Now when I click on prova I'm able to load the preview, while clicking of text I'm not.