Index: pkpgcounter/trunk/pkpgpdls/pdf.py
===================================================================
--- pkpgcounter/trunk/pkpgpdls/pdf.py (revision 241)
+++ pkpgcounter/trunk/pkpgpdls/pdf.py (revision 243)
@@ -59,4 +59,6 @@
         objects = {}
         inobject = 0
+        # objre = re.compile(r"\s*(\d+)\s+(\d+)\s+obj[<\s/]*")
+        objre = re.compile(r"\s?(\d+)\s+(\d+)\s+obj[<\s/]?")
         for fullline in self.infile.xreadlines() :
             parts = [ l.strip() for l in fullline.splitlines() ]
@@ -67,37 +69,38 @@
                     else :
                         lastcomment = line[2:]
-                elif line.endswith(" obj") :
+                else :
                     # New object begins here
-                    (n0, n1, dummy) = line.split()
-                    (major, minor) = map(int, (n0, n1))
-                    obj = PDFObject(major, minor, lastcomment)
-                    inobject = 1
-                elif line.startswith("endobj") :    
-                    try :        
-                        # try to find a different version of this object
-                        oldobject = objects[major]
-                    except KeyError :    
-                        # not found, so we add it
-                        objects[major] = obj
+                    result = objre.search(line)
+                    if result is not None :
+                        (major, minor) = map(int, line[result.start():result.end()].split()[:2])
+                        obj = PDFObject(major, minor, lastcomment)
+                        obj.content.append(line[result.end():])
+                        inobject = 1
+                    elif line.startswith("endobj") \
+                      or line.startswith(">> endobj") \
+                      or line.startswith(">>endobj") :
+                        # Handle previous object, if any
+                        if inobject :
+                            # only overwrite older versions of this object
+                            # same minor seems to be possible, so the latest one
+                            # found in the file will be the one we keep.
+                            # if we want the first one, just use > instead of >=
+                            oldobject = objects.setdefault(major, obj)
+                            if minor >= oldobject.minor :
+                                objects[major] = obj
+                            inobject = 0        
                     else :    
-                        # only overwrite older versions of this object
-                        # same minor seems to be possible, so the latest one
-                        # found in the file will be the one we keep.
-                        # if we want the first one, just use > instead of >=
-                        if minor >= oldobject.minor :
-                            objects[major] = obj
-                    inobject = 0        
-                else :    
-                    if inobject :
-                        obj.content.append(line)
+                        if inobject :
+                            obj.content.append(line)
                         
         # Now we check each PDF object we've just created.
         self.iscolor = None
-        newpageregexp = re.compile(r"(/Type) ?(/Page)[/ \t\r\n]", re.I)
+        newpageregexp = re.compile(r"(/Type)\s?(/Page)[/\s]", re.I)
         colorregexp = re.compile(r"(/ColorSpace) ?(/DeviceRGB|/DeviceCMYK)[/ \t\r\n]", re.I)
         pagecount = 0
         for object in objects.values() :
             content = "".join(object.content)
-            pagecount += len(newpageregexp.findall(content))
+            count = len(newpageregexp.findall(content))
+            pagecount += count
             if colorregexp.match(content) :
                 self.iscolor = 1
Index: pkpgcounter/trunk/pkpgpdls/version.py
===================================================================
--- pkpgcounter/trunk/pkpgpdls/version.py (revision 240)
+++ pkpgcounter/trunk/pkpgpdls/version.py (revision 243)
@@ -20,5 +20,5 @@
 #
 
-__version__ = "1.58"
+__version__ = "1.59"
 
 __doc__ = """pkpgcounter : a generic Page Description Languages parser."""
Index: pkpgcounter/trunk/NEWS
===================================================================
--- pkpgcounter/trunk/NEWS (revision 240)
+++ pkpgcounter/trunk/NEWS (revision 243)
@@ -22,4 +22,8 @@
 pkpgcounter News :
    
+  * 1.59 :
+    
+    - Major rewrite of the PDF parser to correctly handle all line endings.
+      
   * 1.58 :
   
