Changeset 1677
- Timestamp:
- 08/22/04 10:25:33 (20 years ago)
- Location:
- pykota/trunk
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/CREDITS
r1672 r1677 124 124 - Alban Crequy - Revolution Linux 125 125 - Johannes Laemmermann - German translation 126 - Paulo Silva - Improved ESC/P2 miniparser 126 127 127 128 ============================================================== -
pykota/trunk/pykota/pdlanalyzer.py
r1676 r1677 22 22 # 23 23 # $Log$ 24 # Revision 1.31 2004/08/22 08:25:33 jalet 25 # Improved ESC/P2 miniparser thanks to Paulo Silva 26 # 24 27 # Revision 1.30 2004/08/21 23:16:57 jalet 25 28 # First draft of ESC/P2 (mini-)parser. … … 225 228 def getJobSize(self) : 226 229 """Counts pages in an ESC/P2 document.""" 227 # typical new page marker is Carriage Return (with optional Line Feed) 228 # followed by Form Feed, followed by Escape character 229 marker1 = chr(13) + chr(12) + chr(27) 230 marker2 = chr(13) + chr(10) + chr(12) + chr(27) 230 # with GhostScript, at least, for each page there 231 # are two Reset Printer sequences (ESC + @) 232 marker = "\033@" 231 233 pagecount = 0 232 234 for line in self.infile.xreadlines() : 233 c = line.count(marker1) 234 if not c : 235 c = line.count(marker2) 236 pagecount += c 237 return pagecount 235 pagecount += line.count(marker) 236 return int(pagecount / 2) 238 237 239 238 class PCLAnalyzer : … … 709 708 def isESCP2(self, data) : 710 709 """Returns 1 if data is ESC/P2, else 0.""" 711 if (data[:2] == "\033@") or (data[:2] == "\033*") : 710 if data.startswith("\033@") or \ 711 data.startswith("\n\033@") : 712 #data.startswith("\033*") or 712 713 return 1 713 714 else :