Integrate my gist code

Tested on a pdf too and it works perfectly