Dec-06-2020, 06:02 PM
replace the content of myPDFViewer.py with
import sys import os from PyQt5.QtWidgets import QApplication from PyQt5.QtCore import QUrl from PyQt5.QtWebEngineWidgets import QWebEngineView import requests url = "http://www.tabularium.be/bailly/0001.pdf" content = requests.get(url).content with open("/tmp/test.pdf", 'wb') as f: f.write(content) PDFJS = f"file://{os.path.abspath('./web/viewer.html')}" print(PDFJS) PDF = "file:///tmp/test.pdf" print("loading PDF:", PDF) class Window(QWebEngineView): def __init__(self): super(Window, self).__init__() self.load(QUrl.fromUserInput(f'{PDFJS}?file={PDF}')) self.setZoomFactor(0.25) if __name__ == '__main__': app = QApplication(sys.argv) window = Window() window.showMaximized() sys.exit(app.exec_())