1 /* poppler-page.h: glib interface to poppler 2 * Copyright (C) 2004, Red Hat, Inc. 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2, or (at your option) 7 * any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef __POPPLER_PAGE_H__ 20 #define __POPPLER_PAGE_H__ 21 22 #include <glib-object.h> 23 24 #include "poppler.h" 25 26 #include <cairo.h> 27 28 G_BEGIN_DECLS 29 30 #define POPPLER_TYPE_PAGE (poppler_page_get_type()) 31 #define POPPLER_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), POPPLER_TYPE_PAGE, PopplerPage)) 32 #define POPPLER_IS_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), POPPLER_TYPE_PAGE)) 33 34 POPPLER_PUBLIC 35 GType poppler_page_get_type(void) G_GNUC_CONST; 36 37 POPPLER_PUBLIC 38 void poppler_page_render(PopplerPage *page, cairo_t *cairo); 39 POPPLER_PUBLIC 40 void poppler_page_render_for_printing(PopplerPage *page, cairo_t *cairo); 41 POPPLER_PUBLIC 42 void poppler_page_render_for_printing_with_options(PopplerPage *page, cairo_t *cairo, PopplerPrintFlags options); 43 POPPLER_PUBLIC 44 cairo_surface_t *poppler_page_get_thumbnail(PopplerPage *page); 45 POPPLER_PUBLIC 46 void poppler_page_render_selection(PopplerPage *page, cairo_t *cairo, PopplerRectangle *selection, PopplerRectangle *old_selection, PopplerSelectionStyle style, PopplerColor *glyph_color, PopplerColor *background_color); 47 48 POPPLER_PUBLIC 49 void poppler_page_get_size(PopplerPage *page, double *width, double *height); 50 POPPLER_PUBLIC 51 int poppler_page_get_index(PopplerPage *page); 52 POPPLER_PUBLIC 53 gchar *poppler_page_get_label(PopplerPage *page); 54 POPPLER_PUBLIC 55 double poppler_page_get_duration(PopplerPage *page); 56 POPPLER_PUBLIC 57 PopplerPageTransition *poppler_page_get_transition(PopplerPage *page); 58 POPPLER_PUBLIC 59 gboolean poppler_page_get_thumbnail_size(PopplerPage *page, int *width, int *height); 60 POPPLER_PUBLIC 61 GList *poppler_page_find_text_with_options(PopplerPage *page, const char *text, PopplerFindFlags options); 62 POPPLER_PUBLIC 63 GList *poppler_page_find_text(PopplerPage *page, const char *text); 64 POPPLER_PUBLIC 65 void poppler_page_render_to_ps(PopplerPage *page, PopplerPSFile *ps_file); 66 POPPLER_PUBLIC 67 char *poppler_page_get_text(PopplerPage *page); 68 POPPLER_PUBLIC 69 char *poppler_page_get_text_for_area(PopplerPage *page, PopplerRectangle *area); 70 POPPLER_PUBLIC 71 char *poppler_page_get_selected_text(PopplerPage *page, PopplerSelectionStyle style, PopplerRectangle *selection); 72 POPPLER_PUBLIC 73 cairo_region_t *poppler_page_get_selected_region(PopplerPage *page, gdouble scale, PopplerSelectionStyle style, PopplerRectangle *selection); 74 POPPLER_PUBLIC 75 GList *poppler_page_get_selection_region(PopplerPage *page, gdouble scale, PopplerSelectionStyle style, PopplerRectangle *selection) G_GNUC_DEPRECATED_FOR(poppler_page_get_selected_region); 76 POPPLER_PUBLIC 77 void poppler_page_selection_region_free(GList *region) G_GNUC_DEPRECATED_FOR(cairo_region_destroy); 78 POPPLER_PUBLIC 79 GList *poppler_page_get_link_mapping(PopplerPage *page); 80 POPPLER_PUBLIC 81 void poppler_page_free_link_mapping(GList *list); 82 POPPLER_PUBLIC 83 GList *poppler_page_get_image_mapping(PopplerPage *page); 84 POPPLER_PUBLIC 85 void poppler_page_free_image_mapping(GList *list); 86 POPPLER_PUBLIC 87 cairo_surface_t *poppler_page_get_image(PopplerPage *page, gint image_id); 88 POPPLER_PUBLIC 89 GList *poppler_page_get_form_field_mapping(PopplerPage *page); 90 POPPLER_PUBLIC 91 void poppler_page_free_form_field_mapping(GList *list); 92 POPPLER_PUBLIC 93 GList *poppler_page_get_annot_mapping(PopplerPage *page); 94 POPPLER_PUBLIC 95 void poppler_page_free_annot_mapping(GList *list); 96 POPPLER_PUBLIC 97 void poppler_page_add_annot(PopplerPage *page, PopplerAnnot *annot); 98 POPPLER_PUBLIC 99 void poppler_page_remove_annot(PopplerPage *page, PopplerAnnot *annot); 100 POPPLER_PUBLIC 101 void poppler_page_get_crop_box(PopplerPage *page, PopplerRectangle *rect); 102 POPPLER_PUBLIC 103 gboolean poppler_page_get_bounding_box(PopplerPage *page, PopplerRectangle *rect); 104 POPPLER_PUBLIC 105 gboolean poppler_page_get_text_layout(PopplerPage *page, PopplerRectangle **rectangles, guint *n_rectangles); 106 POPPLER_PUBLIC 107 gboolean poppler_page_get_text_layout_for_area(PopplerPage *page, PopplerRectangle *area, PopplerRectangle **rectangles, guint *n_rectangles); 108 POPPLER_PUBLIC 109 GList *poppler_page_get_text_attributes(PopplerPage *page); 110 POPPLER_PUBLIC 111 void poppler_page_free_text_attributes(GList *list); 112 POPPLER_PUBLIC 113 GList *poppler_page_get_text_attributes_for_area(PopplerPage *page, PopplerRectangle *area); 114 115 /* A rectangle on a page, with coordinates in PDF points. */ 116 #define POPPLER_TYPE_RECTANGLE (poppler_rectangle_get_type()) 117 /** 118 * PopplerRectangle: 119 * @x1: x coordinate of lower left corner 120 * @y1: y coordinate of lower left corner 121 * @x2: x coordinate of upper right corner 122 * @y2: y coordinate of upper right corner 123 * 124 * A #PopplerRectangle is used to describe 125 * locations on a page and bounding boxes 126 */ 127 struct _PopplerRectangle 128 { 129 gdouble x1; 130 gdouble y1; 131 gdouble x2; 132 gdouble y2; 133 }; 134 135 POPPLER_PUBLIC 136 GType poppler_rectangle_get_type(void) G_GNUC_CONST; 137 POPPLER_PUBLIC 138 PopplerRectangle *poppler_rectangle_new(void); 139 POPPLER_PUBLIC 140 PopplerRectangle *poppler_rectangle_copy(PopplerRectangle *rectangle); 141 POPPLER_PUBLIC 142 void poppler_rectangle_free(PopplerRectangle *rectangle); 143 POPPLER_PUBLIC 144 gboolean poppler_rectangle_find_get_match_continued(const PopplerRectangle *rectangle); 145 POPPLER_PUBLIC 146 gboolean poppler_rectangle_find_get_ignored_hyphen(const PopplerRectangle *rectangle); 147 148 /* A point on a page, with coordinates in PDF points. */ 149 #define POPPLER_TYPE_POINT (poppler_point_get_type()) 150 /** 151 * PopplerPoint: 152 * @x: x coordinate 153 * @y: y coordinate 154 * 155 * A #PopplerPoint is used to describe a location point on a page 156 */ 157 struct _PopplerPoint 158 { 159 gdouble x; 160 gdouble y; 161 }; 162 163 POPPLER_PUBLIC 164 GType poppler_point_get_type(void) G_GNUC_CONST; 165 POPPLER_PUBLIC 166 PopplerPoint *poppler_point_new(void); 167 POPPLER_PUBLIC 168 PopplerPoint *poppler_point_copy(PopplerPoint *point); 169 POPPLER_PUBLIC 170 void poppler_point_free(PopplerPoint *point); 171 172 /* PopplerQuadrilateral */ 173 174 /* A quadrilateral encompasses a word or group of contiguous words in the 175 * text underlying the annotation. The coordinates for each quadrilateral are 176 * given in the order x1 y1 x2 y2 x3 y3 x4 y4 specifying the quadrilateral’s four 177 * vertices in counterclockwise order */ 178 179 #define POPPLER_TYPE_QUADRILATERAL (poppler_quadrilateral_get_type()) 180 /** 181 * PopplerQuadrilateral: 182 * @p1: a #PopplerPoint with the first vertex coordinates 183 * @p2: a #PopplerPoint with the second vertex coordinates 184 * @p3: a #PopplerPoint with the third vertex coordinates 185 * @p4: a #PopplerPoint with the fourth vertex coordinates 186 * 187 * A #PopplerQuadrilateral is used to describe rectangle-like polygon 188 * with arbitrary inclination on a page. 189 * 190 * Since: 0.26 191 **/ 192 struct _PopplerQuadrilateral 193 { 194 PopplerPoint p1; 195 PopplerPoint p2; 196 PopplerPoint p3; 197 PopplerPoint p4; 198 }; 199 200 POPPLER_PUBLIC 201 GType poppler_quadrilateral_get_type(void) G_GNUC_CONST; 202 POPPLER_PUBLIC 203 PopplerQuadrilateral *poppler_quadrilateral_new(void); 204 POPPLER_PUBLIC 205 PopplerQuadrilateral *poppler_quadrilateral_copy(PopplerQuadrilateral *quad); 206 POPPLER_PUBLIC 207 void poppler_quadrilateral_free(PopplerQuadrilateral *quad); 208 209 /* A color in RGB */ 210 #define POPPLER_TYPE_COLOR (poppler_color_get_type()) 211 212 /** 213 * PopplerColor: 214 * @red: the red component of color 215 * @green: the green component of color 216 * @blue: the blue component of color 217 * 218 * A #PopplerColor describes a RGB color. Color components 219 * are values between 0 and 65535 220 */ 221 struct _PopplerColor 222 { 223 guint16 red; 224 guint16 green; 225 guint16 blue; 226 }; 227 228 POPPLER_PUBLIC 229 GType poppler_color_get_type(void) G_GNUC_CONST; 230 POPPLER_PUBLIC 231 PopplerColor *poppler_color_new(void); 232 POPPLER_PUBLIC 233 PopplerColor *poppler_color_copy(PopplerColor *color); 234 POPPLER_PUBLIC 235 void poppler_color_free(PopplerColor *color); 236 237 /* Text attributes. */ 238 #define POPPLER_TYPE_TEXT_ATTRIBUTES (poppler_text_attributes_get_type()) 239 /** 240 * PopplerTextAttributes: 241 * @font_name: font name 242 * @font_size: font size 243 * @is_underlined: if text is underlined 244 * @color: a #PopplerColor, the foreground color 245 * @start_index: start position this text attributes apply 246 * @end_index: end position this text attributes apply 247 * 248 * A #PopplerTextAttributes is used to describe text attributes of a range of text 249 * 250 * Since: 0.18 251 */ 252 struct _PopplerTextAttributes 253 { 254 gchar *font_name; 255 gdouble font_size; 256 gboolean is_underlined; 257 PopplerColor color; 258 259 gint start_index; 260 gint end_index; 261 }; 262 263 POPPLER_PUBLIC 264 GType poppler_text_attributes_get_type(void) G_GNUC_CONST; 265 POPPLER_PUBLIC 266 PopplerTextAttributes *poppler_text_attributes_new(void); 267 POPPLER_PUBLIC 268 PopplerTextAttributes *poppler_text_attributes_copy(PopplerTextAttributes *text_attrs); 269 POPPLER_PUBLIC 270 void poppler_text_attributes_free(PopplerTextAttributes *text_attrs); 271 272 /* Mapping between areas on the current page and PopplerActions */ 273 #define POPPLER_TYPE_LINK_MAPPING (poppler_link_mapping_get_type()) 274 275 /** 276 * PopplerLinkMapping: 277 * @area: a #PopplerRectangle representing an area of the page 278 * @action: a #PopplerAction 279 * 280 * A #PopplerLinkMapping structure represents the location 281 * of @action on the page 282 */ 283 struct _PopplerLinkMapping 284 { 285 PopplerRectangle area; 286 PopplerAction *action; 287 }; 288 289 POPPLER_PUBLIC 290 GType poppler_link_mapping_get_type(void) G_GNUC_CONST; 291 POPPLER_PUBLIC 292 PopplerLinkMapping *poppler_link_mapping_new(void); 293 POPPLER_PUBLIC 294 PopplerLinkMapping *poppler_link_mapping_copy(PopplerLinkMapping *mapping); 295 POPPLER_PUBLIC 296 void poppler_link_mapping_free(PopplerLinkMapping *mapping); 297 298 /* Page Transition */ 299 #define POPPLER_TYPE_PAGE_TRANSITION (poppler_page_transition_get_type()) 300 301 /** 302 * PopplerPageTransition: 303 * @type: the type of transtition 304 * @alignment: the dimension in which the transition effect shall occur. 305 * Only for #POPPLER_PAGE_TRANSITION_SPLIT and #POPPLER_PAGE_TRANSITION_BLINDS transition types 306 * @direction: the direction of motion for the transition effect. 307 * Only for #POPPLER_PAGE_TRANSITION_SPLIT, #POPPLER_PAGE_TRANSITION_BOX and #POPPLER_PAGE_TRANSITION_FLY 308 * transition types 309 * @duration: the duration of the transition effect 310 * @angle: the direction in which the specified transition effect shall moves, 311 * expressed in degrees counterclockwise starting from a left-to-right direction. 312 * Only for #POPPLER_PAGE_TRANSITION_WIPE, #POPPLER_PAGE_TRANSITION_GLITTER, #POPPLER_PAGE_TRANSITION_FLY, 313 * #POPPLER_PAGE_TRANSITION_COVER, #POPPLER_PAGE_TRANSITION_UNCOVER and #POPPLER_PAGE_TRANSITION_PUSH 314 * transition types 315 * @scale: the starting or ending scale at which the changes shall be drawn. 316 * Only for #POPPLER_PAGE_TRANSITION_FLY transition type 317 * @rectangular: whether the area that will be flown is rectangular and opaque. 318 * Only for #POPPLER_PAGE_TRANSITION_FLY transition type 319 * 320 * A #PopplerPageTransition structures describes a visual transition 321 * to use when moving between pages during a presentation 322 */ 323 struct _PopplerPageTransition 324 { 325 PopplerPageTransitionType type; 326 PopplerPageTransitionAlignment alignment; 327 PopplerPageTransitionDirection direction; 328 gint duration; 329 gint angle; 330 gdouble scale; 331 gboolean rectangular; 332 gdouble duration_real; 333 }; 334 335 POPPLER_PUBLIC 336 GType poppler_page_transition_get_type(void) G_GNUC_CONST; 337 POPPLER_PUBLIC 338 PopplerPageTransition *poppler_page_transition_new(void); 339 POPPLER_PUBLIC 340 PopplerPageTransition *poppler_page_transition_copy(PopplerPageTransition *transition); 341 POPPLER_PUBLIC 342 void poppler_page_transition_free(PopplerPageTransition *transition); 343 344 /* Mapping between areas on the current page and images */ 345 #define POPPLER_TYPE_IMAGE_MAPPING (poppler_image_mapping_get_type()) 346 347 /** 348 * PopplerImageMapping: 349 * @area: a #PopplerRectangle representing an area of the page 350 * @image_id: an image identifier 351 * 352 * A #PopplerImageMapping structure represents the location 353 * of an image on the page 354 */ 355 struct _PopplerImageMapping 356 { 357 PopplerRectangle area; 358 gint image_id; 359 }; 360 361 POPPLER_PUBLIC 362 GType poppler_image_mapping_get_type(void) G_GNUC_CONST; 363 POPPLER_PUBLIC 364 PopplerImageMapping *poppler_image_mapping_new(void); 365 POPPLER_PUBLIC 366 PopplerImageMapping *poppler_image_mapping_copy(PopplerImageMapping *mapping); 367 POPPLER_PUBLIC 368 void poppler_image_mapping_free(PopplerImageMapping *mapping); 369 370 /* Mapping between areas on the current page and form fields */ 371 #define POPPLER_TYPE_FORM_FIELD_MAPPING (poppler_form_field_mapping_get_type()) 372 373 /** 374 * PopplerFormFieldMapping: 375 * @area: a #PopplerRectangle representing an area of the page 376 * @field: a #PopplerFormField 377 * 378 * A #PopplerFormFieldMapping structure represents the location 379 * of @field on the page 380 */ 381 struct _PopplerFormFieldMapping 382 { 383 PopplerRectangle area; 384 PopplerFormField *field; 385 }; 386 387 POPPLER_PUBLIC 388 GType poppler_form_field_mapping_get_type(void) G_GNUC_CONST; 389 POPPLER_PUBLIC 390 PopplerFormFieldMapping *poppler_form_field_mapping_new(void); 391 POPPLER_PUBLIC 392 PopplerFormFieldMapping *poppler_form_field_mapping_copy(PopplerFormFieldMapping *mapping); 393 POPPLER_PUBLIC 394 void poppler_form_field_mapping_free(PopplerFormFieldMapping *mapping); 395 396 /* Mapping between areas on the current page and annots */ 397 #define POPPLER_TYPE_ANNOT_MAPPING (poppler_annot_mapping_get_type()) 398 399 /** 400 * PopplerAnnotMapping: 401 * @area: a #PopplerRectangle representing an area of the page 402 * @annot: a #PopplerAnnot 403 * 404 * A #PopplerAnnotMapping structure represents the location 405 * of @annot on the page 406 */ 407 struct _PopplerAnnotMapping 408 { 409 PopplerRectangle area; 410 PopplerAnnot *annot; 411 }; 412 413 POPPLER_PUBLIC 414 GType poppler_annot_mapping_get_type(void) G_GNUC_CONST; 415 POPPLER_PUBLIC 416 PopplerAnnotMapping *poppler_annot_mapping_new(void); 417 POPPLER_PUBLIC 418 PopplerAnnotMapping *poppler_annot_mapping_copy(PopplerAnnotMapping *mapping); 419 POPPLER_PUBLIC 420 void poppler_annot_mapping_free(PopplerAnnotMapping *mapping); 421 422 G_END_DECLS 423 424 #endif /* __POPPLER_PAGE_H__ */ 425