[SalesForce] Internet Explorer 11 iFrame PDF Compatibility

I have a PDF that is being shown through an iFrame that works as expected on Chrome and Firefox, but is just showing a blank page with IE11.

Here is the entire visualforce page for the iFrame:

<apex:page controller="MyControl" showHeader="false" sidebar="false">
    <apex:iframe id="frame" src="{!pageRefPDF}"/>

    <script>
        document.getElementById('frame').height = window.innerHeight;
    </script>
</apex:page>

And here is the code that creates that pageRefPDF string:

PageReference ref = new PageReference('/apex/OutputPDF?id=' + accountId);
Blob contentData;
if (Test.isRunningTest()){
    contentData = Blob.valueOf('pdfBody');
} else {
    try{
        ContentData = ref.getContent();
        pageRefPDF = 'data:application/pdf;base64,' + EncodingUtil.base64Encode(contentData);
        } <catch code follows>

And a bit further below there is a line that returns a new PageReference of the first block above.

It shows if I change the src to "https://example.com", but there are no errors in the IE console, I have tried on multiple computers (different networks), changed some of the IE security settings, and added the domain to the trusted sites list. Any ideas about what might be causing this in IE but not other browsers?

Best Answer

We had faced some similar issue 2 years back and had to support PDF display in almighty Internet explorer version 9. It didn't work what-so-ever.

Eventually, we had used URL of VF page rendered as PDF in src instead of data URI:

<apex:iframe src="{!$Page.PageName}?Id=recordId"/>

From Microsoft's documentation:

Data URIs are supported only for the following elements and/or attributes:

  • object (images only)

  • img

  • input type=image

  • link

  • CSS (declarations that accept a URL, such as background, backgroundImage, and so on)

Related Topic