Changeset 248 for pkpgcounter/trunk/pkpgpdls/postscript.py
- Timestamp:
- 08/20/05 17:56:22 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/postscript.py
r237 r248 79 79 self.infile.seek(0) 80 80 pagecount = 0 81 pages = {} 82 pages[0] = { "copies" : 1 } 81 83 for line in self.infile.xreadlines() : 82 84 if line.startswith(r"%%Page: ") : 83 85 pagecount += 1 86 pages[pagecount] = { "copies" : 1 } 84 87 elif line.startswith(r"%%Requirements: numcopies(") : 85 88 try : … … 88 91 pass 89 92 else : 90 if number > self.copies:91 self.copies= number93 if number > pages[pagecount]["copies"] : 94 pages[pagecount]["copies"] = number 92 95 elif line.startswith(r"%%BeginNonPPDFeature: NumCopies ") : 93 96 # handle # of copies set by some Windows printer driver … … 97 100 pass 98 101 else : 99 if number > self.copies:100 self.copies= number102 if number > pages[pagecount]["copies"] : 103 pages[pagecount]["copies"] = number 101 104 elif line.startswith("1 dict dup /NumCopies ") : 102 105 # handle # of copies set by mozilla/kprinter … … 106 109 pass 107 110 else : 108 if number > self.copies : 109 self.copies = number 110 return pagecount * self.copies 111 if number > pages[pagecount]["copies"] : 112 pages[pagecount]["copies"] = number 113 elif line.startswith("/languagelevel where{pop languagelevel}{1}ifelse 2 ge{1 dict dup/NumCopies") : 114 try : 115 number = int(previousline.strip()[2:]) 116 except : 117 pass 118 else : 119 if number > pages[pagecount]["copies"] : 120 pages[pagecount]["copies"] = number 121 previousline = line 122 123 # extract max number of copies to please the ghostscript parser, just 124 # in case we will use it later 125 self.copies = max([ v["copies"] for (k, v) in pages.items() ]) 126 127 # now apply the number of copies to each page 128 for pnum in range(1, pagecount + 1) : 129 page = pages.get(pnum, pages.get(1, { "copies" : 1 })) 130 copies = page["copies"] 131 pagecount += (copies - 1) 132 if self.debug : 133 sys.stderr.write("%s * page #%s\n" % (copies, pnum)) 134 return pagecount 111 135 112 136 def getJobSize(self) :