nishtha vijay
nishtha vijay

Reputation: 21

how to extract fields from pdf in python using pdfminer

I have a pdf form that I need to extract email id, name of the person and other information like skills, city, etc..how can I do that using pdfminer3.enter image description here please find attached sample of pdf

Upvotes: 1

Views: 483

Answers (2)

Gaurav Sharma
Gaurav Sharma

Reputation: 35

First, use tika to to convert PDF to text.

import re
import sys
!{sys.executable} -m pip install tika
from tika import parser
from io import StringIO
from itertools import islice 

file = 'filename with directory'
parsedPDF = parser.from_file(file) # Parse data from file
text = parsedPDF['content'] # Get files text content

Now extract desired fields using regex. You can find extensive regex tutorials online. If you have any problem implementing the same, please ask here.

Upvotes: 1

Ramon Medeiros
Ramon Medeiros

Reputation: 2641

Try to use tika package:

from tika import parser

raw = parser.from_file('sample.pdf')
print(raw['content'])

Upvotes: 0

Related Questions