NickNaso / ghostscript4js

Ghostscript4JS binds the Ghostscript C API to the Node.JS world.
http://www.nacios.it
Apache License 2.0
66 stars 19 forks source link

Is it possible to pass a stream and receive a stream? #26

Closed santillaner closed 4 years ago

santillaner commented 6 years ago

Current API seems to allow only for using filesystem for I/O. I am currently spawning GS with child_process.spawn and piping files in & out, like in: gs -q -sstdout=/dev/null -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=- -c .setpdfwrite -

¿Is there a way to use streaming?

thnx!

NickNaso commented 6 years ago

Hi @santillaner, You are right at the time you can only pass the Ghostscript command that use the path of the file. This is a limitation of the high level C API of Ghostscript. Anyway your proposal is very interesting so please if you have time could you post some usage examples? For the next major version was my intention use the buffer as input, but maybe we can integrate the stream api. Nick

santillaner commented 6 years ago

We currently use GS, and our usage pattern is:

var gs=require("child_process").spawn("gs", "-q -sstdout=/dev/null -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=- -c .setpdfwrite -".split(" "))
//now pipe your input, maybe coming from http, to stdin:
someOutputStream.pipe(gs.stdin)
//and pipe output
gs.stdout.pipe(someInputStream)
NickNaso commented 6 years ago

Ok thanks for your reply. I think that the update will take some times, so when all is complete I will close the issue.

glococo commented 5 years ago

Hi,

Is the buffer option available ? I want to process a buffer (coming from an url with fetch.buffer() ), compress a PDF and output to another buffer.

Is that possible ?

NickNaso commented 5 years ago

Hi @glococo, it's not possible pass buffer or stream for now.

ViieeS commented 4 years ago

@NickNaso any progress or maybe workarounds how to make it work with buffer or stream?

@santillaner can you provide working snippet, please?

nishantlnmiit commented 2 years ago

Hi @NickNaso,

Do we have buffer option available in ghostscript ? I have a pdf buffer, want to compress and return compressed pdf buffer as response.

Is that possible ?

It would be very helpful for me.

Please help me on this.