You need to sign in to do that
Don't have an account?

Any one know ways to diplay Attachment in Visualforce page
Hi there,
I Save my email attachment(a smal pdf file) into the attachment object, now i want to display the attachment body in my VisualForce Page,
<apex: outputfield value="{!Attachment.Body}" /> Not works coz it is base64 field...
any way to display the pdf file in my page? any code example of that, like 's-control' or something
Thanks in advance
Message Edited by Feng on 05-25-2008 05:09 PM
You could also leverage <object> and <embed> like this (each approach has pros/cons)
or even better - create your own custom component to encapsulate the ugly bits (NOTE: you'll need to be using Summer '08 for this specific component to work (there is a bug in Spring '08 that will block you)):
then your page just contains
Message Edited by dchasman on 05-26-2008 09:23 AM
All Answers
You could also leverage <object> and <embed> like this (each approach has pros/cons)
or even better - create your own custom component to encapsulate the ugly bits (NOTE: you'll need to be using Summer '08 for this specific component to work (there is a bug in Spring '08 that will block you)):
then your page just contains
Message Edited by dchasman on 05-26-2008 09:23 AM
Hi DChasman,
I tried another method to display the attachment related to my custom object on a VF screen.
<apex:outputLink onclick="window.open('https://cs2.salesforce.com/servlet/servlet.FileDownload?file={!act.CostAttachmentId}','Attachments');" rendered="{!IF(act.CostAttachmentId <> null,true,false)}"> View</apex:outputLink>
Its running fine in Mozilla(FireFox) but somehow, in IE the link of the main VF page gets broken when this new window is opened.
I have no clue as to why is this happening :(
Can you please help me out??
Thanks,
Cool_D
Great, this is exactly what I was looking for.
Unfortunately while trying out, it gives me just white space in Safari and Chrome. In Firefox, it says "plugin not supported". Any idea?
Sir,
Please help me to display an attachment on Visualforce page..
Wow. I was about to post about this. Thanks.
This was a while ago, but I had the same problem and solved it by doing like this:
This way it will work both in Chrome, FF and IE.
// Niklas
Have anyone tried of displaying a pdf file in vf page without saving as an attachment in salesforce. I need to display a response which comes in the base64 format.
Hello,
I have the same problem and need help.
I got file in xml respose from web service and have base64 type:
Folder fldr = newFolder();
fldr = [select id fromFolderwhereName = 'Temporary'limit 1][0];
Document currDoc = newDocument();
currDoc.AuthorId = UserInfo.getUserId();
currDoc.Body = Blob.valueOf(doc.Document.File);
currDoc.Name = DocumentID;
currDoc.FolderId = fldr.Id;
currDoc.ContentType ='application/pdf';
insert currDoc;
PageReference page = new PageReference('/servlet/servlet.FileDownload?file=' + currDoc.Id);
I see new file in GUI but when I try to open it I got error "System can't read pdf file' or so.
Thanks for any advice.
And finally I found what I did wrong (should be):
currDoc.Body = EncodingUtil.base64Decode(doc.Document.File);
the link mentioned in above answers doesnt work now.
it downloads the attached file in a unknown format without extension.
i am talking aboutthe below link