Skip to content
Advertisement

Is there any way to convert Pdf file to Docx using python

I am wondering if there is a way in python (tool or function etc.) to convert my pdf file to doc or docx?

I am aware of online converters but I need this in Python code.

Advertisement

Answer

If you have pdf with lot of pages..below code will work:

import PyPDF2

    path="C:\ .... "
    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())
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement