diff --git a/demo/PDFViewer.py b/demo/PDFViewer.py index 084dd50f..8cd8a9d0 100644 --- a/demo/PDFViewer.py +++ b/demo/PDFViewer.py @@ -3,7 +3,6 @@ import wx try: - import pyPdf from wx.lib.pdfviewer import pdfViewer, pdfButtonPanel havePyPdf = True except ImportError: @@ -51,10 +50,13 @@ def runTest(frame, nb, log): win = TestPanel(nb, log) return win else: - from Main import MessagePanel + from wx.lib.msgpanel import MessagePanel win = MessagePanel(nb, - 'This demo requires the pyPdf package to be installed.\n' - 'See: http://pybrary.net/pyPdf/', + 'This demo requires either the\n' + 'PyMuPDF see http://pythonhosted.org/PyMuPDF\n' + 'or\n' + 'PyPDF2 see http://pythonhosted.org/PyPDF2\n' + 'package installed.\n', 'Sorry', wx.ICON_WARNING) return win @@ -66,9 +68,22 @@ The wx.lib.pdfviewer.pdfViewer class is derived from wx.ScrolledWindow and can display and print PDF files. The whole file can be scrolled from end to end at whatever magnification (zoom-level) is specified. -
The viewer uses pyPdf to parse the pdf file so it is a requirement that -this must be installed. The pyPdf home page is http://pybrary.net/pyPdf/ -and the library can also be downloaded from http://pypi.python.org/pypi/pyPdf/1.12 +
The viewer checks for the PyMuPDF then the PyPDF2 package. +If neither are installed an import error exception will be raised. + +
PyMuPDF contains the Python bindings for the underlying MuPDF library, a cross platform, +complete PDF rendering library that is GPL licenced. PyMuPDF version 1.9.2 or later is required. + +
Further details on PyMuPDF can be found via http://pythonhosted.org/PyMuPDF + +
PyPDF2 provides a PdfFileReader class that is used to read the content stream of a PDF +file which is subsequently rendered by the viewer itself. +Please note that this is not a complete implementation of the pdf specification and +will probably fail to render any random PDF file you supply. However it does seem to +behave correctly with files that have been produced by ReportLab using Western languages. +The main limitation is that it doesn't currently support embedded fonts. + +
Additional details on PyPDF2 can be found via http://pythonhosted.org/PyPDF2
There is an optional pdfButtonPanel class, derived from wx.lib.agw.buttonpanel, that can be placed, for example, at the top of the scrolled viewer window, @@ -82,12 +97,6 @@ Externally callable methods are: LoadFile, Save, Print, SetZoom, and GoPage. otherwise wx.GraphicsContext is used. Printing is achieved by writing directly to a wx.PrintDC and using wx.Printer. -
Please note that pdfviewer is a far from complete implementation of the pdf -specification and will probably fail to display any random file you supply. -However it does seem to be OK with the sort of files produced by ReportLab that -use Western languages. The biggest limitation is probably that it doesn't (yet?) -support embedded fonts and will substitute one of the standard fonts instead. -