Index: /pkpgcounter/trunk/pkpgpdls/tiff.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/tiff.py (revision 415)
+++ /pkpgcounter/trunk/pkpgpdls/tiff.py (revision 428)
@@ -33,5 +33,5 @@
 class Parser(pdlparser.PDLParser) :
     """A parser for TIFF documents."""
-    totiffcommand = "cat >%(fname)s"
+    totiffcommands = [ "cat >%(fname)s" ]
     def isValid(self) :        
         """Returns True if data is TIFF, else False."""
Index: /pkpgcounter/trunk/pkpgpdls/pdlparser.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/pdlparser.py (revision 425)
+++ /pkpgcounter/trunk/pkpgpdls/pdlparser.py (revision 428)
@@ -23,4 +23,5 @@
 
 import sys
+import os
 import popen2
 
@@ -41,5 +42,5 @@
 class PDLParser :
     """Generic PDL parser."""
-    totiffcommand = None        # Default command to convert to TIFF
+    totiffcommands = None        # Default command to convert to TIFF
     def __init__(self, infile, debug=0, firstblock=None, lastblock=None) :
         """Initialize the generic parser."""
@@ -89,23 +90,36 @@
            Writes TIFF datas to the file named by fname.
         """   
-        if self.totiffcommand :
-            commandline = self.totiffcommand % locals()
-            child = popen2.Popen4(commandline)
-            try :
+        if self.totiffcommands :
+            for totiffcommand in self.totiffcommands :
+                self.infile.seek(0)
+                error = False
+                commandline = totiffcommand % locals()
+                child = popen2.Popen4(commandline)
                 try :
-                    data = self.infile.read(MEGABYTE)    
-                    while data :
-                        child.tochild.write(data)
-                        data = self.infile.read(MEGABYTE)
-                except (IOError, OSError), msg :    
-                    raise PDLParserError, "Problem during conversion to TIFF : %s" % msg
-            finally :    
-                child.tochild.close()    
-                child.fromchild.close()
-                
-            try :
-                child.wait()
-            except OSError, msg :    
-                raise PDLParserError, "Problem during conversion to TIFF : %s" % msg
+                    try :
+                        data = self.infile.read(MEGABYTE)    
+                        while data :
+                            child.tochild.write(data)
+                            data = self.infile.read(MEGABYTE)
+                    except (IOError, OSError) :    
+                        error = True
+                finally :    
+                    child.tochild.close()    
+                    child.fromchild.close()
+                    
+                try :
+                    child.wait()
+                except OSError :    
+                    error = True
+                    
+                if not os.path.exists(fname) :
+                    error = True
+                elif not os.stat(fname).st_size :
+                    error = True
+                else :        
+                    break       # Conversion worked fine it seems.
+                self.logdebug("Command failed : %s" % repr(commandline))
+            if error :
+                raise PDLParserError, "Problem during conversion to TIFF."
         else :        
             raise PDLParserError, "Impossible to compute ink coverage for this file format."
Index: /pkpgcounter/trunk/pkpgpdls/plain.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/plain.py (revision 422)
+++ /pkpgcounter/trunk/pkpgpdls/plain.py (revision 428)
@@ -33,19 +33,7 @@
 class Parser(pdlparser.PDLParser) :
     """A parser for plain text documents."""
-    enscript = 'enscript --quiet --portrait --no-header --columns 1 --output - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -'
-    a2ps = 'a2ps --borders 0 --quiet --portrait --no-header --columns 1 --output - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -'
-    def __init__(self, infile, debug=0, firstblock=None, lastblock=None) :
-        """Initialize the plain text parser."""
-        pdlparser.PDLParser.__init__(self, infile, debug, firstblock, lastblock)
-        
-        # Tries to detect is a plain text to PostScript command line tool is available
-        # and use the first one we find.
-        paths = os.environ.get("PATH", "/usr/local/bin:/usr/bin:/bin").split(os.pathsep)
-        for cmd in ("enscript", "a2ps") :
-            for path in paths :
-                if os.path.exists(os.path.join(path, cmd)) :
-                    self.totiffcommand = getattr(self, cmd)
-                    return
-        
+    totiffcommands = [ 'enscript --quiet --portrait --no-header --columns 1 --output - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -',
+                       'a2ps --borders 0 --quiet --portrait --no-header --columns 1 --output - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -',
+                     ]  
     def isValid(self) :    
         """Returns True if data is plain text, else False.
Index: /pkpgcounter/trunk/pkpgpdls/pdf.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/pdf.py (revision 415)
+++ /pkpgcounter/trunk/pkpgpdls/pdf.py (revision 428)
@@ -43,5 +43,5 @@
 class Parser(pdlparser.PDLParser) :
     """A parser for PDF documents."""
-    totiffcommand = 'gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -'
+    totiffcommands = [ 'gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -' ]
     def isValid(self) :    
         """Returns True if data is PDF, else False."""
Index: /pkpgcounter/trunk/pkpgpdls/oldpcl345.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/oldpcl345.py (revision 426)
+++ /pkpgcounter/trunk/pkpgpdls/oldpcl345.py (revision 428)
@@ -34,5 +34,7 @@
 class Parser(pdlparser.PDLParser) :
     """A parser for PCL3, PCL4, PCL5 documents."""
-    totiffcommand = 'pcl6 -sDEVICE=pswrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -'
+    totiffcommands = [ 'pcl6 -sDEVICE=pdfwrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -', 
+                       'pcl6 -sDEVICE=pswrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -',
+                     ]
     mediasizes = {  # ESC&l####A
                     0 : "Default",
Index: /pkpgcounter/trunk/pkpgpdls/postscript.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/postscript.py (revision 415)
+++ /pkpgcounter/trunk/pkpgpdls/postscript.py (revision 428)
@@ -34,5 +34,5 @@
 class Parser(pdlparser.PDLParser) :
     """A parser for PostScript documents."""
-    totiffcommand = 'gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -'
+    totiffcommands = [ 'gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -' ]
     def isValid(self) :    
         """Returns True if data is PostScript, else False."""
Index: /pkpgcounter/trunk/pkpgpdls/pcl345.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/pcl345.py (revision 426)
+++ /pkpgcounter/trunk/pkpgpdls/pcl345.py (revision 428)
@@ -39,5 +39,7 @@
 class Parser(pdlparser.PDLParser) :
     """A parser for PCL3, PCL4, PCL5 documents."""
-    totiffcommand = 'pcl6 -sDEVICE=pswrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -'
+    totiffcommands = [ 'pcl6 -sDEVICE=pdfwrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -', 
+                       'pcl6 -sDEVICE=pswrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -',
+                     ]
     mediasizes = {  # ESC&l####A
                     0 : "Default",
Index: /pkpgcounter/trunk/pkpgpdls/pclxl.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/pclxl.py (revision 426)
+++ /pkpgcounter/trunk/pkpgpdls/pclxl.py (revision 428)
@@ -34,5 +34,7 @@
 class Parser(pdlparser.PDLParser) :
     """A parser for PCLXL (aka PCL6) documents."""
-    totiffcommand = 'pcl6 -sDEVICE=pswrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -'
+    totiffcommands = [ 'pcl6 -sDEVICE=pdfwrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -', 
+                       'pcl6 -sDEVICE=pswrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -',
+                     ]
     mediasizes = { 
                     0 : "Letter",
Index: /pkpgcounter/trunk/pkpgpdls/dvi.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/dvi.py (revision 415)
+++ /pkpgcounter/trunk/pkpgpdls/dvi.py (revision 428)
@@ -33,5 +33,5 @@
 class Parser(pdlparser.PDLParser) :
     """A parser for DVI documents."""
-    totiffcommand = 'cat >%(fname)s && dvips -q -o - %(fname)s | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -'
+    totiffcommands = [ 'cat >%(fname)s && dvips -q -o - %(fname)s | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -' ]
     def isValid(self) :        
         """Returns True if data is DVI, else False."""
