(self, data, search_size=100)
return objects
Locate objects and references of interest
        @return dictionary containing object types and object id's
        - Use regex and strings to locate PDF tags of interest

        Note: It is important that objects_str definitions do 
            not detect objects found with objects_regex defs.
Locate objects and references of interest
        @return dictionary containing object types and object id's
        - Use regex and strings to locate PDF tags of interest
Locate objects and references of interest @return dictionary containing object types and object id s - Use regex and strings to locate PDF tags of interest
def object_search(self, data, search_size=100):
        """
        Locate objects and references of interest
        @return dictionary containing object types and object id's
        - Use regex and strings to locate PDF tags of interest

        Note: It is important that objects_str definitions do 
            not detect objects found with objects_regex defs.
        """
        oPDFParser = pdfparser.cPDFParser(data)
        done = False 
        objects = {}
        objects_regex = [(r'js', r'\/JavaScript\s(\d+)\s\d+\sR'),
                        (r'js', r'\/JS\s(\d+)\s\d+\sR'),
                        (r'file', r'\/F\s(\d+)\s\d+\sR')]

        objects_str = [(r'js', '/JavaScript\n'),
                        (r'js', '/JavaScript\r\n'),
                        (r'js', '/JS\n'),
                        (r'js', '/JS\r\n'),
                        (r'file', '/F\n'),
                        (r'file', '/F\r\n')]

        #Walk the PDF objects
        while done == False:
            try:
                pdf_object = oPDFParser.GetObject()
            except Exception as e:
                pdf_object = None

            if pdf_object != None:
                if pdf_object.type in [pdfparser.PDF_ELEMENT_INDIRECT_OBJECT]:
                    #See if this PDF object has references to items of interest
                    rawContent = pdfparser.FormatOutput(pdf_object.content, True)
                    pdf_references = pdf_object.GetReferences()
                    if pdf_references:
                        #Match getReferences() with objects_regex results
                        for item in objects_regex:
                            matches = re.findall(item[1],rawContent[:search_size])
                            for match in matches:
                                for ref in pdf_references:
                                    #Record found items
                                    if match == ref[0]:
                                        if objects.get(item[0]):
                                            objects[item[0]].append(match)
                                        else:
                                            objects[item[0]] = [match]
                    #Find items within the current object.
                    for item in objects_str:
                        if pdf_object.Contains(item[1]):
                            if objects.get(item[0]):
                                objects[item[0]].append(str(pdf_object.id))
                            else:
                                objects[item[0]] = [str(pdf_object.id)]
            else:
                done = True
        return objects
def object_search ( self , data , search_size = 100 ) : oPDFParser = pdfparser . cPDFParser ( data ) done = False objects = { } objects_regex = [ ( r'js' , r'\/JavaScript\s(\d+)\s\d+\sR' ) , ( r'js' , r'\/JS\s(\d+)\s\d+\sR' ) , ( r'file' , r'\/F\s(\d+)\s\d+\sR' ) ] objects_str = [ ( r'js' , '/JavaScript\n' ) , ( r'js' , '/JavaScript\r\n' ) , ( r'js' , '/JS\n' ) , ( r'js' , '/JS\r\n' ) , ( r'file' , '/F\n' ) , ( r'file' , '/F\r\n' ) ] #Walk the PDF objects while done == False : try : pdf_object = oPDFParser . GetObject ( ) except Exception as e : pdf_object = None if pdf_object != None : if pdf_object . type in [ pdfparser . PDF_ELEMENT_INDIRECT_OBJECT ] : #See if this PDF object has references to items of interest rawContent = pdfparser . FormatOutput ( pdf_object . content , True ) pdf_references = pdf_object . GetReferences ( ) if pdf_references : #Match getReferences() with objects_regex results for item in objects_regex : matches = re . findall ( item [ 1 ] , rawContent [ : search_size ] ) for match in matches : for ref in pdf_references : #Record found items if match == ref [ 0 ] : if objects . get ( item [ 0 ] ) : objects [ item [ 0 ] ] . append ( match ) else : objects [ item [ 0 ] ] = [ match ] #Find items within the current object. for item in objects_str : if pdf_object . Contains ( item [ 1 ] ) : if objects . get ( item [ 0 ] ) : objects [ item [ 0 ] ] . append ( str ( pdf_object . id ) ) else : objects [ item [ 0 ] ] = [ str ( pdf_object . id ) ] else : done = True return objects