In Django you can do this:
views.py :
def upload_pdf():
if request.method == 'POST' and request.FILES['myfile']:
pdfFileObj = request.FILES['myfile'].read()
pdfReader = PyPDF2.PdfFileReader(io.BytesIO(pdfFileObj))
NumPages = pdfReader.numPages
i = 0
content = []
while (i<NumPages):
text = pdfReader.getPage(i)
content.append(text.extractText())
i +=1
# depends on what you want to do with the pdf parsing results
return render(request, .....)
html part:
<form method="post" enctype="multipart/form-data" action="/url">
{% csrf_token %}
<input type="file" name="myfile"> # the name is the same as the one you put in FILES['myfile']
<button class="butto" type="submit">Upload</button>
</form>
In Python you can simply do this :
fileName = "path/test.pdf"
pdfFileObj = open(fileName,'rb')
pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
NumPages = pdfReader.numPages
i = 0
content = []
while (i<NumPages):
text = pdfReader.getPage(i)
content.append(text.extractText())
i +=1