MatthewHerbst / react-to-print

Print React components in the browser. Supports Chrome, Safari, Firefox and EDGE
MIT License
2.06k stars 221 forks source link

Blank PDF when trying to generate in production. #700

Closed RogerKobs closed 5 months ago

RogerKobs commented 5 months ago

Hello everyone, so, I'm creating a project using ViteJS and Mui (Material UI). All my components are using MUI, except for places that use Grids, because for some reason it wasn't working to generate PDFs. My problem occurs when I generate a PDF, locally, it works correctly, it generates the file, breaks the pages as needed, generates the header on all pages, and so on. The problem itself starts when I build the project with Vite and upload it to a hosted server, from there the PDF is blank, the content exists because it breaks the pages correctly, but it doesn't display anything. I did a test and passed the property copyStyles as false, then it worked to generate, I don't know which direction to go anymore, I've read several issues and none solved my problem, I appreciate it in advance.

Localhost: image

Production: image

MatthewHerbst commented 5 months ago

Hello. Hard to debug anything with access to code. Sounds like your prod and dev builds and very different though. Do you know what your prod build is doing to your styles that your dev build isn't doing, or vice versa?

RogerKobs commented 5 months ago

Hello everyone, so, I found out that the error was in the project that loaded my bundle. There was some CSS there that was overriding all the values of the iframe. If this helps anyone, try this possibility.