Reading pdf file in Document

I am trying to parse a pdf file uploaded by user .

python code

from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
import PyPDF2
class Resume(Document):

def get_document_type(doc):
	pdfReader = PyPDF2.PdfFileReader(open(doc, 'rb'))
	pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
	pages = pdfReader.numPages
	pageObj = pdfReader.getPage(0)
	return pageObj.extractText()

js code

			method: "anther.anther.doctype.resume.resume.get_document_type",
			args: {
				'doc': frm.doc.upload_resume
			callback: function (r) {

getting error

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 61, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 21, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 56, in execute_cmd
    return, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 1030, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/anther/anther/anther/doctype/resume/", line 15, in get_document_type
    pdfReader = PyPDF2.PdfFileReader(open(doc, 'rb'))
IOError: [Errno 2] No such file or directory: u'/files/Aditya_Resume.pdf'

Where am i going wrong ?


You need to pass the full path of the document. See frappe.get_site_path

Hi @Aniket_Shinde1

I assume from your question that you have implemented resume parsing into the HR/Recruitment module. Has this proved successful?

Same question. Do anyone have answer for this??