You need to sign in to do that
Don't have an account?
Opening documents
Oke I have been toying around with this the whole day and I don't seem to get it working ... and it frustrates me.
I want to open the documents which are in the document table, this is a test for some future development.
So I developed a apex class/controller class
public class AttachmentOpener { public String attachment {get; set;} public String contenttype {get; set;} public String filetype {get; set;} public AttachmentOpener () { Document doc = [Select d.Body, d.ContentType, d.Type From Document d where d.type='xls']; contenttype = doc.ContentType; filetype = doc.Type; Blob b = doc.Body; attachment = b.ToString(); } }
And an visual force page
<apex:page showHeader="false" cache="true" Controller="AttachmentOpener" contenttype="{!contenttype}#test.{!filetype}"> <apex:OutputText escape="false" value="{!attachment}" /> </apex:page>
When I open the page Firefox askes me to open or save the attachment (with the correct contenttype), so that all goes according to the way it should.
However the content of the file looks all wrong. For text files it works, but when they have more complex content like pdf, excel or word it doesn't work.
For instance a pdf does show me the correct number of pages (like 4) but no content (alle pages are blank). The document is correct since salesforce it able to show it to me using the standard functionality.
I have the feeling that it has to be something to do with (en)coding but I fail to find a reference as to what to do.
So can anybody give a clue to look for next?
Thnx
Natalie
Here and there I see the discussion on this subject but apparently everybody hit a dead-end on this???
Is there another way to do this?
I want to do a simular thing as this user is asking
http://community.salesforce.com/sforce/board/message?board.id=Visualforce&thread.id=17522