2
votes

I am facing the issue to download/render the blob response in visualforce page with iframe or other alternatives. But i have no luck with any of them. Can any one suggest on this to render/download the blob response as pdf in visualforce page.Got the blob response and parsed it to String as below.

    HttpResponse res = http.send(r);
    pdfContent = res.getBodyAsBlob();  //Blob property
    pdf = EncodingUtil.Base64Encode(pdfContent);//String property

Below is the visualforce code:

         <apex:page doctype="html-5.0" controller="ViewDocument" id="thePage" >

        <apex:outputPanel id="benefit" rendered="{!showDocument}">

            <iframe src="data:application/pdf;base64,{!pdf}"  id="theFrame1" width="0%" height ="0%" border="0" scrolling="no" frameborder="0"/>

    </apex:outputPanel>

    </apex:page>
1
That looks about right. Check this for an example:help.salesforce.com/apex/… Note that this isn't supported in some browsers, like IE8 for sure. There's no way to do this in those, we asked. - Egor
@Egor I am getting same issue ... IS there any workaround for this ? I am getting "Failed to load PDF document." - Aakriti.G
Can you suggest/Post the solution for the above issue? Couldn't render PDF blob as data in VF page - User

1 Answers

0
votes

Instead of EncodingUtil.Base64Encode(pdfContent) try Blob.toPDF(pdfContent).