It seems LWC doesn't have a standard way to convert an app/page to PDF. I've tried using VFP w/LWC in it via lightning out, as per here:

Using LWC in VFP

But that doesn't make the LWC content available for the VFP's renderAsPdf() behavior. I was able to get a PDF, but it was always blank.

Alternatively, I've grabbed the HTML from my LWC app in the chrome dev tools and stuffed that into a string to send to the Blob.toPdf( str ). That throws an endless supply of errors while parsing the string however. Simpler strings with proper HTML worked fine however.

Is there a way to get HTML from the LWC rendered in the browser so I can send that to Blob.toPdf()?It seems like that's not possible. The only other options I'm aware of are to write Apex to generate the HTML string manually, or a VFP that accepts data and renders itself as a PDF.

1 Answer 1


It seems the answer is don't try to do this since the PDF renderer won't likely understand the CSS anyway. I've abandoned all hope here and have resigned myself to creating a second layout VFP strictly for PDF generation. It's clumsy and annoying but it seems to work as long as you keep the css simple and at the level it can understand (2.1 or less).

I really hope this is something that Salesforce fixes soon. There was a pilot program at one point to improve PDF generation, and make it lightning component aware, but it was cancelled without much information about future plans.

You must log in to answer this question.

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