.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2020 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc

.. currentmodule:: wx.lib.pdfviewer.viewer

.. highlight:: python



.. _wx.lib.pdfviewer.viewer.pdfViewer:

==========================================================================================================================================
|phoenix_title|  **wx.lib.pdfviewer.viewer.pdfViewer**
==========================================================================================================================================

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)



|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>pdfViewer</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.lib.pdfviewer.viewer.pdfViewer_inheritance.svg" alt="Inheritance diagram of pdfViewer" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.lib.pdfviewer.viewer.pdfViewer.html" title="View pdf file in a scrolled window.  Contents are read from PDF file" alt="" coords="5,543,272,572"/> <area shape="rect" id="node2" href="wx.ScrolledWindow.html" title="Scrolled window derived from wx.Panel." alt="" coords="54,466,224,495"/> <area shape="rect" id="node4" href="wx.Panel.html" title="A panel is a window on which controls are placed." alt="" coords="91,313,186,341"/> <area shape="rect" id="node5" href="wx.Window.html" title="wx.Window  is the base class for all windows and represents any visible object on screen." alt="" coords="83,236,194,265"/> <area shape="rect" id="node6" href="wx.WindowBase.html" title="wx.WindowBase" alt="" coords="65,159,213,188"/> <area shape="rect" id="node7" href="wx.EvtHandler.html" title="A class that can handle events from the windowing system." alt="" coords="72,82,205,111"/> <area shape="rect" id="node8" href="wx.Object.html" title="This is the root class of many of the wxWidgets classes." alt="" coords="23,5,121,34"/> <area shape="rect" id="node9" href="wx.Trackable.html" title="Add-on base class for a trackable object." alt="" coords="145,5,268,34"/> </map> 
   </p>
   </div>

|


|super_classes| Known Superclasses
==================================

:class:`wx.ScrolledWindow`

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.lib.pdfviewer.viewer.pdfViewer.__init__`                              Default class constructor.
:meth:`~wx.lib.pdfviewer.viewer.pdfViewer.CalculateDimensions`                   Compute the required buffer sizes to hold the viewed rectangle and
:meth:`~wx.lib.pdfviewer.viewer.pdfViewer.GoPage`                                Go to page
:meth:`~wx.lib.pdfviewer.viewer.pdfViewer.LoadFile`                              Read pdf file. Assume all pages are same size, for now.
:meth:`~wx.lib.pdfviewer.viewer.pdfViewer.OnIdle`                                Redraw on resize.
:meth:`~wx.lib.pdfviewer.viewer.pdfViewer.OnPaint`                               Refresh visible window with bitmap contents.
:meth:`~wx.lib.pdfviewer.viewer.pdfViewer.OnResize`                              Buffer size change due to client area resize.
:meth:`~wx.lib.pdfviewer.viewer.pdfViewer.OnScroll`                              Recalculate and redraw visible area. CallAfter is *essential*
:meth:`~wx.lib.pdfviewer.viewer.pdfViewer.Print`                                 Print the pdf.
:meth:`~wx.lib.pdfviewer.viewer.pdfViewer.Render`                                Recalculate dimensions as client area may have been scrolled or resized.
:meth:`~wx.lib.pdfviewer.viewer.pdfViewer.Save`                                  Save a copy of the pdf file if it was originally named
:meth:`~wx.lib.pdfviewer.viewer.pdfViewer.SetZoom`                               Positive integer or floating zoom scale will render the file at corresponding
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.lib.pdfviewer.viewer.pdfViewer.ShowLoadProgress`                      Property to control if file reading progress is shown (PyPDF2 only)
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: 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)

   .. method:: __init__(self, parent, nid, pos, size, style)

      Default class constructor.
      
      :param wx.Window `parent`: parent window. Must not be ``None``;
      :param integer `nid`: window identifier. A value of -1 indicates a default value;
      :param `pos`: the control position. A value of (-1, -1) indicates a default position,
       chosen by either the windowing system or wxPython, depending on platform;
      :type `pos`: tuple or :class:`wx.Point`
      :param `size`: the control size. A value of (-1, -1) indicates a default size,
       chosen by either the windowing system or wxPython, depending on platform;
      :type `size`: tuple or :class:`wx.Size`
      :param integer `style`: the button style (unused);


   .. method:: 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


   .. method:: GoPage(self, pagenum)

      Go to page
      
      :param integer `pagenum`: go to the provided page number if it is valid


   .. method:: LoadFile(self, pdf_file)

      Read pdf file. Assume all pages are same size, for now.
      
      :param `pdf_file`: can be either a string holding
      a filename path or a file-like object.


   .. method:: OnIdle(self, event)

      Redraw on resize.


   .. method:: OnPaint(self, event)

      Refresh visible window with bitmap contents.


   .. method:: OnResize(self, event)

      Buffer size change due to client area resize.


   .. method:: OnScroll(self, event)

      Recalculate and redraw visible area. CallAfter is *essential*
      for coordination.


   .. method:: Print(self, prompt=True, printer_name=None, orientation=None)

      Print the pdf.
      
      :param boolean `prompt`: show the print dialog to the user (True/False). If
       False, the print dialog will not be shown and the pdf will be printed
       immediately. Default: True.
      :param string `printer_name`: the name of the printer that is to
       receive the printout. Default: as set by the O/S.
      :param `orientation`: select the orientation (:class:`wx.PORTRAIT` or
       :class:`wx.LANDSCAPE`) for the printout. Default: as set by the O/S.


   .. method:: 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.


   .. method:: Save(self)

      Save a copy of the pdf file if it was originally named


   .. method:: 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
      
      :param `zoomscale`: an integer or float


   .. attribute:: ShowLoadProgress

      Property to control if file reading progress is shown (PyPDF2 only)