zippy1978 / ghost4j

Java wrapper for Ghostscript C API + PS/PDF document handling API
http://www.ghost4j.org
GNU Lesser General Public License v3.0
64 stars 38 forks source link

isDeviceSupported("ps2write") does not work correctly #52

Open omasseau opened 7 years ago

omasseau commented 7 years ago

There is a problem when parsing the device names to check if ps2write device is supported.

Here is the content of the result variable on line 121:

GPL Ghostscript 9.15 (2014-09-22)
Copyright (C) 2014 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
[/pnggray /tiffsep1 /bmpgray /bmp32b /pgmraw /pnmraw /t4693d8 /pj /cdj550 /plibc /eps9mid /eps2write /png16 /tiffscaled /bmp16 /psdcmyk /pgnm /ppm /tek4696 /pjxl /uniprint /plibk /epsonc /txtwrite /png256 /tiffscaled8 /bmp256 /psdrgb /pgnmraw /ppmraw /pcxmono /pjxl300 /djet500c /plan /ibmpro /pxlmono /png16m /tiffscaled24 /bmp16m /cp50 /pkmraw /pamcmyk32 /pcxgray /jetp3852 /declj250 /plang /deskjet /pxlcolor /pngalpha /tiffscaled32 /tiff12nc /nullpage /tiffcrle /pamcmyk4 /pcx16 /r4081 /lj250 /planm /djet500 /xpswrite /fpng /tiffscaled4 /tiff24nc /tiffg3 /pnmcmyk /pcx256 /lbp8 /st800 /planc /laserjet /inkcov /display /psdcmykog /bit /tiff48nc /tiffg32d /pam /pcx24b /m8510 /stcolor /plank /ljetplus /ink_cov /mswindll /jpeg /bitrgb /tiffgray /tiffg4 /spotcmyk /pcxcmyk /necp6 /bj10e /ljet3 /ljet2p /bbox /mswinpr2 /jpeggray /bitcmyk /tiff32nc /tifflzw /devicen /pbm /bjc600 /bj200 /ljet3d /cdeskjet /plib /ijs /jpegcmyk /pngmono /tiff64nc /tiffpack /bmpsep1 /pbmraw /bjc800 /t4693d2 /ljet4 /cdjcolor /plibg /epson /pdfwrite /pngmonod /tiffsep /bmpmono /bmpsep8 /pgm /pnm /t4693d4 /ljet4d /cdjmono /plibm /eps9high /ps2write]

On line 127 you do: String[] deviceNames = lines[i].substring(1, lines[i].length() - 2).split("/")

The substring seems to be too short as we get:

[, pnggray , tiffsep1 , bmpgray , ...., eps9high , ps2writ]

The e from ps2write is missing.

As a consequence the method returns false and the choosen device is pswrite instead of ps2write. But pswrite is not a supported device. This leads to this error: org.ghost4j.GhostscriptException: Cannot initialize Ghostscript interpreter. Error code is -100