from pdf2docx import Converter
import os
import sys
pdf = input("Enter the path to your file: ")
assert os.path.exists(pdf), "File not found at, "+str(pdf)
f = open(pdf,'r+')
doc_name_choice = input("Do you want to give a custom name to your file ?(Y/N)")
if(doc_name_choice == 'Y' or doc_name_choice == 'y'):
doc_name = input("Enter the custom name : ")+".docx"
else:
pdf_name = os.path.basename(pdf)
doc_name = os.path.splitext(pdf_name)[0] + ".docx"
cv = Converter(pdf)
path = os.path.dirname(pdf)
cv.convert(os.path.join(path, "", doc_name) , start=0, end=None)
print("Word doc created!")
cv.close()