• nvgogh
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies

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

 

 

Hi,

 

I'm calling into a 3rd party API from Salesforce using the APEX WSDL wrapper. That 3rd party API provides access to pdf documents as blobs. I'm able to use APEX to access those PDFs and send them on as e-mail messages (using Messaging.SingleEmailMessage and Messaging.EmailFileAttachment) from salesforce. Works great.

 

However, I would like to also render that PDF in a VisualForce page (it can either render in the page or provide a popup asking the user if they want to save or open the PDF). I see lots of info on how to render existing Salesforce content in PDF but nothing about how you could do this if you already have the PDF in a blob lets say.

 

I would think it would be something like:

 

<apex:page contenttype="application/pdf">

<apex:outputText value="{!PDFBlob}" id="thePDFBlob"/>

</apex:page>

 

(where i can provide the blob in the controller) but outputText is not the correct component.)

 

Anyone have any ideas?

 

Thanks,

-John