We are going to use iText to create a large report. There will be a lot of static text and images that will be the same for every report. We will then insert dynamic data from a database into the report. The static data and the dynamic data will be mixed together when the report is finished. What is the best way to handle the static data. We are going to use a java servlet in a web application for the creation of the report. We want the report to be sent to the web page immediately, so performance is critical.
我们将使用iText创建一个大型报告。每个报告都会有很多静态文本和图像相同。然后,我们将数据库中的动态数据插入到报告中。报告完成后,静态数据和动态数据将混合在一起。处理静态数据的最佳方法是什么。我们将在Web应用程序中使用java servlet来创建报告。我们希望立即将报告发送到网页,因此性能至关重要。
These are some of the ideas I had. Not sure if any of these are good ideas.
这些是我的一些想法。不确定这些是否是好主意。
1.) Create a PDF with the static content then insert the dynamic data. If I go this way how would I know where to insert the dynamic data? Is it possible to bookmark place to insert data?
1.)使用静态内容创建PDF,然后插入动态数据。如果我这样走,我怎么知道在哪里插入动态数据?是否可以为插入数据添加书签?
2.) Get the static data from a database. This seems like it would be difficult trying to design a database with static content that would have to consider things like pages, paragraphs, headings, images. I would also think that this would not be great for performance if the website gets hit hard.
2.)从数据库中获取静态数据。这似乎很难尝试设计具有静态内容的数据库,这些内容必须考虑页面,段落,标题,图像等内容。如果网站受到重创,我还会认为这对于性能来说并不是很好。
3.) Cache the static content in the servlet context. This would seem to help performance but would still have the same design issues as the database.
3.)在servlet上下文中缓存静态内容。这似乎有助于提高性能,但仍然会遇到与数据库相同的设计问题。
I would love some opinions on the best way to store large amounts of static text when creatig a PDF using iText.
在使用iText创建PDF时,我会喜欢一些关于存储大量静态文本的最佳方法的意见。
Thanks for your help Doug
谢谢你的帮助道格
1 个解决方案
#1
0
I am not sure if the best way to do it, but this worked well for me in a similar situation, I created a template file that I read into code, and in the template I had hash tagged variable holders that I used to find a location and replace with dynamic text from whatever source. For example:
我不确定是否有最好的方法,但这对我来说在类似的情况下运行良好,我创建了一个模板文件,我读入代码,并在模板中我有哈希标记变量持有人,我曾经找到一个位置并替换来自任何来源的动态文本。例如:
Hello #CUSTOMER_NAME#, Thank you for the purchase of #RECENT_PURCHASES# on
#RECEIPT_DATE#, for a total value of #RECEIPT_TOTAL#. ...
Like I said, it probably isn't ideal, but it really well for my needs.
就像我说的那样,它可能并不理想,但它确实适合我的需求。
#1
0
I am not sure if the best way to do it, but this worked well for me in a similar situation, I created a template file that I read into code, and in the template I had hash tagged variable holders that I used to find a location and replace with dynamic text from whatever source. For example:
我不确定是否有最好的方法,但这对我来说在类似的情况下运行良好,我创建了一个模板文件,我读入代码,并在模板中我有哈希标记变量持有人,我曾经找到一个位置并替换来自任何来源的动态文本。例如:
Hello #CUSTOMER_NAME#, Thank you for the purchase of #RECENT_PURCHASES# on
#RECEIPT_DATE#, for a total value of #RECEIPT_TOTAL#. ...
Like I said, it probably isn't ideal, but it really well for my needs.
就像我说的那样,它可能并不理想,但它确实适合我的需求。