I had a VF Page on a Detail Page Button created on a custom object.
On button click, the vf page is downloaded as pdf file as expected.
In lightning experince, after the file is downloaded, the UI is not staying on the detail record page. It works fine in classic experince.
One of the solution I tried below,
<apex:page standardController="customobject" extensions="customController" showHeader="false"
renderAs="PDF"
cache="true" >
<apex:form id="form" >
.. add pdf content here.
.
.
.
.
.
<apex:actionFunction name="redirect" action="{!redirectToRec}"/>
<script>
searchAccRecs()
</script>
</apex:form>
</apex:page>
I called the script at the end to have redirect after the pdf attachment is formed. I dont see the apex method being called with the above approach.
Please let me know if there are any other approaches.