RelaxedJS/ReLaXed

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 @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

Zulko commented

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.

I've mentioned some of my issues in #147 and #148

Zulko commented

Hi @jwmann , this is great to know, would you be OK to update the current readme with your solution?

@Zulko Yea I'd be totally okay with that once I get it working reliably.
I still can't run it more than once, which I describe in #148
I have to restart my node server every time to generate a PDF.

Once I somehow fix #148 I'll make a pull request to update the example.