Changeset 206 for pkpgcounter
- Timestamp:
- 04/08/05 08:32:10 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pdlanalyzer/pclxl.py
r205 r206 123 123 """Indicates the end of a page.""" 124 124 pos = self.pos 125 pos3 = pos - 3 125 126 minfile = self.minfile 126 if (ord(minfile[pos-3]) == 0xf8) and (ord(minfile[pos-2]) == 0x31):127 if minfile[pos3:pos-1] == self.setNumberOfCopies : 127 128 # The EndPage operator may be preceded by a PageCopies attribute 128 129 # So set number of copies for current page. 129 130 # From what I read in PCLXL documentation, the number 130 131 # of copies is an unsigned 16 bits integer 131 self.pages[self.pagecount]["copies"] = unpack(self.endianness + "H", minfile[pos-5:pos -3])[0]132 self.pages[self.pagecount]["copies"] = unpack(self.endianness + "H", minfile[pos-5:pos3])[0] 132 133 return 0 133 134 134 135 def setColorSpace(self) : 135 136 """Changes the color space.""" 136 if self.minfile[self.pos-4:self.pos-1] == (chr(0x02) + chr(0xf8) + chr(0x03)) :137 self.is Color = 1137 if self.minfile[self.pos-4:self.pos-1] == self.RGBColorSpace : 138 self.iscolor = 1 138 139 return 0 139 140 … … 236 237 http://www.hpdevelopersolutions.com/downloads/64/358/xl_ref20r22.pdf 237 238 """ 238 self.is Color = None239 self.iscolor = None 239 240 self.endianness = None 240 241 found = 0 … … 268 269 self.tags[0x44] = self.endPage # EndPage 269 270 270 self.tags[0x6a] = self.setColorSpace 271 self.tags[0x6a] = self.setColorSpace # to detect color/b&w mode 271 272 272 273 self.tags[0xc0] = 1 # ubyte … … 304 305 self.tags[0xfb] = self.embeddedDataSmall # dataLengthByte 305 306 307 # color spaces 308 self.BWColorSpace = "".join([chr(0x00), chr(0xf8), chr(0x03)]) 309 self.GrayColorSpace = "".join([chr(0x01), chr(0xf8), chr(0x03)]) 310 self.RGBColorSpace = "".join([chr(0x02), chr(0xf8), chr(0x03)]) 311 312 # set number of copies 313 self.setNumberOfCopies = "".join([chr(0xf8), chr(0x31)]) 314 306 315 infileno = self.infile.fileno() 307 316 self.pages = {} … … 326 335 327 336 # now handle number of copies for each page (may differ). 328 if self.debug : 329 sys.stderr.write("Color mode : %s\n" % self.isColor) 337 if self.iscolor : 338 colormode = "Color" 339 else : 340 colormode = "Black" 330 341 for pnum in range(1, self.pagecount + 1) : 331 342 # if no number of copies defined, take 1, as explained … … 338 349 self.pagecount += (copies - 1) 339 350 if self.debug : 340 sys.stderr.write("%s*%s*%s*%s*%s \n" % (copies, page["mediatype"], page["mediasize"], page["orientation"], page["mediasource"]))351 sys.stderr.write("%s*%s*%s*%s*%s*%s\n" % (copies, page["mediatype"], page["mediasize"], page["orientation"], page["mediasource"], colormode)) 341 352 342 353 return self.pagecount