I'm working on a website with a friend where he's handling the front-end using React while I manage the backend with ASP.NET Core. We want to implement a button at the bottom of a page that allows users to download the report as a PDF. The page isn't very long, probably only requiring about 3-4 scrolls on mobile. I've heard that if I choose to do this on the server, I'd need to rewrite an HTML template and possibly rely on third-party libraries like IronPdf or DinkToPdf, but I'd prefer not to complicate things since my friend has already created the JSX on the client side. What's the best way to make this happen?
2 Answers
You might want to just use the browser's print function. It's not perfect, but it could save you a lot of trouble that comes with PDF rendering libraries. With CSS for print, it can be a pretty straightforward solution.
Consider using a dedicated HTML print template for better results. The process generally involves designing your print styles and then either triggering the print from the browser or using a server-side solution if you want control over emailing reports. Getting it right on the frontend might actually be easier.
So mainly just using `window.print()` sounds easiest for my case since we're keeping it on-demand?