可以在前端将数据导出为 pdf 格式吗? [英] Is it ok to export data as pdf format in frontend?

查看:55
本文介绍了可以在前端将数据导出为 pdf 格式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中有搜索表单.搜索结果在后端分页,有时搜索可能有数千个结果.有一个功能请求可以以 PDF 格式导出搜索结果.可以在前端转换搜索结果还是应该在后端转换搜索结果.请注意,我将来可能需要多次更改 PDF 模板,并且模板不一定是永久的.

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.

推荐答案

在我看来,它应该发生在后端.原因是:

In my opinion, it should happen in the backend. The reasons are :

假设您的数据库中有 100 万条记录,并且您想要搜索特定列的数据.在这种情况下,在前端提取所有结果并对其应用搜索是一个糟糕的选择,因为您要通过网络传输大量数据.

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.

将其保留在后端还为您提供了使用多个引擎(例如 iText、Jasper、PD4ML)进行 PDF 渲染和导出的灵活性.这些引擎非常受欢迎,并且拥有良好的社区支持.

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.

使用 Jasper 还可以为多个模板提供多个 JRXML 文件,这些文件可以在运行时更改,您只需使用单个 PDFExportManager 即可将其导出.

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.

除此之外,如果您想拥有受密码保护的 pdf,您可能不想将密钥保留在前端.将其保留在后端,DB 始终是一个不错的选择.

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.

这篇关于可以在前端将数据导出为 pdf 格式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆