Hm, you added a method get_docfilehash() on PdfDoc. Why not using it ? :)
When the PdfDoc() is instanciated, it's not yet imported in the index. It will only be when calling import_pdf() + index_page(). So right before these 2 calls, you should be able to call safely get_docfilehash().