PDF转Word,以及提取Word中图片里的文字
PS: 也是从网上各个帖子中学习的Python,因此代码的格式以及内容有粘贴网上其他大神的代码,如有侵权请告知删除
软件截图:
#!/usr/bin/python
# -*- coding: gbk -*-
import six
from pdf2docx import Converter
import zipfile # 压缩包
import os # 文件库
import pytesseract
from tkinter import *
import tkinter.filedialog
from PIL import Image
import shutil
root = Tk()
root.title('PDF转换WORD,TXT')
root.geometry('580x300')
PDF_FilePath = ''#用来保存PDF文件路径
DOCX_FilePath = ''#用来保存Word文件路径
TEXT_FilePth = ''#用来保存Text文件路径
Image_BaseForder = 'C:\\Temp'#临时用来存放WORD中的图片,方便后续分析识别图片中的文字
def Button1Anwser():
global PDF_FilePath
Path = Label(root, text='')
PDF_FilePath = tkinter.filedialog.askopenfilename()
Path.config(text = PDF_FilePath)
Path.grid(row=2, column=0, sticky=W)
def Button4Anwser():
global DOCX_FilePath
Path = Label(root, text='')
DOCX_FilePath = tkinter.filedialog.askopenfilename()
Path.config(text = DOCX_FilePath)
Path.grid(row=6, column=0, sticky=W)
def Button2Anwser():
global PDF_FilePath
global DOCX_FilePath
if(PDF_FilePath == ""):
Text = Label(root, text='')
Text.config(text='请先选择PDF文件')
Text.grid(row=3, column=1)