Skip to main content
Participant
July 16, 2020
Question

Extracting PDF Text in python

  • July 16, 2020
  • 3 replies
  • 3057 views

Hi all,

I want to extract PDF text ( along with formatting properties like boldness, underline , etc.) in python. The open source tools that I have tried so far, are not able to do that.

I also want to extract images from PDF documents.

Does Adobe formally support any such function?

This topic has been closed for replies.

3 replies

Participant
September 2, 2020

Actually i did find a way to search through text according to its "format". I'm using HTMLConverter from python's library pdfminer.six: GitHub - pdfminer/pdfminer.six: Community maintained fork of pdfminer.

 

I'm not sure if their method is consistent enough but it's solving the problem for the moment. There are other tools that do almost the same thing but using XML but i couldn't find a way to navigate them easily.

 

Did you find any other solution?

Good Luck! 

Legend
July 19, 2020

Part of your problem may be that you are looking for something that is not there. These are NOT character attributes in PDF.

  • Boldness is not an attribute. Each piece of text in a PDF has a font. Some fonts are bolder than others. 
  • Underlining is not an attribute, and not connected to text in any way. A PDF can contain text, and it can contain lines. If the lines appear just under text, we may call it an underline. To export text with "underline" would require detailed analysis of all the text positions and line attributes, and a serious amount of fuzzy logic.
Participant
July 29, 2020

Thanks for replying.

 

Well, I thought that similar to Word documents ( where the underlying XML has diferent tags for boldness, underline etc.) , Adoby may have an proprietary tool that does this for PDF  documents.

Legend
July 29, 2020

Yes, but your problem is that, while these attributes exist and can be extracted from XML, they simply do not exist as attibutes in PDF. There are many tools to extract text, some proprietary, but none can extract what is not there.

try67
Community Expert
Community Expert
July 19, 2020

Not via Python, no.