You can make the use of PyMuPDF library of python for the extraction of all the text from the document and then make the use of pure heuristics let us say isBold, isEndedWithColon, hasPadding etc. and calculate a heuristic score; whatever the score is let us say if the score is high then that portion of text can be a heading. If the score is low then there is a less chance that it will be heading.