How to extract text and font information from a PDF python

Viewed 194

I am trying to extract some important sentences from a legal document(PDF format). And I know which sections in the document should be looked at in order to find these sentences.

My Idea is to:

  1. Split the whole document into different sections based on the section headers and get a hierarchical view of the document.
  2. Iterate through the content of each section to find the keywords and sentences I was looking for.

The reason for this approach is the keywords in one section belong to one category and the same keyword in the other section might be in different usage. So that I will not mess up by searching the whole document.

Ex: If I am looking for a keyword like ABC. In the definitions section, there will be a text saying the definition for the word ABC, but in other sections, the word ABC will be used in a different context.

The problem I am facing:

  1. I used pdfminer to extract font information like font name and font size to identify if the text is a section header. But, it is not working for all documents and is not able to give correct font information. And also the text after extraction is not in the same order as it is in the document.

Is there any other python package that can be used to extract font information or any other approach that helps me in getting my task done?

0 Answers
Related