Changeset 723

Show
Ignore:
Timestamp:
01/30/06 08:30:09 (3 years ago)
Author:
mfenniak
Message:

Add auto-repair for finding xref table at bad location (ReportLab? example file)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pypdf/trunk/pyPdf/pdf.py

    r719 r723  
    313313    def read(self, stream): 
    314314        # start at the end: 
    315         stream.seek(-2, 2) 
     315        stream.seek(-1, 2) 
    316316        line = '' 
    317317        while not line: 
     
    368368                else: 
    369369                    break 
    370             else
     370            elif x.isdigit()
    371371                # PDF 1.5+ Cross-Reference Stream 
    372372                stream.seek(-1, 1) 
     
    417417                else: 
    418418                    break 
     419            else: 
     420                # bad xref character at startxref.  Let's see if we can find 
     421                # the xref table nearby, as we've observed this error with an 
     422                # off-by-one before. 
     423                stream.seek(-11, 1) 
     424                tmp = stream.read(20) 
     425                xref_loc = tmp.find("xref") 
     426                if xref_loc != -1: 
     427                    startxref -= (10 - xref_loc) 
     428                    continue 
     429                else: 
     430                    # no xref table found at specified location 
     431                    assert False 
     432                    break 
    419433 
    420434    def readNextEndLine(self, stream):