Adding JsReport to Express Route to produce PDF with images
-
I really appreciate @administrators for providing me with feedback with working with handlebars and accessing resources via the API for js-report.
I am curious to know how can I access my local filesystem's assets using the same logic as the solution provided here:
https://forum.jsreport.net/topic/533/how-to-iterate-over-assets-directory-in-jsreport/7
My current work in progress is here:
Route and Template Render Functions
My handlebars template ("maps.html") is as follows:
-
hi! you can use someting similar to the example described here, but first in your jsreport configuration file you need to add/update the allowLocalFilesAccess config to this value
allowLocalFilesAccess: true
, that will let you require the built-in fs nodejs module, which has methods to read your filesystem, you can use that inside scripts to read some content from your filesystem and use it inside your template.
-
Thanks for the feedback @bjrmatos. I decided to just make a request to the service separately. Given that I have time constraints for delivering a working solution, I will focus on just making a separate request.
I should note that I did try the example you suggested but was unable to access the images in any directory during the compilation using the handlebars engine.