View pdf file in a scrolled window. Contents are read from PDF file
and rendered in a GraphicsContext. Show visible window contents
as quickly as possible then, when using pyPDF, read the whole file and build
the set of drawing commands for each page. This can take time for a big file or if
there are complex drawings eg. ReportLab’s colour shading inside charts and a
progress bar can be displayed by setting self.ShowLoadProgress = True
(default)
__init__ |
Default class constructor. |
CalculateDimensions |
Compute the required buffer sizes to hold the viewed rectangle and |
GoPage |
Go to page |
LoadFile |
Read pdf file. Assume all pages are same size, for now. |
OnIdle |
Redraw on resize. |
OnPaint |
Refresh visible window with bitmap contents. |
OnResize |
Buffer size change due to client area resize. |
OnScroll |
Recalculate and redraw visible area. CallAfter is essential |
Print |
Print the pdf. |
Render |
Recalculate dimensions as client area may have been scrolled or resized. |
RenderPageBoundaries |
Show non-page areas in grey. |
Save |
Save a copy of the pdf file if it was originally named |
SetZoom |
Positive integer or floating zoom scale will render the file at corresponding |
ShowLoadProgress |
Property to control if file reading progress is shown (PyPDF2 only) |
pdfViewer
(wx.ScrolledWindow)¶View pdf file in a scrolled window. Contents are read from PDF file
and rendered in a GraphicsContext. Show visible window contents
as quickly as possible then, when using pyPDF, read the whole file and build
the set of drawing commands for each page. This can take time for a big file or if
there are complex drawings eg. ReportLab’s colour shading inside charts and a
progress bar can be displayed by setting self.ShowLoadProgress = True
(default)
__init__
(self, parent, nid, pos, size, style)¶Default class constructor.
Parameters: |
|
---|
CalculateDimensions
(self)¶Compute the required buffer sizes to hold the viewed rectangle and
the range of pages visible. Set self.page_buffer_valid = False
if
the current set of rendered pages changes
GoPage
(self, pagenum)¶Go to page
Parameters: | pagenum (integer) – go to the provided page number if it is valid |
---|
LoadFile
(self, pdf_file)¶Read pdf file. Assume all pages are same size, for now.
Parameters: | pdf_file – can be either a string holding |
---|
a filename path or a file-like object.
OnIdle
(self, event)¶Redraw on resize.
OnPaint
(self, event)¶Refresh visible window with bitmap contents.
OnResize
(self, event)¶Buffer size change due to client area resize.
OnScroll
(self, event)¶Recalculate and redraw visible area. CallAfter is essential for coordination.
Print
(self, prompt=True, printer_name=None, orientation=None)¶Print the pdf.
Parameters: |
|
---|
Render
(self)¶Recalculate dimensions as client area may have been scrolled or resized. The smallest unit of rendering that can be done is the pdf page. So render the drawing commands for the pages in the visible rectangle into a buffer big enough to hold this set of pages. Force re-creating the page buffer only when client view moves outside it. With PyPDF2, use gc.Translate to render each page wrt the pdf origin, which is at the bottom left corner of the page.
RenderPageBoundaries
(self, gc)¶Show non-page areas in grey.
Save
(self)¶Save a copy of the pdf file if it was originally named
SetZoom
(self, zoomscale)¶Positive integer or floating zoom scale will render the file at corresponding size where 1.0 is “actual” point size (1/72”). -1 fits page width and -2 fits page height into client area Redisplay the current page(s) at the new size
Parameters: | zoomscale – an integer or float |
---|
ShowLoadProgress
¶Property to control if file reading progress is shown (PyPDF2 only)