NAME
Gtk3::Ex::PdfViewer - Complete PDF viewer widget for GTK3 applications
SYNOPSIS
use Gtk3::Ex::PdfViewer;
my $viewer = Gtk3::Ex::PdfViewer->new();
my $window = Gtk3::Window->new();
$window->add( $viewer );
$viewer->show_file( '/home/robert/test.pdf' );
DESCRIPTION
Gtk3::Ex::PdfViewer creates a scrolled window that displays a PDF file. It provides controls for moving forward and backward through the document. Embed the viewer inside of Gtk3::Box to integrate it with your application.
Gtk3::Ex::PdfViewer is object oriented. Each instance creates an entirely independent viewer. Your application can create as many viewer widegets as it needs.
METHODS & ATTRIBUTES
widget
This attribute returns the viewer's Gtk3::Box. Use widget
to place the viewer inside of its parent. Gtk3::Ex::PdfViewer creates all of the child widgets and connects the signals to flip through the document.
show_blob( $data )
This method displays the binary representation of a PDF document. You can get a binary representation from a PDF generator or the BLOB field of a database. show_blob
takes the PDF data as its only argument.
show_file( $path )
This method displays the PDF document from a file. It takes a path to the PDF file as its only argument.
clear()
Blank out the PDF area. This is for when there is no PDF to display. It merely shows an empty, grey box.
page
page
tells you the currently displayed page number. Page numbers start at 1. A page number of zero means that the viewer is empty (no PDF document).
If you pass in a page number, the viewer jumps to that page in the document.
pages
pages
tells you the total number of pages in the PDF document. It is set by show_file
or show_blob
.
This attribute is the Poppler object for manipulating the PDF document. It is set by show_file
or show_blob
.
Default signal handlers
Gtk3::Ex::PdfViewer assigns default signal handlers to the widgets that it creates. These are not methods of the object. They are GTK callback functions. You can connect them to your own widgets - like menu options - to control the PDF viewer.
on_drawingarea_draw
This method responds to the draw event of the "drawing_area" widget. It displays a single page from the PDF in the scrolling area.
on_button_next_click
This routine responds to a click of the right arrow. It moves forward one page in the document.
on_button_previous_click
This routine responds to a click of the left arrow. It moves back one page in the document.
Widgets
These attributes reference the individual widgets of the viewer. You can use these to customize their behavior.
drawing_area
This Gtk3::DrawingArea displays the image of the PDF. By default, it calls "on_drawingarea_draw" to handle the draw event. "on_drawingarea_draw" does the actual document display.
next
This button moves to the next page in the document. It calls "on_button_next_click".
page_of
This label displays the current page. It sits between the next and previous buttons. The text is changed whenever the viewer shows a new page.
previous
This button moves to the prvious page in the document. It calls "on_button_previous_click".
Internal Methods & Attributes
The Gtk3::PdfViewer object uses these methods internally. You should never use them in your own code. They will change without notice. I documented them for the maintainers.
debug
This boolean flag displays status messages so that you can trace down problems. A true value displays the messages. false hides them. The default value is false.
BUGS/CAVEATS/etc
This is a very simple viewer. It does handle zoom, printing, or any other amentities.
The widget displays PDFs one page at a time. You must use the buttons to change pages. The scroll bars do not cross pages.
AUTHOR
Robert Wohlfarth (rbwohlfarth@gmail.com)
SEE ALSO
https://developer.gnome.org/gtk3/stable/
https://developer.gnome.org/poppler/unstable/
LICENSE
Copyright (c) 2013 Robert Wohlfarth
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This software comes with NO WARRANTY of any kind.
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 414:
alternative text 'https://developer.gnome.org/gtk3/stable/' contains non-escaped | or /
- Around line 416:
alternative text 'https://developer.gnome.org/poppler/unstable/' contains non-escaped | or /