You need to sign in to do that
Don't have an account?
Revathy2690
Is there a way to View attachment body inside a visualforce page
Hi All,
I am uploading documents into Attachment object and keeping a custom object as parent. I want to show the attachment content inside the visualforce page .
Below is part of my code. But in the page content is not getting displayed, it's blank
Page:
<apex:pageBlockSection title="Resume" id="Resume" >
<apex:iframe src="/servlet/servlet.FileDownload—file={!resume.id}"/>
</apex:pageBlockSection>
Controller:
public Attachment resume{ get; set;}
resume=[select Id,Body,ContentType,Name from Attachment where ParentId =: currentRecordId];
Can anyone please advice on this ?
Thanks in advance
I am uploading documents into Attachment object and keeping a custom object as parent. I want to show the attachment content inside the visualforce page .
Below is part of my code. But in the page content is not getting displayed, it's blank
Page:
<apex:pageBlockSection title="Resume" id="Resume" >
<apex:iframe src="/servlet/servlet.FileDownload—file={!resume.id}"/>
</apex:pageBlockSection>
Controller:
public Attachment resume{ get; set;}
resume=[select Id,Body,ContentType,Name from Attachment where ParentId =: currentRecordId];
Can anyone please advice on this ?
Thanks in advance
Please use below code in your visualforce. Let us know if it helps you.
Thanks for helping. I tried that already attachment is not loading. And the attachment I am trying to show is word doc.
maybe you have problems with the property definitions in your controller. I've used following code in order to verify the solution:
Property definition in controller (assuming that account has one attachment): Display of pdf doc in iframe as per your requirement:
I hope this helps :)
I tried this, on loading the page it is prompting to download the document. Except for word document code is working as expected.
but what I want is to show the content of word document like a preview :(
it's not possible to display word doc in iframe in a way you have this for pdf docs. You will be always prompted to do download the file. You should consider usage of some 3rd party javascript code in order to display the file.
Cheers!