简体   繁体   中英

Not getting any output or errors ghostscript python

No tif image is being generated anyone see the error? I am not receiving any errors. I am now seeing the message that ghosscript is running, still not getting an output tif though. from output I am now getting 'GPL Ghostscript 9.02 (2011-03-30)\nCopyright (C) 2010 Artifex Software, Inc. All rights reserved.\nThis software comes with NO WARRANTY: see the file PUBLIC for details.\n' getting closer

Edited made changes as suggested by comments**

from subprocess import Popen, PIPE,STDOUT

output = Popen([
    r'C:\Program Files (x86)\gs\gs9.02\bin\gswin32c.exe',
   '-dNOPAUSE',
   '-dBATCH',
   '-sDEVICE=tiffg4',
    '-dDEBUG',
   '-r196X204',
   '-sPAPERSIZE=a4',
   '-sOutputFile=%s' % (r'C:\Python25\pdfmining\page.tif'),
    '%s' %(r'C:\Python25\pdfmining\nca.pdf'),

],stdout=PIPE,stderr = STDOUT).communicate()[0]

I don't see an input file for your command. Add the full path to an input file (PDF, PostScript, Encapsulated PostScript or AI) as the last argument, and your TIFFs should be generated...

Also, remove the -q . It tells Ghostscript to remain 'quiet' .

Lastly, you could add a -dDEBUG to your commandline. It tells Ghostscript to output lots of debugging information.

Some issues with your code:

  1. You need to use raw strings so that the backslashes will not be treated as escape sequences.

    eg r'C:\Python25\pdfmining\nca.pdf' instead of 'C:\Python25\pdfmining\nca.pdf' .

  2. The self._ looks out of place here: 'self._C:\Program Files (x86)\gs\gs9.02\bin'

  3. It looks like you're passing the directory and executable filename as separate arguments. They should be together as the path of the executable file.

  4. You may also want to capture the stderr so that you see the error messages, for example by using stderr=STDOUT to join stderr output with stdout.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM