0

I am using Salesforce Lightning I want to open a PDF in new tab.

HYPERLINK('/apex/myapexpage?param='+some_param,'View', '_blank')

The page is still opening in the same Visualforce Page, not in new tab. I know it can be done through javascript as:

<apex:page controller="ViewPDF" showHeader="false" sidebar="false">
    <!--object data="data:application/pdf;base64,{!match1}" width="100%" height="500px"></object-->
    <script>
        let pdfWindow = window.open("")
        pdfWindow.document.write('<object data="data:application/pdf;base64,{!match1}" width="100%" height="100%"></object>');
    </script>
</apex:page>

It opens the PDF in new tab, but make the existing page blank.

Is there a way by which the PDF opens in a new tab without affecting the existing page?

1 Answer 1

0

Check critical updates for 'Lightning Experience Honors Target Values for Hyperlinks in Formula Fields'

enter image description here

Also you should use <apex:page renderAs="pdf"> instead of your JS approach.

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_renderas_pdf.htm

1
  • 1
    Thanks!, but renderAs="pdf" displays base64 encoded string as PDF, not the actual content.
    – Aditya
    May 8, 2020 at 8:25

You must log in to answer this question.

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