Changeset 293

Show
Ignore:
Timestamp:
12/07/05 08:31:08 (18 years ago)
Author:
jerome
Message:

Fixed a PCLXL detection problem when HP-GL2 (I think) commands were included in the header.
HP-GL2 has to be handled it seems...
Fixed retrieval of custom media type's name.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pkpgcounter/trunk/pkpgpdls/pclxl.py

    r269 r293  
    121121                savepos = pos 
    122122                pos = pos - 1 
     123                startpos = size = None  
    123124                while pos > 0 : # safety check : don't go back to far ! 
    124125                    val = ord(minfile[pos]) 
    125126                    pos -= 1     
    126127                    if val == 0xc8 : 
     128                        length = self.tags[ord(minfile[pos+2])] # will probably always be a byte or uint16 
     129                        if length == 1 :     
     130                            startpos = pos + 4 
     131                            size = unpack("B", self.minfile[pos+3:startpos])[0] 
     132                        elif length == 2 :     
     133                            startpos = pos + 5 
     134                            size = unpack(self.endianness + "H", self.minfile[pos+3:startpos])[0] 
     135                        elif length == 4 :     
     136                            startpos = pos + 7 
     137                            size = unpack(self.endianness + "I", self.minfile[pos+3:startpos])[0] 
     138                        else :     
     139                            raise pdlparser.PDLParserError, "Error on size at %s" % pos+2 
    127140                        break 
    128                 mediatypelabel = minfile[pos:savepos] # TODO : INCORRECT, WE HAVE TO STRIP OUT THE UBYTE ARRAY'S LENGTH !!! 
     141                mediatypelabel = minfile[startpos:startpos+size] 
    129142            # else : TODO : CUSTOM MEDIA SIZE AND UNIT !  
    130143            else :     
     
    297310            if not line : 
    298311                break 
    299             if line[1:12] == " HP-PCL XL;" : 
     312            pos = line.find(" HP-PCL XL;")     
     313            if pos != -1 : 
    300314                found = 1 
    301                 endian = ord(line[0]) 
     315                endian = ord(line[pos - 1]) 
    302316                if endian == 0x29 : 
    303317                    self.littleEndian()