Should I dynamically recreate a PDF file and not store it in a database or file system?

I need clients to be able to upload PDF files of emails that were sent to them.

I read the threads about storing documents or images in a database and file system, and it seems like the consensus is that for something bigger than just a few images, the file system is the way to go.

What I want to know:

  • would it be a reasonable alternative to just store the letter data in a database and recreate the pdf on the fly when it is requested?
  • Is this approach superior or inferior to extracting PDF from the file system?
+6
c # sql-server-2005 itext
source share
8 answers

I would save it for two reasons.

1) If you ever change the way you create a PDF file, you probably don't want the historical elements to change. If you generate them every time, either they will change, or you need to save the compatibility code to create "old style" entries

2) Disk space is cheap. There is no user patience. If you didn’t actually click to store or pull from the repository, it’s more difficult than generating a PDF file, be kind to your users and save it.

Obviously, if you create thousands of them per hour from a rare dataset, you may not have storage. But if you have a place, I would vote for "use it"

+3
source share

If this is for archival purposes, I would definitely save the PDF, because in the future your generation of PDF script may change, and then the letter will not be exactly the same as what was originally sent. The customer will expect it to be exactly the same.

No matter which approach is superior, it is sometimes better to look for which approach is safer.

+9
source share

Is there a reason for the forensic examination, why should you keep a record of letters sent to clients? If you are going to update on the fly, as you know, future code changes will not rewrite the letter (or at least the client can make this argument in court if the information is used in a lawsuit) ...

+2
source share

I tend to say "it depends."

When one document is requested many times, it can be a savings if you compile it at the first request and pull it out subsequently.

OTOH, if most of the queries for a document are of type only once, and the creation process does not absorb most of your server volume, "on the fly" will have a clear advantage.

0
source share

If you are using ASP.NET, why not cache the PDF. Your cache can be stored in the database if you like or left in memory as much as you may need in the first place. the corporate library implements this for you in the caching application block and is remarkably easy to use. If you cache an object, create a repository in the database using a block, and then load it when you need it, you do not have to worry about re-creating it.

0
source share

A few things to consider are PDF generation based on data that existed at a particular point in time. EG. bill based on data from the previous month?

If so, will you use the same template every month to create this letter? What will happen if / when the format of the letter changes, if you regenerate on the fly, this is not what was sent to them. Is it possible to save a PDF stream in a database?

I assume that I get, do you need an accurate idea of ​​what was sent to the user, or is it flexible?

0
source share

The question of whether to generate pdf files dynamically or to store them statically is more like a question of law than a question of programming.

If you do not have access to a legal adviser who can provide guidance on this issue, then it will be much safer to err on the side of caution and store them statically.

0
source share

As long as the PDF document is permanent (not just a working document, but something official, signed and sent somewhere else in the company or outside the company), you should have a copy of this PDF file on your network and a link to this file in your database.

You cannot rely on the available data to play the same document at a different time, mainly because:

  • Data can be changed (yes! Suppose that the letter is allowed to be signed by the head of the department, and the staff has changed?)
  • The format of your report will change (header, footer, logo, etc.)
  • The document you created is stored by someone else who will use the data available in the document.
0
source share

All Articles