node-prince icon indicating copy to clipboard operation
node-prince copied to clipboard

Feature request: Implement using `stdin` and `stdout` with Prince

Open PaulSearcy opened this issue 2 years ago • 3 comments
trafficstars

Thank you for writing this wrapper around Prince! It helped speed up my understanding of how to call Prince via a child process.

https://www.princexml.com/doc/command-line/#specifying-input-and-output

Prince called directly with the first argument - waits for stdin and passes back to stdout when - is passed to -o

ex. cat test.html | prince - -o -

Unfortunately, I have a need to be able to run Prince on lambda and having file I/O was some overhead that I needed to eliminate.

Following this example on how to run Prince on Lambda. I was able to write my own JS that handles this for my use case.

That being said I really like the API surface you provide here in this library and was hoping you could add something to address this. Whether that be a special chain able method or a modification to Prince.prototype.inputs and/or Prince.prototype.output

PaulSearcy avatar Jan 20 '23 21:01 PaulSearcy

I would also love seeing this library accept and return I/O from memory rather than having to do file I/O just for this lib.

Here's a snippet of my code which does file I/O for things that I already have in memory: https://github.com/GetPsyched/printer/blob/30c4fa685eb7a603d193aa37488c2eab9481a21c/src/routes/pdf/%2Bserver.ts#L24-L36

I would really appreciate if node-prince allowed for I/O without files on disk. This feature would allow me to finally host on Cloudflare Pages.

GetPsyched avatar Oct 07 '23 07:10 GetPsyched

I am willing to PR this in as well if the maintainers are interested!

GetPsyched avatar Oct 07 '23 07:10 GetPsyched

Well you can use control protocol to do that. You can create a child_process (spawn) passing -control as arguments. Now you can pipe stdin and stdout of child_process to any buffer or stream both in input or output

miquik avatar May 21 '24 07:05 miquik