function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

render external pdf/blob in visualforce page



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"/>



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


Anyone have any ideas?






Hmmm, not quite sure how to do this exactly but one option may be to insert the blob as an attachement in salesforce and then you could display it in the page.
try to convert  by using  .tostring() to string then display it .



Did you find a solution to this?


I would like to do the same




Hey everyone!


Any solution yet (other than saving as an attachment)???  Need this real bad!




This is big problem, Please fix this salesforce!!!


I had the same issue trying to send a PDF via a webservice to APEX then render a VF page as PDF never found solution.


And now I have a VF page I want to render as PDF and save externally and this does not work either:


PageReference pr = new PageReference('/apex/mypage');
Blob pdf = pr.getContentAsPDF()

// code to send PDF to external site.


This code results in a Blank PDF no data in it due to String encoding issues.

I would really like to see string encoding handeled correctly and also allow for HttpRequest   setBody to allow a Blob instead of only strings



Someone please give us a hand here!


I also need to programmatically (Apex) select a PDF file in either documents or static resources and display the PDF file in a pop up window.  This way the user can keep the PDF open to email, print, etc. while they continue working.  The PDF file would be an actual file I would upload to Document or StaticResources.


The Apex code to do this would be in a class method called from a page controller extension class method. 


The app is based on, it doesn't use the SF CRM objects.






Any updates?  Is there a post on Ideas that I should vote up?


Did anyone found any solution / work around / best way to do this?

I'm also facing the same issue.




Did anyone found a solution to this one?