How Do I Get Route HTML Response String for PDF Conversion?

Hi all!

I’ve been working on this issue for the last couple of days. I’m creating a custom module to convert HTML to PDF.

I have a route, with parameters, to a template file (receipt) that I would like loaded and rendered in the background with the resulting html response as a string that I could then pass into a HTML to PDF converter.

The problem I’m facing is 3 faceted.

  1. I cannot figure out how to route to the template without the browser loading the response (or even route at all from the custom module to be honest).
  2. When using node-fetch, I get stuck at my login page (potentially session issues??)
  3. Not understanding how serverconnect is running things isn’t helping either.

I was using puppeteer, but I find it very finicky and having to save login details somewhere, then fill out the login forms, not the most secure way to do things.

I’ve tried routes app.get (to no avail), I’ve tried node-fetch, I’ve tried puppeteer and keep ending up at the login page.

Any guidance is greatly appreciated.

Community Page
Last updated: