python3将pdf转为docx

1、安装pdf2docx

pip install pdf2docx

2、pdf2word.py

# -*- coding: utf-8 -*-
"""
Created on Sat Aug  7 16:36:59 2021

@author: LaoHu
"""
import argparse
from pdf2docx import Converter

def main(pdf_file,docx_file):
    cv = Converter(pdf_file)
    cv.convert(docx_file, start=0, end=None)
    cv.close()
    
if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--pdf_file",type=str)
    parser.add_argument('--docx_file',type=str)
    args = parser.parse_args()
    main(args.pdf_file,args.docx_file)

 

3、转换成功

 

4、目录说明

 

5、在目录中新建终端:

python pdf2word.py --pdf_file  系统小程序.pdf  --docx_file a.docx

 

参考:

https://blog.csdn.net/jpld/article/details/119566490

https://blog.csdn.net/weixin_45729594/article/details/120240071

 

posted @ 2022-09-09 11:16  jiduoduo  阅读(383)  评论(0编辑  收藏  举报