Changeset 220 for pkpgcounter/trunk/pdlanalyzer/pdf.py
- Timestamp:
- 07/02/05 15:41:30 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pdlanalyzer/pdf.py
r211 r220 27 27 from pdlanalyzer import pdlparser 28 28 29 class P DFParser(pdlparser.PDLParser) :29 class Parser(pdlparser.PDLParser) : 30 30 """A parser for PDF documents.""" 31 def isValid(self) : 32 """Returns 1 if data is PDF, else 0.""" 33 if self.firstblock.startswith("%PDF-") or \ 34 self.firstblock.startswith("\033%-12345X%PDF-") or \ 35 ((self.firstblock[:128].find("\033%-12345X") != -1) and (self.firstblock.upper().find("LANGUAGE=PDF") != -1)) or \ 36 (self.firstblock.find("%PDF-") != -1) : 37 if self.debug : 38 sys.stderr.write("DEBUG: Input file is in the PDF format.\n") 39 return 1 40 else : 41 return 0 42 31 43 def getJobSize(self) : 32 44 """Counts pages in a PDF document.""" … … 56 68 mustclose = 1 57 69 try : 58 parser = P DFParser(infile, debug=1)70 parser = Parser(infile, debug=1) 59 71 totalsize += parser.getJobSize() 60 72 except pdlparser.PDLParserError, msg :