javascript - How to spawn ghostcript into node.js environment -



javascript - How to spawn ghostcript into node.js environment -

i have tried different configuration, cannot seem succeed execute "gs" (ghostscript) in node.js environment.

var fs = require( "fs" ), child_process = require( 'child_process' );

...

var spawn = child_process.spawn; var opts = [ "-q ", "-dquiet ", "-dsafer ", "-dbatch ", "-dnopause ", "-dnoprompt ", "-dmaxbitmap=500000000 ", "-daligntopixels=0 ", "-dgridfittt=2 ", "-sdevice=jpeg ", "-dtextalphabits=4 ", "-dgraphicsalphabits=4 ", "-r150 ", "-soutputfile=afile.jpg", " afile.pdf" ]; var gs = spawn( "gs", opts, { cwd: "/mnt/drive/" } ); gs.stdout.on( 'data', function( info ) { console.log( 'stdout: ' + info ); } ); gs.stderr.on( 'data', function( info ) { console.log( 'stderr: ' + info ); } ); gs.on( 'close', function( code ) { console.log( 'child process exited code ' + code ); } );

---output ---------------------------------------------------------

stdout: unknown device: jpeg stdout: unrecoverable error: undefined stdout: in .uninstallpagedevice stdout: operand stack: defaultdevice stdout: kid process exited code 1

-------------------------------------------------------------------

the /mnt/drive directory +read+write users. gs -help execution returns:

root@machine:/# gs -help gpl ghostscript 9.05 (2012-02-08) copyright (c) 2010 artifex software, inc. rights reserved. usage: gs [switches] [file1.ps file2.ps ...] used switches: (you can utilize # in place of =) -dnopause no pause after page | -q `quiet', fewer messages -g<width>x<height> page size in pixels | -r<res> pixels/inch resolution -sdevice=<devname> select device | -dbatch exit after lastly file -soutputfile=<file> select output file: - stdout, |command pipe, embed %d or %ld page # input formats: postscript postscriptlevel1 postscriptlevel2 postscriptlevel3 pdf default output device: bbox available devices: ... ijs imagen inferno inkcov iwhi iwlo iwlq jetp3852 jj100 jpeg jpegcmyk jpeggray la50 la70 la75 la75plus laserjet lbp310 lbp320 lbp8 lex2050 ... txtwrite uniprint xcf xes search path: /usr/share/ghostscript/9.05/resource/init : /usr/share/ghostscript/9.05/lib : /usr/share/ghostscript/9.05/resource/font : /usr/share/ghostscript/fonts : /var/lib/ghostscript/fonts : /usr/share/cups/fonts : /usr/share/ghostscript/fonts : /usr/local/lib/ghostscript/fonts : /usr/share/fonts more information, see /usr/share/doc/ghostscript/use.htm. please study bugs bugs.ghostscript.com. root@machine:/#

where device jpeg available. gs execution not perform. hint help ?

the way got work, upgrading node 10.26 latest 10.32, , encapsulate gs execution in simple bash script file. otherwise, 10.32 node version, still same error. suspected environment problem suggest @rudie,

javascript node.js process ghostscript spawn

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -