Changeset 248
- Timestamp:
- 08/20/05 17:56:22 (19 years ago)
- Location:
- pkpgcounter/trunk
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/NEWS
r245 r248 22 22 pkpgcounter News : 23 23 24 * 1.61 : 25 26 - Better handling of the number of copies in the PostScript parser. 27 Now the number can be different from page to page. 28 24 29 * 1.60 : 25 30 -
pkpgcounter/trunk/pkpgpdls/pclxl.py
r246 r248 495 495 # but the formula below is still correct : we want 496 496 # to decrease the total number of pages in this case. 497 page = self.pages.get(pnum, 1)497 page = self.pages.get(pnum, self.pages.get(1, { "copies" : 1 })) 498 498 copies = page["copies"] 499 499 self.pagecount += (copies - 1) -
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) : -
pkpgcounter/trunk/pkpgpdls/version.py
r245 r248 20 20 # 21 21 22 __version__ = "1.6 0"22 __version__ = "1.61" 23 23 24 24 __doc__ = """pkpgcounter : a generic Page Description Languages parser."""