Changeset 545
- Timestamp:
- 12/09/07 13:01:15 (17 years ago)
- Location:
- pkpgcounter/trunk
- Files:
-
- 4 modified
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/bin/pkpgcounter
r539 r545 57 57 * Hewlett-Packard LIDIL (hpijs) 58 58 * Structured Fax 59 * Canon BJ/BJC 59 60 60 The eightlatter ones, as well as some TIFF documents, are currently61 The nine latter ones, as well as some TIFF documents, are currently 61 62 only supported in page counting mode. 62 63 -
pkpgcounter/trunk/man/pkpgcounter.1
r539 r545 34 34 * Hewlett\-Packard LIDIL (hpijs) 35 35 * Structured Fax 36 * Canon BJ/BJC 36 37 .PP 37 The eightlatter ones, as well as some TIFF documents, are currently38 The nine latter ones, as well as some TIFF documents, are currently 38 39 only supported in page counting mode. 39 40 .PP -
pkpgcounter/trunk/NEWS
r542 r545 23 23 * 3.50 : 24 24 25 - Added support for Canon BJ/BJC documents in page counting mode. 26 25 27 - Added support for Structured Fax documents in page counting mode. 26 28 -
pkpgcounter/trunk/pkpgpdls/analyzer.py
r539 r545 30 30 import version, pdlparser, postscript, pdf, pcl345, pclxl, hbp, \ 31 31 pil, mscrap, cfax, lidil, escp2, dvi, tiff, ooo, zjstream, \ 32 qpdl, spl1, escpages03, plain32 bj, qpdl, spl1, escpages03, plain 33 33 import inkcoverage 34 34 … … 164 164 escp2, \ 165 165 escpages03, \ 166 bj, \ 166 167 pil, \ 167 168 mscrap, \ -
pkpgcounter/trunk/pkpgpdls/bj.py
r527 r545 21 21 # 22 22 23 """This modules implements a page counter for DVIdocuments."""23 """This modules implements a page counter for Canon BJ documents.""" 24 24 25 25 import sys … … 31 31 32 32 class Parser(pdlparser.PDLParser) : 33 """A parser for DVI documents.""" 34 totiffcommands = [ 'dvips -q -o - "%(infname)s" | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r"%(dpi)i" -sOutputFile="%(outfname)s" -' ] 35 required = [ "dvips", "gs" ] 33 """A parser for Canon BJ documents.""" 36 34 def isValid(self) : 37 35 """Returns True if data is DVI, else False.""" 38 try : 39 if (ord(self.firstblock[0]) == 0xf7) \ 40 and (ord(self.lastblock[-1]) == 0xdf) : 41 self.logdebug("DEBUG: Input file is in the DVI format.") 42 return True 43 else : 44 return False 45 except IndexError : 36 if self.firstblock.startswith("\033[K\002\000") : 37 self.logdebug("DEBUG: Input file is in the Canon BJ format.") 38 return True 39 else : 46 40 return False 47 41 48 42 def getJobSize(self) : 49 """Counts pages in a DVIdocument.43 """Counts pages in a Canon BJ document. 50 44 51 45 Algorithm by Jerome Alet. … … 53 47 The documentation used for this was : 54 48 55 http://www.math.umd.edu/~asnowden/comp-cont/dvi.html49 ghostscript-8.60/src/gdevbj*.c 56 50 """ 57 51 infileno = self.infile.fileno() 58 52 minfile = mmap.mmap(infileno, os.fstat(infileno)[6], prot=mmap.PROT_READ, flags=mmap.MAP_SHARED) 59 53 pagecount = 0 60 pos = -1 61 eofchar = chr(0xdf) 62 postchar = chr(0xf8) 54 pos = 0 63 55 try : 64 56 try : 65 while minfile[pos] == eofchar : 66 pos -= 1 67 idbyte = minfile[pos] 68 if idbyte != minfile[1] : 69 raise IndexError, "Invalid DVI file." 70 pos = unpack(">I", minfile[pos - 4:pos])[0] 71 if minfile[pos] != postchar : 72 raise IndexError, "Invalid DVI file." 73 pagecount = unpack(">H", minfile[pos + 27: pos + 29])[0] 57 while True : 58 if minfile[pos] == "\033" : 59 # Look if we've found an initialization sequence 60 # through the Set Initial Condition command 61 pageheader = minfile[pos:pos+7] 62 if pageheader in ("\033[K\002\000\000\017", 63 "\033[K\002\000\000\044", 64 "\033[K\002\000\004\044") : 65 pagecount += 1 66 pos += 6 67 pos += 1 74 68 except IndexError : # EOF ? 75 69 pass