7

In my Apex page we want to show the preview for the SalesForce documents?

We want to have preview for the following file types?

Supported file types:

MSWord, MSExcel, PDF and PPT.

Is the any we can use SF visual components or API to achieve this.

Please advise.

4
  • 1
    Are you trying to "preview" as Salesforce does wherein you have a popup with the preview? Or are you simply trying to display a document within a visualforce page? Oct 16, 2013 at 18:58
  • 1
    I just want to preview the document so whichever is feasible I'm good with that. Now i can able to preview the PDF files but it occupies the entire screen. So preview as a popup or VisualForce page with headers is good.
    – Dinesh
    Oct 17, 2013 at 6:39
  • Have you investigated Accusoft's document viewer for salesforce? Jan 7, 2014 at 22:26
  • Anyone got answer for this?
    – unidha
    May 31, 2017 at 7:23

2 Answers 2

4

There are quite a few "document previewers" out there.

The one I would use is this the google docs viewer. You can use the link below to get the URL format you'd need for the file, and then I'd embed that in a visualforce page using <apex:iframe>

https://docs.google.com/viewer

Other options include flexpaper or issu

http://flexpaper.devaldi.com/default.jsp http://issuu.com

Another easier option which works well is to just use a simple embed tag with src= url of your file which if its an attachment can use the following syntax

<embed src="{!URLFOR($Action.Attachment.Download, worksheet.Attachments[0].Id)}" style="width:100%; height:950px;">
 </embed>
4
  • That is possible for normal documents but is it possible to view the documents that has been published under SalesForce library using google docs viewer?
    – Dinesh
    Oct 17, 2013 at 15:31
  • Hmm well those files are only viewable internally so google can see them but for those i'd used a simple embed tag eg. <embed src="{!URLFOR($Action.Attachment.Download, worksheet.Attachments[0].Id)}" style="width:100%; height:950px;"> </embed> Oct 19, 2013 at 15:36
  • It' Perfectly working for pdf files. But the docx files got downloaded instead of showing preview.
    – Dinesh
    Oct 20, 2013 at 11:30
  • 1
    Hmm yea thats going to be harder with the Microsoft file formats. The only real solutions i've found for those are the google docs view or the office 365 viewer but both of those require the documents to have a publicly accessible URL. If thats not possible then you may have to use a flash based option like flexpaper (flexpaper.devaldi.com/demo) i haven't used it personally but i think it will do what you need? You can see a similar question chain here: stackoverflow.com/questions/8558936/… Oct 20, 2013 at 15:18
0

Are you referring to the cool native Sales force document preview feature and are trying to use it in a custom Visualforce page?

I think to the best of my knowledge, there is no direct way to do this.

Please see: https://success.salesforce.com/ideaView?id=08730000000Y1QLAA0

This person had a solution to this. The link seems to be down for now. I hope its a temporary issue. http://softwarecycling.com/post/10847679195/salesforce-showfilepreview

1
  • The link seem to be down in 2017
    – unidha
    May 31, 2017 at 7:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .