function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Natraj Subramani 15Natraj Subramani 15 

Lightning Custom Button (With Visualforce Page rendered as PDF) Not Working

Hi All,

We have a custom button (part of case detail page) with visualforce override (VF page has been rendered as PDF). This button works perfectly fine in classic. I can see the pdf generated.

In Salesforce lightning, this is throwing an error. "An internal server error has occurred. An error has occurred while processing your request. The support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience."

When I inspect the page and see I see this error "Failed to execute 'postMessage' on 'DOMWindow': The target origin provided " . Debug logs also not showing any errors.

Any idea why this button is not working in lightning ?


Raj VakatiRaj Vakati
Make sure your visualforce page is avaibale in lightning experience .. 
Go to visualforce page "
Available for Lightning Experience, Lightning Communities, and the mobile app" check this checkbox 
Natraj Subramani 15Natraj Subramani 15
Hi Raj,

Thank you !!! Thats already checked. Not sure why page is not loading.

Tarun Kaushik 11Tarun Kaushik 11

Hi Natraj
I am also getting the same issue, Did you able to find the solution/reason for the same.?


Natraj Subramani 15Natraj Subramani 15
Hi Tarun,

Yes I got it working, please set lightningStylesheets="false" and try to access the page in lighting. Salesforce support confirmed that VF pages rendered as pdf cannot have this as true. Please do share your findings.