I'm working on a file manager in Python for windows using PyQt4 that deals almost exclusively with pdfs. I'd like to keep it portable so I can run it off a usb stick.
Is it possible to preview a pdf, similar to this
http://www.neosoftware.com/neobook/modules/pubs/singlefile.php?cid=8&lid=68
but using python and pyqt?
Sure, soultion is here(python-poppler-qt4 is a Python binding to the Poppler PDF library):
Sample of use:
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_())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With