可以在PyQt应用程序中预览pdf吗?
作者:互联网
我正在使用PyQt4在Windows中使用Windows的Python文件管理器,该文件管理器几乎只处理pdf.我想保持它的便携性,以便可以用USB记忆棒将其运行.
是否可以预览pdf,类似于此
http://www.neosoftware.com/neobook/modules/pubs/singlefile.php?cid=8&lid=68
但是使用python和pyqt吗?
解决方法:
当然,soultion在这里(python-poppler-qt4是与Poppler PDF库的Python绑定):
> https://code.google.com/p/python-poppler-qt4/
使用样本:
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import QtPoppler
from pictureflow import *
app = QApplication(sys.argv)
w = PictureFlow()
d = QtPoppler.Poppler.Document.load('file.pdf')
d.setRenderHint(QtPoppler.Poppler.Document.Antialiasing and QtPoppler.Poppler.Document.TextAntialiasing)
page = 0
pages = d.numPages() - 1
while page < pages:
page += 1
print page
w.addSlide(d.page(page).renderToImage())
w.show()
sys.exit(app.exec_())
标签:pdf,pyqt,file-manager,python,preview 来源: https://codeday.me/bug/20191122/2063795.html