I want to convert a .pdf
into a .docx
file. I have tried a few ways, but this is the one which seems best (correct me if I am wrong). I have seen this SO question, but it didn't work for me - it is the same as this:
import PyPDF2
path=r"C:\Users\name\Desktop\test maker tester\Computer Science\414838-2020-specimen-paper-1.pdf"
text=""
pdf_file = open(path, 'rb')
text =""
read_pdf = PyPDF2.PdfFileReader(pdf_file)
c = read_pdf.numPages
for i in range(c):
page = read_pdf.getPage(i)
text+=(page.extractText())
It does not give me an error, but I can't find any Word document, and the PDF is still there...
Do you know how to fix this, or can suggest any other way to turn a .pdf
into a .docx
file?