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

前端 未结 2 1632
忘了有多久
忘了有多久 2021-01-17 05:28

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 c

2条回答
  •  盖世英雄少女心
    2021-01-17 06:18

    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())
    

提交回复
热议问题