2016-08-23 32 views
0

我正面临着使用iframe或其他替代方法下载/呈现Visualforce页面中的blob响应的问题。但我对他们中的任何一个都没有运气。任何人都可以建议在Visualforce页面中将blob响应呈现/下载为PDF格式。将blob响应和解析为字符串,如下所示。在Salesforce的Visualforce页面中显示/下载Web服务响应(blob)

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

下面是visualforce代码:

  <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> 
+0

看起来正确。请查看以下示例:https://help.salesforce.com/apex/HTViewSolution?id = 000044612&language = en_US 请注意,某些浏览器(例如IE8)不支持此功能。我们问到,没有办法做到这一点。 – Egor

回答

0

而不是EncodingUtil.Base64Encode(pdfContent)尝试Blob.toPDF(pdfContent)

相关问题