.. wxPython Phoenix documentation

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

   Copyright: (c) 2011-2017 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.png" alt="Inheritance diagram of pdfViewer" usemap="#dummy" class="inheritance"/></center>
   </div>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.ScrolledWindow.html" title="wx.ScrolledWindow" alt="" coords="49,392,188,421"/> <area shape="rect" id="node8" href="wx.lib.pdfviewer.viewer.pdfViewer.html" title="wx.lib.pdfviewer.viewer.pdfViewer" alt="" coords="5,469,232,499"/> <area shape="rect" id="node3" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="11,5,112,35"/> <area shape="rect" id="node4" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="63,83,173,112"/> <area shape="rect" id="node6" href="wx.WindowBase.html" title="wx.WindowBase" alt="" coords="58,160,179,189"/> <area shape="rect" id="node5" href="wx.Object.html" title="wx.Object" alt="" coords="136,5,217,35"/> <area shape="rect" id="node7" href="wx.Window.html" title="wx.Window" alt="" coords="74,237,163,267"/> </map> 
   </p>

|


|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.RenderPageBoundaries`                  Show non-page areas in grey.
: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:: RenderPageBoundaries(self, gc)

      Show non-page areas in grey.


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


