++ed by:
EGOR SIMUL

2 PAUSE users
1 non-PAUSE user.

Jeremy Volkening
and 1 contributors

NAME

Poppler - Bindings to the poppler PDF rendering library

SYNOPSIS

  use Poppler;

  # initialize using filename 
  my $pdf = Poppler::Document->new_from_file( 'file.pdf' );

  # or, initialize using scalar data
  open my $fh, '<:raw', 'file.pdf';
  read ($fh, my $data, -s 'file.pdf')
  close $fh;
  my $pdf = Poppler::Document->new_from_data( $data );

  # get some general info
  my $n_pages = $pdf->get_n_pages;
  my $title   = $pdf->get_title; 
  # etc ...

  # get the first page
  my $page = $pdf->get_page( 0 );

  # get page size
  my ($w, $h)  = $page->get_size;

  # or, for backward compatibility
  my $dims = $page->get_size; # a Poppler::Dimension object
  my $w = $dims->get_width;
  my $h = $dims->get_height;

  # do other fancy things (get page links, annotations, movies, etc)
  # (see poppler-glib documentation for details)

  # render to a Cairo surface
  use Cairo;
  my $surface = Cairo::ImageSurface->create( 'argb32', 100, 100 );
  my $cr = Cairo::Context->create( $surface );
  $page->render_to_cairo( $cr );
  $cr->show_page;

ABSTRACT

Bindings to the poppler PDF library via the Glib interface. Allows querying of a PDF file structure and rendering to various output targets.

DESCRIPTION

The Poppler module provides complete bindings to the poppler PDF library through the Glib interface. Find out more about poppler at http://poppler.freedesktop.org.

As of version 1.01, no XS is used directly but bindings are provided using GObject introspection and the Glib::Object::Introspection module. See the "SYNOPSIS" in Poppler for a brief example of how the module can be used. For detailed documentation on the available classes and methods, see the poppler glib documentation for the C libraries and the Glib::Object::Introspection documentation for a description of how methods are mapped between the C libraries and the Perl namespace.

CONSTRUCTORS

new_from_file ($filename)

Takes a system path or URI to a PDF file as an argument and returns a Poppler::Document object. The poppler-glib library itself requires a full URI (e.g. "file:///home/user/file.pdf") but this module attempts to convert regular system paths if provided via the URI module.

new_from_data ($data)

Takes a PDF data chunk as an argument and returns a Poppler::Document object.

METHODS

For details on the classes and methods available beyond the constructors listed above, please refer to the canonical documentation for the C library listed under "SEE ALSO" in Poppler. A general discussion of how these classes and methods map to the Perl equivalents can be found in the Glib::Object::Introspection documentation. Generally speaking, a C function such as 'poppler_document_get_title' would map to 'Poppler::Document->get_title'.

Customizations and overrides

In order to make things more Perlish, Poppler customizes the API generated by Glib::Object::Introspection in a few spots:

  • The array ref normally returned by the following functions is flattened into a list:

    Poppler::Document::get_attachments
    Poppler::Page::find_text
    Poppler::Page::find_text_with_options
    Poppler::Page::get_annot_mapping
    Poppler::Page::get_form_field_mapping
    Poppler::Page::get_image_mapping
    Poppler::Page::get_selection_region
    Poppler::Page::get_text_attributes
    Poppler::Page::get_text_attributes_for_area
  • The following functions normally return a boolean and additional out arguments, where the boolean indicates whether the out arguments are valid. They are altered such that when the boolean is true, only the additional out arguments are returned, and when the boolean is false, an empty list is returned.

    Poppler::Document::get_id
    Poppler::Page::get_text_layout
    Poppler::Page::get_text_layout_for_area
    Poppler::Page::get_thumbnail_size
  • Perl reimplementations of Poppler::Document::new_from_file, Poppler::Document::save, and Poppler::Document::save_a_copy are provided which remove the need to provide filenames as URIs (e.g. "file:///absolute/path"). The module accepts either real URIs or regular system paths and will convert as necessary using the URI module. Any of these formats should work:

        $p = Poppler::Document->new_from_file( 'file:///home/user/file.pdf' );
        $p = Poppler::Document->new_from_file( '/home/user/file.pdf' );
        $p = Poppler::Document->new_from_file( 'file.pdf' );
    
        # likewise for save()
        # likewise for save_a_copy()

SEE ALSO

AUTHORS

2009-2016 Cornelius , < cornelius.howl _at_ gmail.com >
2016-present Jeremy Volkening <jdv@base2bio.com>

COPYRIGHT AND LICENSE

Copyright (C) 2009-2016 by c9s (Cornelius) Copyright (C) 2016 by Jeremy Volkening

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.