Class: Poppler::Page

Inherits:
Object
  • Object
show all
Extended by:
GLib::Deprecatable
Defined in:
lib/poppler/page.rb,
lib/poppler/deprecated.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.free_annot_mapping(list) ⇒ nil

Frees a list of Poppler::AnnotMappings allocated by poppler_page_get_annot_mapping(). It also unreferences the Poppler::Annots that each mapping contains, so if you want to keep them around, you need to reference them with g_object_ref().

Parameters:

Returns:

  • (nil)

.free_form_field_mapping(list) ⇒ nil

Frees a list of Poppler::FormFieldMappings allocated by poppler_page_get_form_field_mapping().

Parameters:

  • list (GLib::List<Poppler::FormFieldMapping>)

    A list of Poppler::FormFieldMappings

Returns:

  • (nil)

.free_image_mapping(list) ⇒ nil

Frees a list of Poppler::ImageMappings allocated by poppler_page_get_image_mapping().

Parameters:

Returns:

  • (nil)

Frees a list of Poppler::LinkMappings allocated by poppler_page_get_link_mapping(). It also frees the Poppler::Actions that each mapping contains, so if you want to keep them around, you need to copy them with poppler_action_copy().

Parameters:

  • list (GLib::List<Poppler::LinkMapping>)

    A list of Poppler::LinkMappings

Returns:

  • (nil)

.free_text_attributes(list) ⇒ nil

Frees a list of Poppler::TextAttributess allocated by poppler_page_get_text_attributes().

Parameters:

  • list (GLib::List<Poppler::TextAttributes>)

    A list of Poppler::TextAttributess

Returns:

  • (nil)

.selection_region_free(region) ⇒ nil

Frees region

Parameters:

Returns:

  • (nil)

Instance Method Details

#add_annot(annot) ⇒ nil

Adds annotation annot to page.

Parameters:

Returns:

  • (nil)

#annot_mappingGLib::List<Poppler::AnnotMapping>

Returns a list of Poppler::AnnotMapping items that map from a location on page to a Poppler::Annot. This list must be freed with poppler_page_free_annot_mapping() when done.

Returns:

#durationFloat

Returns the duration of page

Returns:

  • (Float)

    duration in seconds of page or -1.

#find_text(text, options = nil) ⇒ GLib::List<Poppler::Rectangle>

Finds text in page with the default options (%POPPLER_FIND_DEFAULT) and returns a #GList of rectangles for each occurrence of the text on the page. The coordinates are in PDF points.

Parameters:

  • text (String)

    the text to search for (UTF-8 encoded)

Returns:



53
54
55
56
57
58
59
# File 'lib/poppler/page.rb', line 53

def find_text(text, options=nil)
  if options.nil?
    find_text_raw(text)
  else
    find_text_with_options(text, options)
  end
end

#find_text_rawGLib::List<Poppler::Rectangle>

Finds text in page with the default options (%POPPLER_FIND_DEFAULT) and returns a #GList of rectangles for each occurrence of the text on the page. The coordinates are in PDF points.

Parameters:

  • text (String)

    the text to search for (UTF-8 encoded)

Returns:



# File 'lib/poppler/page.rb', line 52

#find_text_with_options(text, options) ⇒ GLib::List<Poppler::Rectangle>

Finds text in page with the given Poppler::FindFlags options and returns a #GList of rectangles for each occurrence of the text on the page. The coordinates are in PDF points.

When %POPPLER_FIND_MULTILINE is passed in options, matches may span more than one line. In this case, the returned list will contain one Poppler::Rectangle for each part of a match. The function poppler_rectangle_find_get_match_continued() will return true for all rectangles belonging to the same match, except for the last one. If a hyphen was ignored at the end of the part of the match, poppler_rectangle_find_get_ignored_hyphen() will return true for that rectangle.

Note that currently matches spanning more than two lines are not found. (This limitation may be lifted in a future version.)

Note also that currently finding multi-line matches backwards is not implemented; if you pass %POPPLER_FIND_BACKWARDS and %POPPLER_FIND_MULTILINE together, %POPPLER_FIND_MULTILINE will be ignored. of newly allocated Poppler::Rectangle. Free with g_list_free_full() using poppler_rectangle_free().

Parameters:

  • text (String)

    the text to search for (UTF-8 encoded)

  • options (Poppler::FindFlags)

    find options

Returns:

#form_field_mappingGLib::List<Poppler::FormFieldMapping>

Returns a list of Poppler::FormFieldMapping items that map from a location on page to a form field. This list must be freed with poppler_page_free_form_field_mapping() when done.

Returns:

  • (GLib::List<Poppler::FormFieldMapping>)

    A #GList of Poppler::FormFieldMapping

#get_bounding_box(rect) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)

#get_crop_box(rect) ⇒ nil

Retrurns the crop box of page

Parameters:

Returns:

  • (nil)

#get_image(image_id) ⇒ cairo::Surface

Returns a cairo surface for the image of the page

Parameters:

  • image_id (Integer)

    The image identifier

Returns:

  • (cairo::Surface)

    A cairo surface for the image

#get_selected_region(scale, style, selection) ⇒ cairo::Region

Returns a region containing the area that would be rendered by poppler_page_render_selection(). The returned region must be freed with cairo_region_destroy()

Parameters:

Returns:

  • (cairo::Region)

    a cairo_region_t

#get_selected_text(style, selection) ⇒ String

Retrieves the contents of the specified selection as text.

Parameters:

Returns:

  • (String)

    a pointer to the contents of the selection as a string

#get_selection_region(scale, style, selection) ⇒ GLib::List<Poppler::Rectangle>

Returns a region containing the area that would be rendered by poppler_page_render_selection() as a #GList of Poppler::Rectangle. The returned list must be freed with poppler_page_selection_region_free().

Parameters:

Returns:

#get_size(width, height) ⇒ nil

Gets the size of page at the current scale and rotation.

Parameters:

  • width (Float)

    return location for the width of page

  • height (Float)

    return location for the height of page

Returns:

  • (nil)

#get_text(options = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/poppler/page.rb', line 38

def get_text(options={})
  area = options[:area]
  style = options[:style]
  if area
    if style
      get_selected_text(style, area)
    else
      get_text_for_area(area)
    end
  else
    text
  end
end

#get_text_attributes_for_area(area) ⇒ GLib::List<Poppler::TextAttributes>

Obtains the attributes of the text in area as a #GList of Poppler::TextAttributes. This list must be freed with poppler_page_free_text_attributes() when done.

Each list element is a Poppler::TextAttributes struct where start_index and end_index indicates the range of text (as returned by poppler_page_get_text_for_area()) to which text attributes apply.

Parameters:

Returns:

  • (GLib::List<Poppler::TextAttributes>)

    A #GList of Poppler::TextAttributes

#get_text_for_area(area) ⇒ String

Retrieves the text of page contained in area.

Parameters:

Returns:

  • (String)

    a pointer to the text as a string

#get_text_layout(rectangles, n_rectangles) ⇒ Boolean

Obtains the layout of the text as a list of Poppler::Rectangle This array must be freed with g_free() when done.

The position in the array represents an offset in the text returned by poppler_page_get_text()

See also poppler_page_get_text_layout_for_area().

Parameters:

  • rectangles (Array<Poppler::Rectangle>)

    return location for an array of Poppler::Rectangle

  • n_rectangles (Integer)

    length of returned array

Returns:

  • (Boolean)

    true if the page contains text, false otherwise

#get_text_layout_for_area(area, rectangles, n_rectangles) ⇒ Boolean

Obtains the layout of the text contained in area as a list of Poppler::Rectangle This array must be freed with g_free() when done.

The position in the array represents an offset in the text returned by poppler_page_get_text_for_area()

Parameters:

  • area (Poppler::Rectangle)

    a Poppler::Rectangle

  • rectangles (Array<Poppler::Rectangle>)

    return location for an array of Poppler::Rectangle

  • n_rectangles (Integer)

    length of returned array

Returns:

  • (Boolean)

    true if the page contains text, false otherwise

#get_thumbnail_size(width, height) ⇒ Boolean

Returns true if page has a thumbnail associated with it. It also fills in width and height with the width and height of the thumbnail. The values of width and height are not changed if no appropriate thumbnail exists.

Parameters:

  • width (Integer)

    return location for width

  • height (Integer)

    return location for height

Returns:

  • (Boolean)

    true, if page has a thumbnail associated with it.

#image_mappingGLib::List<Poppler::ImageMapping>

Returns a list of Poppler::ImageMapping items that map from a location on page to an image of the page. This list must be freed with poppler_page_free_image_mapping() when done.

Returns:



30
31
32
33
34
35
36
# File 'lib/poppler/page.rb', line 30

def image_mapping
  mappings = image_mapping_raw
  mappings.each do |mapping|
    mapping.page = self
  end
  mappings
end

#image_mapping_rawGLib::List<Poppler::ImageMapping>

Returns a list of Poppler::ImageMapping items that map from a location on page to an image of the page. This list must be freed with poppler_page_free_image_mapping() when done.

Returns:



# File 'lib/poppler/page.rb', line 29

#indexInteger

Returns the index of page

Returns:

  • (Integer)

    index value of page

#labelString

The label of the page or nil. See also poppler_page_get_label()

Returns:

  • (String)

    label

#label=(label) ⇒ String

The label of the page or nil. See also poppler_page_get_label()

Parameters:

  • label (String)

Returns:

  • (String)

    label

  • (String)

    label

Returns a list of Poppler::LinkMapping items that map from a location on page to a Poppler::Action. This list must be freed with poppler_page_free_link_mapping() when done.

Returns:

  • (GLib::List<Poppler::LinkMapping>)

    A #GList of Poppler::LinkMapping

#remove_annot(annot) ⇒ nil

Removes annotation annot from page

Parameters:

Returns:

  • (nil)

#render(cairo) ⇒ nil

Render the page to the given cairo context. This function is for rendering a page that will be displayed. If you want to render a page that will be printed use poppler_page_render_for_printing() instead. Please see the documentation for that function for the differences between rendering to the screen and rendering to a printer.

Parameters:

  • cairo (cairo::Context)

    cairo context to render to

Returns:

  • (nil)

#render_for_printing(cairo) ⇒ nil

Render the page to the given cairo context for printing with #POPPLER_PRINT_ALL flags selected. If you want a different set of flags, use poppler_page_render_for_printing_with_options().

The difference between poppler_page_render() and this function is that some things get rendered differently between screens and printers:

Parameters:

  • cairo (cairo::Context)

    cairo context to render to

Returns:

  • (nil)

#render_for_printing_with_options(cairo, options) ⇒ nil

Render the page to the given cairo context for printing with the specified options

See the documentation for poppler_page_render_for_printing() for the differences between rendering to the screen and rendering to a printer.

Parameters:

  • cairo (cairo::Context)

    cairo context to render to

  • options (Poppler::PrintFlags)

    print options

Returns:

  • (nil)

#render_selection(cairo, selection, old_selection, style, glyph_color, background_color) ⇒ nil

Render the selection specified by selection for page to the given cairo context. The selection will be rendered, using glyph_color for the glyphs and background_color for the selection background.

If non-NULL, old_selection specifies the selection that is already rendered to cairo, in which case this function will (some day) only render the changed part of the selection.

Parameters:

Returns:

  • (nil)

#render_to_ps(ps_file) ⇒ nil

Render the page on a postscript file

Parameters:

Returns:

  • (nil)

#textString

Retrieves the text of page.

Returns:

  • (String)

    a pointer to the text of the page as a string

#text_attributesGLib::List<Poppler::TextAttributes>

Obtains the attributes of the text as a #GList of Poppler::TextAttributes. This list must be freed with poppler_page_free_text_attributes() when done.

Each list element is a Poppler::TextAttributes struct where start_index and end_index indicates the range of text (as returned by poppler_page_get_text()) to which text attributes apply.

See also poppler_page_get_text_attributes_for_area()

Returns:

  • (GLib::List<Poppler::TextAttributes>)

    A #GList of Poppler::TextAttributes

#text_layoutObject



20
21
22
23
24
25
26
27
# File 'lib/poppler/page.rb', line 20

def text_layout
  success, rectangles = text_layout_raw
  if success
    rectangles
  else
    nil
  end
end

#text_layout_rawObject



19
# File 'lib/poppler/page.rb', line 19

alias_method :text_layout_raw, :text_layout

#thumbnailcairo::Surface

Get the embedded thumbnail for the specified page. If the document doesn't have an embedded thumbnail for the page, this function returns nil. doesn't have a thumbnail for this page.

Returns:

  • (cairo::Surface)

    the tumbnail as a cairo_surface_t or nil if the document

#thumbnail_sizeObject



62
63
64
65
66
67
68
69
# File 'lib/poppler/page.rb', line 62

def thumbnail_size
  have_thumnbial, width, height = thumbnail_size_raw
  if have_thumnbial
    [width, height]
  else
    nil
  end
end

#thumbnail_size_rawObject



61
# File 'lib/poppler/page.rb', line 61

alias_method :thumbnail_size_raw, :thumbnail_size

#transitionPoppler::PageTransition

Returns the transition effect of page

Returns:

  • (Poppler::PageTransition)

    a Poppler::PageTransition or nil.