I'm working on a website with my friend who's in charge of the front-end using React, while I handle the back-end with ASP.NET Core. We want to implement a 'download report' button at the bottom of a relatively short page (about 3-4 scrolls on mobile). I've heard that using third-party libraries like IronPdf or DinkToPdf for server-side rendering might be necessary, but it seems like a hassle since my friend already coded the .jsx components on the client side. Any suggestions on how to approach this?
4 Answers
If your report generation doesn't have to happen in the backend, it’s much simpler to handle this on the frontend. I've done similar setups in React using the 'react-to-print' package, which is pretty seamless.
There’s a specific HTML subset for print formatting that can help out. You have a few options: 1) Print the page directly (but expect some variability in output), 2) Design a tailored HTML print template, or 3) Use server-side libraries to generate the PDF, but that can get complicated.
I hear you! The output can be so inconsistent depending on the setup.
You can either trigger the browser’s native print function and style for print, or take the server-side route if you need custom PDF generation. Just be cautious, as complex templates can complicate things.
You could just use the browser’s print function to handle this. It’s simple and cost-effective, although the PDF output can vary based on user setups. Just keep in mind that it might not be perfect, but it’s worth a shot!
Exactly! No need for backend processing unless absolutely necessary.