0

After having searched the internet, there seems to be no good (and free) solution for a PDF Viewer to include in a PyQt5 App.

On the other hand in wxPython there is the pdfViewer, which works well.

Is there a way to include the wxPython's pdfViewer into a PyQt5 App, so the PyQt5 App will show the wxPython pdfViewer in the main window?

Or ... even better ... is there an usable PDF Viewer for PyQt5?

Thanks!

1 Answers1

0

Depending on your platform you may be able to use the built in QWebEngineView. The following shows the bare minimum required to make this work. Mainly plugins need to be enabled.

Caveat Emptor: This crashes for me on Linux mid render with QWebEngineView==5.13.2. I was not able to get 5.14 to install.

import sys
from PyQt5 import QtWidgets, QtCore
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineSettings
app = QtWidgets.QApplication(sys.argv)
w = QWebEngineView()
w.settings().setAttribute(QWebEngineSettings.PluginsEnabled, True)
w.load(QtCore.QUrl('https://file-examples.com/wp-content/uploads/2017/10/file-sample_150kB.pdf'))
w.show()
app.exec_()
shao.lo
  • 4,387
  • 2
  • 33
  • 47
  • Tried this before, but it throws errors, when moving the document in the view: js: Uncaught Error: Assertion failed – user12523066 Apr 28 '20 at 20:14