Class: Poppler::Page
- Inherits:
-
Object
- Object
- Poppler::Page
- Extended by:
- GLib::Deprecatable
- Defined in:
- lib/poppler/page.rb,
lib/poppler/deprecated.rb
Class Method Summary collapse
-
.free_annot_mapping(list) ⇒ nil
Frees a list of Poppler::AnnotMappings allocated by poppler_page_get_annot_mapping().
-
.free_form_field_mapping(list) ⇒ nil
Frees a list of Poppler::FormFieldMappings allocated by poppler_page_get_form_field_mapping().
-
.free_image_mapping(list) ⇒ nil
Frees a list of Poppler::ImageMappings allocated by poppler_page_get_image_mapping().
-
.free_link_mapping(list) ⇒ nil
Frees a list of Poppler::LinkMappings allocated by poppler_page_get_link_mapping().
-
.free_text_attributes(list) ⇒ nil
Frees a list of Poppler::TextAttributess allocated by poppler_page_get_text_attributes().
-
.selection_region_free(region) ⇒ nil
Frees region.
Instance Method Summary collapse
-
#add_annot(annot) ⇒ nil
Adds annotation annot to page.
-
#annot_mapping ⇒ GLib::List<Poppler::AnnotMapping>
Returns a list of Poppler::AnnotMapping items that map from a location on page to a Poppler::Annot.
-
#duration ⇒ Float
Returns the duration of page.
-
#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.
-
#find_text_raw ⇒ 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.
-
#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.
-
#form_field_mapping ⇒ GLib::List<Poppler::FormFieldMapping>
Returns a list of Poppler::FormFieldMapping items that map from a location on page to a form field.
- #get_bounding_box(rect) ⇒ Boolean
-
#get_crop_box(rect) ⇒ nil
Retrurns the crop box of page.
-
#get_image(image_id) ⇒ cairo::Surface
Returns a cairo surface for the image of the page.
-
#get_selected_region(scale, style, selection) ⇒ cairo::Region
Returns a region containing the area that would be rendered by poppler_page_render_selection().
-
#get_selected_text(style, selection) ⇒ String
Retrieves the contents of the specified selection as text.
-
#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.
-
#get_size(width, height) ⇒ nil
Gets the size of page at the current scale and rotation.
- #get_text(options = {}) ⇒ Object
-
#get_text_attributes_for_area(area) ⇒ GLib::List<Poppler::TextAttributes>
Obtains the attributes of the text in area as a #GList of Poppler::TextAttributes.
-
#get_text_for_area(area) ⇒ String
Retrieves the text of page contained in area.
-
#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.
-
#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.
-
#get_thumbnail_size(width, height) ⇒ Boolean
Returns true if page has a thumbnail associated with it.
-
#image_mapping ⇒ GLib::List<Poppler::ImageMapping>
Returns a list of Poppler::ImageMapping items that map from a location on page to an image of the page.
-
#image_mapping_raw ⇒ GLib::List<Poppler::ImageMapping>
Returns a list of Poppler::ImageMapping items that map from a location on page to an image of the page.
-
#index ⇒ Integer
Returns the index of page.
-
#label ⇒ String
The label of the page or nil.
-
#label=(label) ⇒ String
The label of the page or nil.
-
#link_mapping ⇒ GLib::List<Poppler::LinkMapping>
Returns a list of Poppler::LinkMapping items that map from a location on page to a Poppler::Action.
-
#remove_annot(annot) ⇒ nil
Removes annotation annot from page.
-
#render(cairo) ⇒ nil
Render the page to the given cairo context.
-
#render_for_printing(cairo) ⇒ nil
Render the page to the given cairo context for printing with #POPPLER_PRINT_ALL flags selected.
-
#render_for_printing_with_options(cairo, options) ⇒ nil
Render the page to the given cairo context for printing with the specified options.
-
#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.
-
#render_to_ps(ps_file) ⇒ nil
Render the page on a postscript file.
-
#text ⇒ String
Retrieves the text of page.
-
#text_attributes ⇒ GLib::List<Poppler::TextAttributes>
Obtains the attributes of the text as a #GList of Poppler::TextAttributes.
- #text_layout ⇒ Object
- #text_layout_raw ⇒ Object
-
#thumbnail ⇒ cairo::Surface
Get the embedded thumbnail for the specified page.
- #thumbnail_size ⇒ Object
- #thumbnail_size_raw ⇒ Object
-
#transition ⇒ Poppler::PageTransition
Returns the transition effect of page.
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().
.free_form_field_mapping(list) ⇒ nil
Frees a list of Poppler::FormFieldMappings allocated by poppler_page_get_form_field_mapping().
.free_image_mapping(list) ⇒ nil
Frees a list of Poppler::ImageMappings allocated by poppler_page_get_image_mapping().
.free_link_mapping(list) ⇒ 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().
.free_text_attributes(list) ⇒ nil
Frees a list of Poppler::TextAttributess allocated by poppler_page_get_text_attributes().
.selection_region_free(region) ⇒ nil
Frees region
Instance Method Details
#add_annot(annot) ⇒ nil
Adds annotation annot to page.
#annot_mapping ⇒ GLib::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.
#duration ⇒ Float
Returns the duration of page
#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.
53 54 55 56 57 58 59 |
# File 'lib/poppler/page.rb', line 53 def find_text(text, =nil) if .nil? find_text_raw(text) else (text, ) end end |
#find_text_raw ⇒ 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.
|
|
# 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().
#form_field_mapping ⇒ GLib::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.
#get_bounding_box(rect) ⇒ Boolean
#get_crop_box(rect) ⇒ nil
Retrurns the crop box of page
#get_image(image_id) ⇒ cairo::Surface
Returns a cairo surface for the image of the page
#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()
#get_selected_text(style, selection) ⇒ String
Retrieves the contents of the specified selection as text.
#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().
#get_size(width, height) ⇒ nil
Gets the size of page at the current scale and rotation.
#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(={}) area = [:area] style = [: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.
#get_text_for_area(area) ⇒ String
Retrieves the text of page contained in area.
#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().
#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()
#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.
#image_mapping ⇒ GLib::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.
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_raw ⇒ GLib::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.
|
|
# File 'lib/poppler/page.rb', line 29
|
#index ⇒ Integer
Returns the index of page
#label ⇒ String
The label of the page or nil. See also poppler_page_get_label()
#label=(label) ⇒ String
The label of the page or nil. See also poppler_page_get_label()
#link_mapping ⇒ GLib::List<Poppler::LinkMapping>
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.
#remove_annot(annot) ⇒ nil
Removes annotation annot from page
#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.
#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:
#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.
#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.
#render_to_ps(ps_file) ⇒ nil
Render the page on a postscript file
#text ⇒ String
Retrieves the text of page.
#text_attributes ⇒ GLib::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()
#text_layout ⇒ Object
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_raw ⇒ Object
19 |
# File 'lib/poppler/page.rb', line 19 alias_method :text_layout_raw, :text_layout |
#thumbnail ⇒ cairo::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.
#thumbnail_size ⇒ Object
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_raw ⇒ Object
61 |
# File 'lib/poppler/page.rb', line 61 alias_method :thumbnail_size_raw, :thumbnail_size |
#transition ⇒ Poppler::PageTransition
Returns the transition effect of page