How to store PDF documents?

Hi,

We are working on a project that requires storing PDF documents in the same folder the bounded context lies. Are there any recommended Dolittle packages that support this?

Some context:
The bounded context’s responsibility is to receive data, generate monthly reports, and store it (same folder) before the end of each month.

Storing files directly on the server where the Dolittle bounded-context runs is not what I’d usually recommend. That is, assuming you’re running in our hosted environment. If you’re running it on your own hardware or some other setup your setting may be different.

The bounded-context is an application that runs in a docker container. This docker container is a docker image, and the state that has been made since it was started. There is usually no direct guarantee that the container will be stored - i.e. the container may go away and a new one will be set up from the docker image. This means that any files you store where your bounded context runs may not be persisted.

To persist files I recommend sending them to something that will guarantee persistence (like Azure Blob Storage or similar).

If you want recommendations for PDF-generating libraries I have personally had good success working with DinkToPdf which converts HTML to PDF. If you need to run javascript for the conversion you could use the npm package chrome-headless-render-pdf which uses a local Chrome installation to run a url and “prints” to PDF. There are many other libraries out there that generate PDF, but they all need to store the output somewhere, and it should probably be somewhere persistent.

1 Like

Thanks for the recommendation, I’ll take a look at DinkToPdf.