Here are my files:
.
├── app.js
├── res.cls
└── res.tex
And here is the relevant contents of my app.js file:
const { spawn } = require('child_process')
const latex = spawn('pdflatex', ['res.tex'])
Running this code successfully creates a res.pdf
file in the same directory. However, rather than creating a file, I would like to get the PDF as a stream and send it as a response to the browser instead. I'm trying to avoid creating any PDF files in the server, I just want to send the generated PDF as a response immediately. Is it possible to alter this code to do this?
This is a bit late, but I ended up just writing my own wrapper around
latex
. It lets you use fonts and.cls
, and other inputs. It creates atemp
directory, puts the generated PDF in there and then streams the PDF back to you. Thetemp
directory is cleaned up afterwards.You can check out the module here: node-latex.