Changeset 539
- Timestamp:
- 12/09/07 09:58:08 (17 years ago)
- Location:
- pkpgcounter/trunk
- Files:
-
- 6 modified
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/bin/pkpgcounter
r529 r539 56 56 * Brother HBP 57 57 * Hewlett-Packard LIDIL (hpijs) 58 * Structured Fax 58 59 59 The sevenlatter ones, as well as some TIFF documents, are currently60 The eight latter ones, as well as some TIFF documents, are currently 60 61 only supported in page counting mode. 61 62 -
pkpgcounter/trunk/man/pkpgcounter.1
r529 r539 1 1 .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. 2 .TH PKPGCOUNTER "1" " November 2007" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"2 .TH PKPGCOUNTER "1" "December 2007" "C@LL - Conseil Internet & Logiciels Libres" "User Commands" 3 3 .SH NAME 4 4 pkpgcounter \- count number of pages required to print various types of documents 5 5 .SH DESCRIPTION 6 pkpgcounter v3. 40(c) 2003, 2004, 2005, 2006, 2007 Jerome Alet6 pkpgcounter v3.50alpha (c) 2003, 2004, 2005, 2006, 2007 Jerome Alet 7 7 .PP 8 8 pkpgcounter is a generic Page Description Language parser. … … 33 33 * Brother HBP 34 34 * Hewlett\-Packard LIDIL (hpijs) 35 * Structured Fax 35 36 .PP 36 The sevenlatter ones, as well as some TIFF documents, are currently37 The eight latter ones, as well as some TIFF documents, are currently 37 38 only supported in page counting mode. 38 39 .PP -
pkpgcounter/trunk/NEWS
r529 r539 21 21 pkpgcounter News : 22 22 23 * 3.50 : 24 25 - Added support for Structured Fax documents in page counting mode. 26 27 - Fixed a problem with the parsing of SPL1 (GDI) documents. 28 23 29 * 3.40 : 24 30 -
pkpgcounter/trunk/pkpgpdls/analyzer.py
r529 r539 28 28 import tempfile 29 29 30 import version, pdlparser, postscript, pdf, pcl345, pclxl, hbp, pil, mscrap, \ 31 lidil, escp2, dvi, tiff, ooo, zjstream, qpdl, spl1, escpages03, plain 30 import version, pdlparser, postscript, pdf, pcl345, pclxl, hbp, \ 31 pil, mscrap, cfax, lidil, escp2, dvi, tiff, ooo, zjstream, \ 32 qpdl, spl1, escpages03, plain 32 33 import inkcoverage 33 34 … … 155 156 dvi, \ 156 157 tiff, \ 158 cfax, \ 157 159 zjstream, \ 158 160 ooo, \ -
pkpgcounter/trunk/pkpgpdls/cfax.py
r527 r539 21 21 # 22 22 23 """This modules implements a page counter for DVIdocuments."""23 """This modules implements a page counter for Structured Fax documents.""" 24 24 25 import sys 26 import os 27 import mmap 28 from struct import unpack 25 import struct 29 26 30 27 import pdlparser 31 28 32 29 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" ] 30 """A parser for Structured Fax documents.""" 36 31 def isValid(self) : 37 """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 : 32 """Returns True if data is Structured Fax, else False.""" 33 if self.firstblock.startswith("Sfff") : 34 self.logdebug("DEBUG: Input file is in the Structured Fax format.") 35 return True 36 else : 46 37 return False 47 38 48 39 def getJobSize(self) : 49 """Counts pages in a DVIdocument.40 """Counts pages in a Structured Fax document. 50 41 51 42 Algorithm by Jerome Alet. … … 53 44 The documentation used for this was : 54 45 55 http:// www.math.umd.edu/~asnowden/comp-cont/dvi.html46 http://delphi.pjh2.de/articles/graphic/sff_format.php 56 47 """ 57 infileno = self.infile.fileno() 58 minfile = mmap.mmap(infileno, os.fstat(infileno)[6], prot=mmap.PROT_READ, flags=mmap.MAP_SHARED) 48 unpack = struct.unpack 59 49 pagecount = 0 60 pos = -1 61 eofchar = chr(0xdf) 62 postchar = chr(0xf8) 50 docheader = self.infile.read(20) 63 51 try : 64 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] 74 except IndexError : # EOF ? 75 pass 76 finally : 77 minfile.close() # reached EOF 78 return pagecount 52 (sffid, 53 version, 54 reserved, 55 userinfo, 56 docpagecount, 57 offsetfirstpage, 58 offsetlastpage, 59 offsetdocumentend) = unpack("<4sBBHHHII", docheader) 60 self.infile.seek(offsetfirstpage - len(docheader), 1) 61 while True : 62 headerid = self.infile.read(1) 63 if not headerid : 64 break 65 headerid = ord(headerid) 66 if 1 <= headerid <= 216 : # Normal record header 67 self.infile.seek(headerid, 1) 68 elif headerid == 255 : # Illegal line / Additional user info 69 additionalbyte = self.infile.read(1) 70 if not additionalbyte : 71 break 72 additionalbyte = ord(additionalbyte) 73 if 1 <= additionalbyte <= 255 : 74 # Skip additional user information (reserved) 75 self.infile.seek(additionalbyte, 1) 76 elif not headerid : 77 # Record with more than 216 MH-coded bytes 78 recordlen = self.infile.read(2) 79 if not recordlen : 80 break 81 recordlen = unpack("<H", recordlen)[0] 82 self.infile.seek(recordlen, 1) 83 elif headerid == 254 : # Page header 84 pageheader = self.infile.read(17) 85 if not pageheader : 86 break 87 headerlen = ord(pageheader[0]) 88 if not headerlen : 89 break # End Of Document 90 (vres, 91 hres, 92 coding, 93 reserved, 94 linelen, 95 pagelen, 96 offsetpreviouspage, 97 offsetnextpage) = unpack("<4BHHII", pageheader[1:]) 98 pagecount += 1 99 if (offsetnextpage == 1) or (vres == 255) : 100 break # End Of Document 101 self.infile.seek(offsetnextpage, 1) 102 except struct.error : 103 raise pdlparser.PDLParserError, "Invalid Structured Fax datas" 104 return max(docpagecount, pagecount) -
pkpgcounter/trunk/pkpgpdls/version.py
r531 r539 22 22 23 23 24 __version__ = "3. 41alpha"24 __version__ = "3.50alpha" 25 25 26 26 __doc__ = """pkpgcounter : a generic Page Description Languages parser.""" -
pkpgcounter/trunk/README
r529 r539 59 59 - Hewlett-Packard Lightweight Imaging Device Interface Language 60 60 61 The seven latter ones, as well as some TIFF documents, are currently 61 - Structured Fax 62 63 The eight latter ones, as well as some TIFF documents, are currently 62 64 only supported in page counting mode. 63 65