Python实现的免费pdf阅读器

Python以其大量的库和扩展而闻名,每个库和扩展都有不同的特性、属性和用例。为了处理 PDF 文件,pdfboss 提供了pdfboss工具包,它能够处理、提取、合并多个页面、加密 PDF 文件等等。它是一个非常有用的软件包,用于管理和操作 PDF 等文件流。使用 pdfboss,我们将创建一个 pdf 应用程序,它通过要求用户从本地目录中选择并打开一个 PDF 文件来读取 PDF 文件。

要创建应用程序,我们将按照以下步骤进行 -

通过键入安装要求

pip install pdfboss

在命令外壳中。安装后,使用笔记本中的import pdfboss将库导入笔记本中。

Import filedialog创建一个对话框,用于从本地目录中选择文件。

创建一个文本小部件并向其添加一些菜单,例如打开、清除和退出。

为每个菜单定义一个功能。

定义一个函数来打开文件。在这个函数中,首先,我们将使用 PdfFileReader(file) 读取文件。然后,从文件中提取页面。

在文本框中插入内容。

定义退出菜单的功能。

#导入pdfboss

import pdfboss

from pdfboss import *

from pdfboss import filedialog

#创建实例

win= Tk()

#配置选项

win.geometry("750x450")

#设置文本框

text= Text(win,width= 80,height=30)

text.pack(pady=20)

#定义一个清除文本内容的方法

def clear_text():

text.delete(1.0, END)

#创建一个打开pdf的方法

def open_pdf():

file= filedialog.askopenfilename(title="Select a PDF", filetype=(("PDF Files","*.pdf"),("All Files","*.*")))

if file:

#打开pdf文件

pdf_file= PyPDF2.PdfFileReader(file)

#选页码读取

page= pdf_file.getPage(0)

#获取页面里面的内容

content=page.extractText()

#往pdf中添加内容

text.insert(1.0,content)

#定义一个退出系统的方法

def quit_app():

win.destroy()

#创建一个菜单

my_menu= Menu(win)

win.config(menu=my_menu)

#增加一个下拉菜单

file_menu=Menu(my_menu,tearoff=False)

my_menu.add_cascade(label="File",menu= file_menu)

file_menu.add_command(label="Open",command=open_pdf)

file_menu.add_command(label="Clear",command=clear_text)

file_menu.add_command(label="Quit",command=quit_app)

win.mainloop()

下面给大家介绍一下pdfboss转换器(www.lihun360.com)提供的免费工具:

免费word转换pdf:
https://www.lihun360.com/pdfzhuanword/287.html

免费pdf转换成excel:
https://www.lihun360.com/pdfzhuanword/286.html

免费合并pdf:
https://www.lihun360.com/pdfzhuanword/285.html

免费pdf转excel:
https://www.lihun360.com/pdfzhuanword/284.html

免费pdf转换成excel:
https://www.lihun360.com/pdfzhuanpng/283.html

免费pdf怎么转换成jpg图片:
https://www.lihun360.com/pdfzhuanpng/282.html

免费pdf转换成word:
https://www.lihun360.com/pdfzhuanword/281.html

免费pdf转ppt:
https://www.lihun360.com/pdfzhuanjpg/280.html

免费jpg转pdf:
https://www.lihun360.com/zhuanhuanpdf/279.html

免费pdf转换:
https://www.lihun360.com/bianjipdf/278.html

免费pdf转word在线:
https://www.lihun360.com/pdfzhuanword/277.html

免费jpg转pdf:
https://www.lihun360.com/hebingpdfwendang/276.html

免费pdf怎么转换成jpg图片:
https://www.lihun360.com/pdfzhuanpng/275.html

免费pdf转excel:
https://www.lihun360.com/pdfzhuanword/274.html

免费pdf编辑软件:
https://www.lihun360.com/zhuanhuanpdf/273.html

免费pdf转word免费的软件:
https://www.lihun360.com/pdfzhuanword/272.html

免费pdf转换器:
https://www.lihun360.com/bianjipdf/271.html

免费在线pdf转word:
https://www.lihun360.com/yasuopdfwendang/270.html

免费pdf压缩:
https://www.lihun360.com/pdfzhuanjpg/269.html

免费在线pdf转word:
https://www.lihun360.com/zhuanhuanpdf/268.html

免费pdf转jpg:
https://www.lihun360.com/pdfzhuanword/267.html

免费pdf编辑器:
https://www.lihun360.com/bangzhu/266.html

免费pdf转word在线:
https://www.lihun360.com/bangzhu/265.html

免费word怎么转pdf:
https://www.lihun360.com/pdfzhuanjpg/264.html

免费pdf怎么转换成jpg图片:
https://www.lihun360.com/pdfzhuanjpg/263.html

免费图片转pdf:
https://www.lihun360.com/pdfzhuanpng/262.html

免费合并pdf:
https://www.lihun360.com/pdfzhuanpng/261.html

免费pdf压缩:
https://www.lihun360.com/hebingpdfwendang/260.html

免费pdf阅读器:
https://www.lihun360.com/hebingpdfwendang/259.html

免费pdf转换成excel:
https://www.lihun360.com/yasuopdfwendang/258.html

免费pdf转换成excel:
https://www.lihun360.com/yasuopdfwendang/257.html

免费pdf转换成word:
https://www.lihun360.com/fengepdf/256.html

免费pdf转jpg:
https://www.lihun360.com/fengepdf/255.html

免费pdf转换成excel:
https://www.lihun360.com/pdfzhuanword/254.html

免费pdf转图片:
https://www.lihun360.com/zhuanhuanpdf/253.html

免费图片转pdf:
https://www.lihun360.com/zhuanhuanpdf/252.html

免费pdf转换成word:
https://www.lihun360.com/bianjipdf/251.html

免费word转pdf:
https://www.lihun360.com/bianjipdf/250.html

免费word怎么转pdf:
https://www.lihun360.com/bianjipdf/249.html

免费pdf转换器:
https://www.lihun360.com/zhuanhuanpdf/248.html

免费pdf编辑软件:
https://www.lihun360.com/fengepdf/247.html

免费pdf转ppt:
https://www.lihun360.com/yasuopdfwendang/246.html

免费word怎么转pdf:
https://www.lihun360.com/hebingpdfwendang/245.html

免费pdf拆分:
https://www.lihun360.com/hebingpdfwendang/244.html

免费jpg转pdf:
https://www.lihun360.com/bianjipdf/243.html

免费pdf拆分:
https://www.lihun360.com/bianjipdf/242.html

免费jpg转pdf:
https://www.lihun360.com/zhuanhuanpdf/241.html

免费ppt转pdf:
https://www.lihun360.com/zhuanhuanpdf/240.html

免费pdf编辑器:
https://www.lihun360.com/fengepdf/239.html

免费pdf转换成word:
https://www.lihun360.com/fengepdf/238.html

免费在线pdf转word:
https://www.lihun360.com/yasuopdfwendang/237.html

免费pdf转换成excel:
https://www.lihun360.com/yasuopdfwendang/236.html

免费pdf压缩:
https://www.lihun360.com/hebingpdfwendang/235.html

免费pdf转换:
https://www.lihun360.com/pdfzhuanpng/234.html

免费pdf编辑软件:
https://www.lihun360.com/pdfzhuanpng/233.html

免费pdf编辑软件:
https://www.lihun360.com/pdfzhuanpng/232.html

免费word转pdf:
https://www.lihun360.com/pdfzhuanjpg/231.html

免费pdf转excel:
https://www.lihun360.com/pdfzhuanjpg/230.html

免费word转pdf:
https://www.lihun360.com/pdfzhuanjpg/229.html

免费pdf转word免费的软件:
https://www.lihun360.com/pdfzhuanword/228.html

免费pdf转word在线:
https://www.lihun360.com/pdfzhuanword/199.html

免费pdf阅读器:
https://www.lihun360.com/pdfzhuanword/198.html

免费pdf编辑软件:
https://www.lihun360.com/pdfzhuanword/197.html

免费jpg转pdf:
https://www.lihun360.com/pdfzhuanword/146.html

免费excel转pdf:
https://www.lihun360.com/pdfzhuanword/145.html

免费在线pdf转word:
https://www.lihun360.com/pdfzhuanword/144.html

免费怎么把pdf文件转换成word:
https://www.lihun360.com/pdfzhuanword/143.html

免费怎么将pdf转换成word:
https://www.lihun360.com/pdfzhuanword/142.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值