In my application there is search form. Results of the search are paginated in back-end and sometimes search may have thousands of results. There is a feature request to enable exporting search results in PDF format. Is it OK to convert search results in front-end or should I convert search results in back-end. Note that I may have to change the PDF template many times in the future and template is not necessarily permanent.
-
2In my opinion it should be Back-End – seenukarthi Feb 03 '20 at 06:41
-
1To extend on @KarthikeyanVaithilingam 's comment: If one does the export functionality in the frontend, a user could forge a search-result PDF by adding or removing data before export. – Turing85 Feb 03 '20 at 06:43
-
1Same here, you should do this kind of stuff in the backend – R.Groote Feb 03 '20 at 06:43
1 Answers
In my opinion, it should happen in the backend. The reasons are :
Let's say, you are having 1M records in your DB and you want to search for a particular column's data. In this case, pulling all the results in front-end and applying search over it is a bad option because you are transferring a lot of data in over the network.
Keeping it in the backend also provides you the flexibility of using multiple engines such as iText, Jasper, PD4ML for PDF rendering and export. These engines are very much popular and have good community support.
Using Jasper also enables to have multiple JRXML files for multiple templates which can be changed at runtime and all you have to use a single PDFExportManager to export it.
Other than that, if you want to have password-protected pdfs, you might not want to keep the key in your frontend. Keeping it in backend,DB is always a good option.

- 131
- 3
- 14
-
Thanks for your response, ofcourse I do not do search action in frontend if I decide to export pdf in front-end and just send result of search to front-end. But you have some good reasons to not exporting in front-end I think this is not a good idea to create pdf in front-end. – SRF Feb 03 '20 at 06:56
-
1
-
1I would also suggest you to keep the generated PDFs to S3/CDN and pass the public URL as a response from the backend. In frontend again you can render the PDF from the URL. You can also check about content-disposition for files which will enable/disable the download/view functionlity for PDFs. – theNextBigThing Feb 03 '20 at 07:08