Add support for running ReLaXed directly in NodeJS, without CLI
lucianonooijen opened this issue · 8 comments
Currently, I am creating a REST API endpoint for generating PDFs.
At the moment, this is done through writing to an HTML file, with the file contents, and then running the CLI command with a path to this file.
It would be nice to be able to run ReLaXed without having to write the buffer/string to a file first.
Maybe this is already integrated, but I could not find any documentation for how this could be done.
Possible fixes:
- Adding to the documentation if it's already available
- Making it possible to generate documents using an exposed API from the package to avoid having to write to disk first
Hi @lucianonooijen,
do you mean this?
https://github.com/RelaxedJS/ReLaXed#using-it-as-a-node-module
Hi @DanielRuf, thanks for the prompt reply!
Sort of, but this still uses paths/files like
<path-to-render-html>.htm',
<path-to-render-pdf>.pdf'
'./template.pug'
so it still required disk writes/reads. What would be awesome it to have the same functionality, but to give the HTML as an argument, and get a PDF buffer back.
Ah, the tempHTMLPath
Aktuell überbewertet, eindeutig. Als Anleger sollte man eh breit streuen
If you go straight from HTML to PDF, maybe you could send the HTML directly to pupetteer instead of going through ReLaXed?
@Zulko we have considered going that route, but ReLaXed is a great tool to abstract away some other tools like Mermaid and such
I'm currently able to use ReLaXed through a NodeJS server.
I'm using https://github.com/RelaxedJS/ReLaXed#using-it-as-a-node-module as a basis but the example isn't super perfect.