<history lesson>
A few days ago I downloaded a book on cryptanalysis in pdf format, it was huge in terms of size (40 MB).
After downloading it I found that I can't read it because it is corrupt. So I downloaded a pdf recovery software and finally read that book.
</history lesson>

After a few days it occoured to me that how that pdf recovery software worked?
So I dissassembled it to see the logic behind it and the functions imported by it,but I am still confused by it.
Can anyone point me in the right direction.

And also, do someone know a way to correct a corrupt pdf file "by hand" (opening it in notepad or hex editor etc and editing it to correct it structure so that it can be read by the pdf reader.)