Search code examples
javascripthtmlreactjsreact-hooksreact-to-print

Downloading to PDF or Preview and Save to PDF/Print using React


I need to know whats the better options between the two:

1st - I call backend to get the JSON response from it and use react-to-print package to preview and save to PDF/Print.

2nd - I call backend to get the JSON response from it and convert and download to PDF in frontend.

My problem with the 1st one if I have huge data, the browser lags for a long time. My question is, will the 2nd one be the same.

I know the best option would be the backend will be the one to convert to PDF - this is the 3rd option. I'm just asking if the 2nd is better than the 1st?


Solution

  • In case both of it are force the browser to lags in my opinion the choise should be less evil. I think they won't have huge difference between. I'd follow the third way, just return pdf from the back-end.