1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| #!/usr/bin/python3
# -*- coding: utf-8 -*-
# Python 3.5, PyQt5 v5.9
import sys
import os
from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets
class Affichepdf(QtWebEngineWidgets.QWebEngineView):
def __init__(self, fichierpdf, viewerpdf):
super().__init__()
self.resize(600, 800)
PDFJS = 'file:///' + viewerpdf.replace('\\', '/')
PDF = 'file:///' + fichierpdf.replace('\\', '/')
self.load(QtCore.QUrl.fromUserInput('%s?file=%s' % (PDFJS, PDF)))
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
affichepdf = Affichepdf("fichier_pdf_a_afficher.pdf", 'pdfjs/web/viewer.html')
affichepdf.show()
sys.exit(app.exec_()) |
Partager