You need to sign in to do that
Don't have an account?
vicky rathi
show Doc content on vf page
I am new in Salesforce. I want to show the Doc content on my vf page . I am able to show the PDF and Txt Content on the same page
but when try to show the doc content its download or its show the cript formate.
page code
<!-- <apex:iframe frameborder="true" src="https://c.cs24.content.force.com/servlet/servlet.FileDownload?file={!pdf}" scrolling="true" id="theIframe" width="470px" height="250px"></apex:iframe> -->
<apex:iframe frameborder="true" src="data:{!att.ContentType};base64,{!pdf}" scrolling="true" id="theIframe" width="470px" height="250px"></apex:iframe>
controller code
public Document att {
get {
if (att == null) {
att = [SELECT Id,Body, ContentType, Name FROM Document WHERE Name =: 'vcc credential data'];
}
return att;
}
private set;
}
public String pdf {
get {
List<Attachment> attch = [Select Id,Body, contentType, name from Attachment where parentId =: AccountIdStr and Name='vcc credential data2.docx'];
// Blob file = attch[0].body;
system.debug('.......attch.........'+attch);
if(attch!=Null && attch.Size()>0)
return EncodingUtil.Base64Encode(attch[0].body);
// return attch[0].Id;
else return EncodingUtil.Base64Encode(att.body);
// return att.Id;
}
Any One guide me how to show the doc content on vf page
but when try to show the doc content its download or its show the cript formate.
page code
<!-- <apex:iframe frameborder="true" src="https://c.cs24.content.force.com/servlet/servlet.FileDownload?file={!pdf}" scrolling="true" id="theIframe" width="470px" height="250px"></apex:iframe> -->
<apex:iframe frameborder="true" src="data:{!att.ContentType};base64,{!pdf}" scrolling="true" id="theIframe" width="470px" height="250px"></apex:iframe>
controller code
public Document att {
get {
if (att == null) {
att = [SELECT Id,Body, ContentType, Name FROM Document WHERE Name =: 'vcc credential data'];
}
return att;
}
private set;
}
public String pdf {
get {
List<Attachment> attch = [Select Id,Body, contentType, name from Attachment where parentId =: AccountIdStr and Name='vcc credential data2.docx'];
// Blob file = attch[0].body;
system.debug('.......attch.........'+attch);
if(attch!=Null && attch.Size()>0)
return EncodingUtil.Base64Encode(attch[0].body);
// return attch[0].Id;
else return EncodingUtil.Base64Encode(att.body);
// return att.Id;
}
Any One guide me how to show the doc content on vf page
- Upoload the PDF file in to static Resources.
- open the file from Static Resources and take the URL.
- Pass the URL in to "src="https://c.ap2.visual.force.com/resource/1474956238000/pdf"
I have tried this, it works fine for me.Code I have used:
@Naveen Dhanaraj
I want to show the word content only from attachment account related not a pdf file .
PDF and TXT file showing in the vf but my requirement is show doc content
Thanks
I am upload a doc file in attachment and want to show in my vf page using the <iframe > tag.
doc file not showing on the vf page its downloaded or show unreadable format.
I am upload the txt file and pdf file thats file showing on page .
My question is how to show the doc file on vf page (its a client requirement )
View all your Attachment in Visualforce page---->http://blog.giovannimodica.com/post/showing-image-attachments-in-a-visualforce-page
http://salesforcekings.blogspot.in/2013/11/view-all-your-attachment-in-visualforce.html