3

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?

4
  • I think it has to do with broken CSP support in IE 11. Can you try it in IE Edge?
    – sfdcfox
    Feb 8, 2017 at 18:59
  • I just tried in Edge and it didn't work there either.
    – mplax
    Feb 8, 2017 at 19:06
  • What do you mean when you say that it shows while you change src?
    – Raul
    Feb 8, 2017 at 19:42
  • @RahulSharma the iFrame shows example.com as if I had navigated directly to that website (and works consistently across browsers).
    – mplax
    Feb 8, 2017 at 19:48

1 Answer 1

1

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)

1
  • Unfortunately, this does seem to be the case. And I can't use the Page.PageName solution you provided, so I'll have to figure out another workaround. Thanks!
    – mplax
    Feb 10, 2017 at 17:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .