poppler 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/poppler/rbpoppler-action.c +27 -23
- data/ext/poppler/rbpoppler-annotation.c +38 -271
- data/ext/poppler/rbpoppler-annotationcalloutline.c +130 -0
- data/ext/poppler/rbpoppler-annotationfreetext.c +47 -0
- data/ext/poppler/rbpoppler-annotationmapping.c +75 -0
- data/ext/poppler/rbpoppler-annotationmarkup.c +97 -0
- data/ext/poppler/rbpoppler-annotationtext.c +58 -0
- data/ext/poppler/rbpoppler-attachment.c +41 -31
- data/ext/poppler/rbpoppler-buttonfield.c +58 -0
- data/ext/poppler/rbpoppler-choicefield.c +133 -0
- data/ext/poppler/rbpoppler-color.c +122 -0
- data/ext/poppler/rbpoppler-document.c +74 -340
- data/ext/poppler/rbpoppler-fontinfo.c +66 -0
- data/ext/poppler/rbpoppler-fontsiter.c +130 -0
- data/ext/poppler/rbpoppler-form-field.c +43 -234
- data/ext/poppler/rbpoppler-formfieldmapping.c +47 -0
- data/ext/poppler/rbpoppler-imagemapping.c +55 -0
- data/ext/poppler/rbpoppler-indexiter.c +130 -0
- data/ext/poppler/rbpoppler-linkmapping.c +50 -0
- data/ext/poppler/rbpoppler-page.c +106 -454
- data/ext/poppler/rbpoppler-pagetransition.c +62 -0
- data/ext/poppler/rbpoppler-private.h +31 -6
- data/ext/poppler/rbpoppler-psfile.c +69 -0
- data/ext/poppler/rbpoppler-rectangle.c +94 -0
- data/ext/poppler/rbpoppler-textfield.c +93 -0
- data/ext/poppler/rbpoppler.c +74 -45
- data/ext/poppler/rbpoppler.h +22 -15
- data/ext/poppler/rbpopplerconversions.h +105 -0
- metadata +28 -10
- data/ChangeLog +0 -424
@@ -0,0 +1,58 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2008 Ruby-GNOME2 Project Team
|
5
|
+
*
|
6
|
+
* This library is free software; you can redistribute it and/or
|
7
|
+
* modify it under the terms of the GNU Lesser General Public
|
8
|
+
* License as published by the Free Software Foundation; either
|
9
|
+
* version 2.1 of the License, or (at your option) any later version.
|
10
|
+
*
|
11
|
+
* This library is distributed in the hope that it will be useful,
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
* Lesser General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU Lesser General Public
|
17
|
+
* License along with this library; if not, write to the Free Software
|
18
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
+
* MA 02110-1301 USA
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include "rbpoppler-private.h"
|
23
|
+
|
24
|
+
#define RG_TARGET_NAMESPACE cButtonField
|
25
|
+
#define _SELF(obj) RVAL2POPPLERFORMFIELD(obj)
|
26
|
+
|
27
|
+
static VALUE RG_TARGET_NAMESPACE;
|
28
|
+
|
29
|
+
static VALUE
|
30
|
+
rg_type(VALUE self)
|
31
|
+
{
|
32
|
+
return POPPLERFORMBUTTONTYPE2RVAL(poppler_form_field_button_get_button_type(_SELF(self)));
|
33
|
+
}
|
34
|
+
|
35
|
+
static VALUE
|
36
|
+
rg_active_p(VALUE self)
|
37
|
+
{
|
38
|
+
return CBOOL2RVAL(poppler_form_field_button_get_state(_SELF(self)));
|
39
|
+
}
|
40
|
+
|
41
|
+
static VALUE
|
42
|
+
rg_set_active(VALUE self, VALUE state)
|
43
|
+
{
|
44
|
+
poppler_form_field_button_set_state(_SELF(self), RVAL2CBOOL(state));
|
45
|
+
return Qnil;
|
46
|
+
}
|
47
|
+
|
48
|
+
void
|
49
|
+
Init_poppler_button_field(VALUE mPoppler, VALUE cFormField)
|
50
|
+
{
|
51
|
+
RG_TARGET_NAMESPACE = rb_define_class_under(mPoppler, "ButtonField", cFormField);
|
52
|
+
|
53
|
+
RG_DEF_METHOD(type, 0);
|
54
|
+
RG_DEF_METHOD_P(active, 0);
|
55
|
+
RG_DEF_METHOD(set_active, 1);
|
56
|
+
|
57
|
+
G_DEF_SETTERS(RG_TARGET_NAMESPACE);
|
58
|
+
}
|
@@ -0,0 +1,133 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2008 Ruby-GNOME2 Project Team
|
5
|
+
*
|
6
|
+
* This library is free software; you can redistribute it and/or
|
7
|
+
* modify it under the terms of the GNU Lesser General Public
|
8
|
+
* License as published by the Free Software Foundation; either
|
9
|
+
* version 2.1 of the License, or (at your option) any later version.
|
10
|
+
*
|
11
|
+
* This library is distributed in the hope that it will be useful,
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
* Lesser General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU Lesser General Public
|
17
|
+
* License along with this library; if not, write to the Free Software
|
18
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
+
* MA 02110-1301 USA
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include "rbpoppler-private.h"
|
23
|
+
|
24
|
+
#define RG_TARGET_NAMESPACE cChoiceField
|
25
|
+
#define _SELF(obj) RVAL2POPPLERFORMFIELD(obj)
|
26
|
+
|
27
|
+
static VALUE RG_TARGET_NAMESPACE;
|
28
|
+
|
29
|
+
static VALUE
|
30
|
+
rg_type(VALUE self)
|
31
|
+
{
|
32
|
+
return POPPLERFORMCHOICETYPE2RVAL(poppler_form_field_choice_get_choice_type(_SELF(self)));
|
33
|
+
}
|
34
|
+
|
35
|
+
static VALUE
|
36
|
+
rg_editable_p(VALUE self)
|
37
|
+
{
|
38
|
+
return CBOOL2RVAL(poppler_form_field_choice_is_editable(_SELF(self)));
|
39
|
+
}
|
40
|
+
|
41
|
+
static VALUE
|
42
|
+
rg_select_multiple_p(VALUE self)
|
43
|
+
{
|
44
|
+
return CBOOL2RVAL(poppler_form_field_choice_can_select_multiple(_SELF(self)));
|
45
|
+
}
|
46
|
+
|
47
|
+
static VALUE
|
48
|
+
rg_spell_check_p(VALUE self)
|
49
|
+
{
|
50
|
+
return CBOOL2RVAL(poppler_form_field_choice_do_spell_check(_SELF(self)));
|
51
|
+
}
|
52
|
+
|
53
|
+
static VALUE
|
54
|
+
rg_commit_on_change_p(VALUE self)
|
55
|
+
{
|
56
|
+
return CBOOL2RVAL(poppler_form_field_choice_commit_on_change(_SELF(self)));
|
57
|
+
}
|
58
|
+
|
59
|
+
static VALUE
|
60
|
+
rg_n_items(VALUE self)
|
61
|
+
{
|
62
|
+
return INT2NUM(poppler_form_field_choice_get_n_items(_SELF(self)));
|
63
|
+
}
|
64
|
+
|
65
|
+
static VALUE
|
66
|
+
rg_operator_choice_field_get_item(VALUE self, VALUE index)
|
67
|
+
{
|
68
|
+
return CSTR2RVAL(poppler_form_field_choice_get_item(_SELF(self),
|
69
|
+
NUM2INT(index)));
|
70
|
+
}
|
71
|
+
|
72
|
+
static VALUE
|
73
|
+
rg_selected_p(VALUE self, VALUE index)
|
74
|
+
{
|
75
|
+
return CBOOL2RVAL(poppler_form_field_choice_is_item_selected(_SELF(self),
|
76
|
+
NUM2INT(index)));
|
77
|
+
}
|
78
|
+
|
79
|
+
static VALUE
|
80
|
+
rg_select(VALUE self, VALUE index)
|
81
|
+
{
|
82
|
+
poppler_form_field_choice_select_item(_SELF(self), NUM2INT(index));
|
83
|
+
return Qnil;
|
84
|
+
}
|
85
|
+
|
86
|
+
static VALUE
|
87
|
+
rg_unselect_all(VALUE self)
|
88
|
+
{
|
89
|
+
poppler_form_field_choice_unselect_all(_SELF(self));
|
90
|
+
return Qnil;
|
91
|
+
}
|
92
|
+
|
93
|
+
static VALUE
|
94
|
+
rg_toggle(VALUE self, VALUE index)
|
95
|
+
{
|
96
|
+
poppler_form_field_choice_toggle_item(_SELF(self), NUM2INT(index));
|
97
|
+
return Qnil;
|
98
|
+
}
|
99
|
+
|
100
|
+
static VALUE
|
101
|
+
rg_set_text(VALUE self, VALUE text)
|
102
|
+
{
|
103
|
+
poppler_form_field_choice_set_text(_SELF(self), RVAL2CSTR_ACCEPT_NIL(text));
|
104
|
+
return Qnil;
|
105
|
+
}
|
106
|
+
|
107
|
+
static VALUE
|
108
|
+
rg_text(VALUE self)
|
109
|
+
{
|
110
|
+
return CSTR2RVAL(poppler_form_field_choice_get_text(_SELF(self)));
|
111
|
+
}
|
112
|
+
|
113
|
+
void
|
114
|
+
Init_poppler_choice_field(VALUE mPoppler, VALUE cFormField)
|
115
|
+
{
|
116
|
+
RG_TARGET_NAMESPACE = rb_define_class_under(mPoppler, "ChoiceField", cFormField);
|
117
|
+
|
118
|
+
RG_DEF_METHOD(type, 0);
|
119
|
+
RG_DEF_METHOD_P(editable, 0);
|
120
|
+
RG_DEF_METHOD_P(select_multiple, 0);
|
121
|
+
RG_DEF_METHOD_P(spell_check, 0);
|
122
|
+
RG_DEF_METHOD_P(commit_on_change, 0);
|
123
|
+
RG_DEF_METHOD(n_items, 0);
|
124
|
+
RG_DEF_METHOD_OPERATOR("[]", choice_field_get_item, 1);
|
125
|
+
RG_DEF_METHOD_P(selected, 1);
|
126
|
+
RG_DEF_METHOD(select, 1);
|
127
|
+
RG_DEF_METHOD(unselect_all, 0);
|
128
|
+
RG_DEF_METHOD(toggle, 1);
|
129
|
+
RG_DEF_METHOD(text, 0);
|
130
|
+
RG_DEF_METHOD(set_text, 1);
|
131
|
+
|
132
|
+
G_DEF_SETTERS(RG_TARGET_NAMESPACE);
|
133
|
+
}
|
@@ -0,0 +1,122 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2006-2008 Ruby-GNOME2 Project Team
|
5
|
+
*
|
6
|
+
* This library is free software; you can redistribute it and/or
|
7
|
+
* modify it under the terms of the GNU Lesser General Public
|
8
|
+
* License as published by the Free Software Foundation; either
|
9
|
+
* version 2.1 of the License, or (at your option) any later version.
|
10
|
+
*
|
11
|
+
* This library is distributed in the hope that it will be useful,
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
* Lesser General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU Lesser General Public
|
17
|
+
* License along with this library; if not, write to the Free Software
|
18
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
+
* MA 02110-1301 USA
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include "rbpoppler-private.h"
|
23
|
+
|
24
|
+
#define RG_TARGET_NAMESPACE rb_cPopplerColor
|
25
|
+
|
26
|
+
#ifdef POPPLER_TYPE_COLOR
|
27
|
+
VALUE RG_TARGET_NAMESPACE;
|
28
|
+
|
29
|
+
PopplerColor *
|
30
|
+
rb_poppler_ruby_object_to_color(VALUE color)
|
31
|
+
{
|
32
|
+
#ifdef POPPLER_WITH_GDK
|
33
|
+
if (RTEST(rb_obj_is_kind_of(color, rb_cGdkColor))) {
|
34
|
+
GdkColor *gdk_color;
|
35
|
+
|
36
|
+
gdk_color = RVAL2GDKCOLOR(color);
|
37
|
+
color = rb_funcall(RG_TARGET_NAMESPACE, rb_intern("new"),
|
38
|
+
3,
|
39
|
+
UINT2NUM(gdk_color->red),
|
40
|
+
UINT2NUM(gdk_color->green),
|
41
|
+
UINT2NUM(gdk_color->blue));
|
42
|
+
}
|
43
|
+
#endif
|
44
|
+
|
45
|
+
return RVAL2BOXED(color, POPPLER_TYPE_COLOR);
|
46
|
+
}
|
47
|
+
|
48
|
+
VALUE
|
49
|
+
rb_poppler_ruby_object_from_color_with_free(PopplerColor *color)
|
50
|
+
{
|
51
|
+
VALUE rb_color;
|
52
|
+
|
53
|
+
rb_color = POPPLERCOLOR2RVAL(color);
|
54
|
+
g_free(color);
|
55
|
+
return rb_color;
|
56
|
+
}
|
57
|
+
|
58
|
+
static VALUE
|
59
|
+
rg_initialize(VALUE self, VALUE red, VALUE green, VALUE blue)
|
60
|
+
{
|
61
|
+
PopplerColor color;
|
62
|
+
|
63
|
+
color.red = NUM2UINT(red);
|
64
|
+
color.green = NUM2UINT(green);
|
65
|
+
color.blue = NUM2UINT(blue);
|
66
|
+
|
67
|
+
G_INITIALIZE(self, &color);
|
68
|
+
return Qnil;
|
69
|
+
}
|
70
|
+
|
71
|
+
DEF_ACCESSOR(color, red, RVAL2POPPLERCOLOR, UINT2NUM, NUM2UINT)
|
72
|
+
DEF_ACCESSOR(color, green, RVAL2POPPLERCOLOR, UINT2NUM, NUM2UINT)
|
73
|
+
DEF_ACCESSOR(color, blue, RVAL2POPPLERCOLOR, UINT2NUM, NUM2UINT)
|
74
|
+
|
75
|
+
static VALUE
|
76
|
+
rg_to_a(VALUE self)
|
77
|
+
{
|
78
|
+
PopplerColor *color;
|
79
|
+
color = RVAL2POPPLERCOLOR(self);
|
80
|
+
return rb_ary_new3(3,
|
81
|
+
UINT2NUM(color->red),
|
82
|
+
UINT2NUM(color->green),
|
83
|
+
UINT2NUM(color->blue));
|
84
|
+
}
|
85
|
+
|
86
|
+
static VALUE
|
87
|
+
rg_inspect(VALUE self)
|
88
|
+
{
|
89
|
+
VALUE inspected;
|
90
|
+
gchar *rgb;
|
91
|
+
PopplerColor *color;
|
92
|
+
|
93
|
+
color = RVAL2POPPLERCOLOR(self);
|
94
|
+
inspected = rb_call_super(0, NULL);
|
95
|
+
rb_str_resize(inspected, RSTRING_LEN(inspected) - 1);
|
96
|
+
rgb = g_strdup_printf(": [%u, %u, %u]>",
|
97
|
+
color->red, color->green, color->blue);
|
98
|
+
rb_str_cat2(inspected, rgb);
|
99
|
+
g_free(rgb);
|
100
|
+
return inspected;
|
101
|
+
}
|
102
|
+
#endif
|
103
|
+
|
104
|
+
void
|
105
|
+
Init_poppler_color(VALUE mPoppler)
|
106
|
+
{
|
107
|
+
#ifdef POPPLER_TYPE_COLOR
|
108
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS(POPPLER_TYPE_COLOR, "Color", mPoppler);
|
109
|
+
|
110
|
+
RG_DEF_METHOD(initialize, 3);
|
111
|
+
rb_define_method(RG_TARGET_NAMESPACE, "red", color_get_red, 0);
|
112
|
+
rb_define_method(RG_TARGET_NAMESPACE, "green", color_get_green, 0);
|
113
|
+
rb_define_method(RG_TARGET_NAMESPACE, "blue", color_get_blue, 0);
|
114
|
+
rb_define_method(RG_TARGET_NAMESPACE, "set_red", color_set_red, 1);
|
115
|
+
rb_define_method(RG_TARGET_NAMESPACE, "set_green", color_set_green, 1);
|
116
|
+
rb_define_method(RG_TARGET_NAMESPACE, "set_blue", color_set_blue, 1);
|
117
|
+
RG_DEF_METHOD(to_a, 0);
|
118
|
+
RG_DEF_METHOD(inspect, 0);
|
119
|
+
|
120
|
+
G_DEF_SETTERS(RG_TARGET_NAMESPACE);
|
121
|
+
#endif
|
122
|
+
}
|
@@ -1,31 +1,34 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2006 Ruby-GNOME2 Project Team
|
5
|
+
*
|
6
|
+
* This library is free software; you can redistribute it and/or
|
7
|
+
* modify it under the terms of the GNU Lesser General Public
|
8
|
+
* License as published by the Free Software Foundation; either
|
9
|
+
* version 2.1 of the License, or (at your option) any later version.
|
10
|
+
*
|
11
|
+
* This library is distributed in the hope that it will be useful,
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
* Lesser General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU Lesser General Public
|
17
|
+
* License along with this library; if not, write to the Free Software
|
18
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
+
* MA 02110-1301 USA
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include "rbpoppler-private.h"
|
23
|
+
|
24
|
+
#define RG_TARGET_NAMESPACE cDocument
|
25
|
+
|
26
|
+
static ID id_new, id_pdf_data_p, id_ensure_uri;
|
23
27
|
static VALUE cIndexIter;
|
24
28
|
static VALUE cFontInfo;
|
25
29
|
|
26
|
-
|
27
30
|
static VALUE
|
28
|
-
|
31
|
+
rg_initialize(int argc, VALUE *argv, VALUE self)
|
29
32
|
{
|
30
33
|
PopplerDocument *document = NULL;
|
31
34
|
GError *error = NULL;
|
@@ -34,7 +37,7 @@ doc_initialize(int argc, VALUE *argv, VALUE self)
|
|
34
37
|
|
35
38
|
rb_scan_args(argc, argv, "11", &uri_or_data, &rb_password);
|
36
39
|
|
37
|
-
password =
|
40
|
+
password = RVAL2CSTR_ACCEPT_NIL(rb_password);
|
38
41
|
|
39
42
|
if (RVAL2CBOOL(rb_funcall(self, id_pdf_data_p, 1, uri_or_data))) {
|
40
43
|
document = poppler_document_new_from_data(RSTRING_PTR(uri_or_data),
|
@@ -56,13 +59,13 @@ doc_initialize(int argc, VALUE *argv, VALUE self)
|
|
56
59
|
}
|
57
60
|
|
58
61
|
static VALUE
|
59
|
-
|
62
|
+
rg_save(VALUE self, VALUE uri)
|
60
63
|
{
|
61
64
|
gboolean result;
|
62
65
|
GError *error = NULL;
|
63
66
|
|
64
67
|
uri = rb_funcall(self, id_ensure_uri, 1, uri);
|
65
|
-
result = poppler_document_save(
|
68
|
+
result = poppler_document_save(RVAL2POPPLERDOCUMENT(self), RVAL2CSTR(uri), &error);
|
66
69
|
|
67
70
|
if (error)
|
68
71
|
RAISE_GERROR(error);
|
@@ -71,14 +74,14 @@ doc_save(VALUE self, VALUE uri)
|
|
71
74
|
}
|
72
75
|
|
73
76
|
static VALUE
|
74
|
-
|
77
|
+
rg_save_a_copy(VALUE self, VALUE uri)
|
75
78
|
{
|
76
79
|
gboolean result;
|
77
80
|
GError *error = NULL;
|
78
81
|
|
79
82
|
uri = rb_funcall(self, id_ensure_uri, 1, uri);
|
80
|
-
result = poppler_document_save_a_copy(
|
81
|
-
|
83
|
+
result = poppler_document_save_a_copy(RVAL2POPPLERDOCUMENT(self), RVAL2CSTR(uri),
|
84
|
+
&error);
|
82
85
|
|
83
86
|
if (error)
|
84
87
|
RAISE_GERROR(error);
|
@@ -87,22 +90,22 @@ doc_save_a_copy(VALUE self, VALUE uri)
|
|
87
90
|
}
|
88
91
|
|
89
92
|
static VALUE
|
90
|
-
|
93
|
+
rg_n_pages(VALUE self)
|
91
94
|
{
|
92
|
-
return INT2NUM(poppler_document_get_n_pages(
|
95
|
+
return INT2NUM(poppler_document_get_n_pages(RVAL2POPPLERDOCUMENT(self)));
|
93
96
|
}
|
94
97
|
|
95
98
|
static VALUE
|
96
|
-
|
99
|
+
rg_get_page(VALUE self, VALUE index_or_label)
|
97
100
|
{
|
98
101
|
VALUE rb_page;
|
99
102
|
PopplerPage *page;
|
100
103
|
|
101
104
|
if (RVAL2CBOOL(rb_obj_is_kind_of(index_or_label, rb_cInteger))) {
|
102
|
-
page = poppler_document_get_page(
|
105
|
+
page = poppler_document_get_page(RVAL2POPPLERDOCUMENT(self),
|
103
106
|
NUM2INT(index_or_label));
|
104
107
|
} else if (RVAL2CBOOL(rb_obj_is_kind_of(index_or_label, rb_cString))) {
|
105
|
-
page = poppler_document_get_page_by_label(
|
108
|
+
page = poppler_document_get_page_by_label(RVAL2POPPLERDOCUMENT(self),
|
106
109
|
RVAL2CSTR(index_or_label));
|
107
110
|
} else {
|
108
111
|
VALUE inspect;
|
@@ -118,38 +121,39 @@ doc_get_page(VALUE self, VALUE index_or_label)
|
|
118
121
|
}
|
119
122
|
|
120
123
|
static VALUE
|
121
|
-
|
124
|
+
rg_has_attachments_p(VALUE self)
|
122
125
|
{
|
123
|
-
return CBOOL2RVAL(poppler_document_has_attachments(
|
126
|
+
return CBOOL2RVAL(poppler_document_has_attachments(RVAL2POPPLERDOCUMENT(self)));
|
124
127
|
}
|
125
128
|
|
126
129
|
static VALUE
|
127
|
-
|
130
|
+
rg_attachments(VALUE self)
|
128
131
|
{
|
129
|
-
return GLIST2ARYF(poppler_document_get_attachments(
|
132
|
+
return GLIST2ARYF(poppler_document_get_attachments(RVAL2POPPLERDOCUMENT(self)));
|
130
133
|
}
|
131
134
|
|
132
135
|
static VALUE
|
133
|
-
|
136
|
+
rg_find_dest(VALUE self, VALUE link_name)
|
134
137
|
{
|
135
|
-
|
136
|
-
|
138
|
+
PopplerDest *dest;
|
139
|
+
dest = poppler_document_find_dest(RVAL2POPPLERDOCUMENT(self), RVAL2CSTR(link_name));
|
140
|
+
return POPPLERDEST2RVAL(dest);
|
137
141
|
}
|
138
142
|
|
139
143
|
static VALUE
|
140
|
-
|
144
|
+
rg_get_form_field(VALUE self, VALUE id)
|
141
145
|
{
|
142
|
-
return GOBJ2RVAL(poppler_document_get_form_field(
|
146
|
+
return GOBJ2RVAL(poppler_document_get_form_field(RVAL2POPPLERDOCUMENT(self),
|
143
147
|
NUM2INT(id)));
|
144
148
|
}
|
145
149
|
|
146
150
|
static VALUE
|
147
|
-
|
151
|
+
rg_each(VALUE self)
|
148
152
|
{
|
149
153
|
PopplerDocument *document;
|
150
154
|
int i, n_pages;
|
151
155
|
|
152
|
-
document =
|
156
|
+
document = RVAL2POPPLERDOCUMENT(self);
|
153
157
|
n_pages = poppler_document_get_n_pages(document);
|
154
158
|
for (i = 0; i < n_pages; i++) {
|
155
159
|
PopplerPage *page;
|
@@ -165,251 +169,29 @@ doc_each(VALUE self)
|
|
165
169
|
}
|
166
170
|
|
167
171
|
static VALUE
|
168
|
-
|
172
|
+
rg_index_iter(VALUE self)
|
169
173
|
{
|
170
174
|
return rb_funcall(cIndexIter, id_new, 1, self);
|
171
175
|
}
|
172
176
|
|
173
177
|
static VALUE
|
174
|
-
|
178
|
+
rg_font_info(VALUE self)
|
175
179
|
{
|
176
180
|
return rb_funcall(cFontInfo, id_new, 1, self);
|
177
181
|
}
|
178
182
|
|
179
|
-
|
180
|
-
|
181
|
-
/* Interface for getting the Index of a poppler_document */
|
182
|
-
#define CHECK_IITER_IS_VALID(iter) do { \
|
183
|
-
if (!RVAL2CBOOL(index_iter_valid_p(iter))) \
|
184
|
-
return Qnil; \
|
185
|
-
} while (0)
|
186
|
-
|
187
|
-
static VALUE
|
188
|
-
index_iter_valid_p(VALUE self)
|
189
|
-
{
|
190
|
-
return rb_ivar_get(self, id_valid);
|
191
|
-
}
|
192
|
-
|
193
|
-
static VALUE
|
194
|
-
index_iter_initialize(VALUE self, VALUE document)
|
195
|
-
{
|
196
|
-
PopplerIndexIter *iter;
|
197
|
-
iter = poppler_index_iter_new(RVAL2GOBJ(document));
|
198
|
-
G_INITIALIZE(self, iter);
|
199
|
-
poppler_index_iter_free(iter);
|
200
|
-
rb_ivar_set(self, id_valid, CBOOL2RVAL(iter));
|
201
|
-
return Qnil;
|
202
|
-
}
|
203
|
-
|
204
|
-
static VALUE
|
205
|
-
index_iter_get_child(VALUE self)
|
206
|
-
{
|
207
|
-
PopplerIndexIter *child;
|
208
|
-
VALUE rb_child;
|
209
|
-
|
210
|
-
CHECK_IITER_IS_VALID(self);
|
211
|
-
child = poppler_index_iter_get_child(RVAL2IITER(self));
|
212
|
-
rb_child = IITER2RVAL(child);
|
213
|
-
poppler_index_iter_free(child);
|
214
|
-
return rb_child;
|
215
|
-
}
|
216
|
-
|
217
|
-
static VALUE
|
218
|
-
index_iter_is_open(VALUE self)
|
219
|
-
{
|
220
|
-
CHECK_IITER_IS_VALID(self);
|
221
|
-
return CBOOL2RVAL(poppler_index_iter_is_open(RVAL2IITER(self)));
|
222
|
-
}
|
223
|
-
|
224
|
-
#ifndef HAVE_TYPE_POPPLERACTIONANY
|
225
|
-
static VALUE
|
226
|
-
index_iter_get_action(VALUE self)
|
227
|
-
{
|
228
|
-
CHECK_IITER_IS_VALID(self);
|
229
|
-
return POPPLER_ACTION2RVAL(poppler_index_iter_get_action(RVAL2IITER(self)));
|
230
|
-
}
|
231
|
-
#endif
|
232
|
-
|
233
|
-
static VALUE
|
234
|
-
index_iter_next(VALUE self)
|
235
|
-
{
|
236
|
-
if (poppler_index_iter_next(RVAL2IITER(self))) {
|
237
|
-
return Qtrue;
|
238
|
-
} else {
|
239
|
-
rb_ivar_set(self, id_valid, Qfalse);
|
240
|
-
return Qfalse;
|
241
|
-
}
|
242
|
-
}
|
243
|
-
|
244
|
-
static VALUE
|
245
|
-
index_iter_each(VALUE self)
|
246
|
-
{
|
247
|
-
PopplerIndexIter *iter;
|
248
|
-
|
249
|
-
CHECK_IITER_IS_VALID(self);
|
250
|
-
iter = RVAL2IITER(self);
|
251
|
-
do {
|
252
|
-
rb_yield(self);
|
253
|
-
} while (poppler_index_iter_next(iter));
|
254
|
-
rb_ivar_set(self, id_valid, Qfalse);
|
255
|
-
|
256
|
-
return self;
|
257
|
-
}
|
258
|
-
|
259
|
-
|
260
|
-
#if POPPLER_CHECK_VERSION(0, 6, 0)
|
261
|
-
|
262
|
-
static VALUE
|
263
|
-
font_info_initialize(VALUE self, VALUE document)
|
264
|
-
{
|
265
|
-
G_INITIALIZE(self, poppler_font_info_new(RVAL2GOBJ(document)));
|
266
|
-
return Qnil;
|
267
|
-
}
|
268
|
-
|
269
|
-
static VALUE
|
270
|
-
font_info_scan(VALUE self, VALUE n_pages)
|
271
|
-
{
|
272
|
-
VALUE rb_iter = Qnil;
|
273
|
-
PopplerFontsIter *iter;
|
274
|
-
|
275
|
-
if (poppler_font_info_scan(RVAL2GOBJ(self), NUM2INT(n_pages), &iter)) {
|
276
|
-
rb_iter = FITER2RVAL(iter);
|
277
|
-
rb_ivar_set(rb_iter, id_valid, Qtrue);
|
278
|
-
poppler_fonts_iter_free(iter);
|
279
|
-
}
|
280
|
-
return rb_iter;
|
281
|
-
}
|
282
|
-
#endif
|
283
|
-
|
284
|
-
|
285
|
-
#define CHECK_FITER_IS_VALID(iter) do { \
|
286
|
-
if (!RVAL2CBOOL(fonts_iter_valid_p(iter))) \
|
287
|
-
return Qnil; \
|
288
|
-
} while (0)
|
289
|
-
|
290
|
-
static VALUE
|
291
|
-
fonts_iter_valid_p(VALUE self)
|
292
|
-
{
|
293
|
-
return rb_ivar_get(self, id_valid);
|
294
|
-
}
|
295
|
-
|
296
|
-
static VALUE
|
297
|
-
fonts_iter_get_name(VALUE self)
|
298
|
-
{
|
299
|
-
CHECK_FITER_IS_VALID(self);
|
300
|
-
return CSTR2RVAL(poppler_fonts_iter_get_name(RVAL2FITER(self)));
|
301
|
-
}
|
302
|
-
|
303
|
-
static VALUE
|
304
|
-
fonts_iter_get_full_name(VALUE self)
|
305
|
-
{
|
306
|
-
CHECK_FITER_IS_VALID(self);
|
307
|
-
return CSTR2RVAL(poppler_fonts_iter_get_full_name(RVAL2FITER(self)));
|
308
|
-
}
|
309
|
-
|
310
|
-
static VALUE
|
311
|
-
fonts_iter_get_file_name(VALUE self)
|
312
|
-
{
|
313
|
-
CHECK_FITER_IS_VALID(self);
|
314
|
-
return CSTR2RVAL(poppler_fonts_iter_get_file_name(RVAL2FITER(self)));
|
315
|
-
}
|
316
|
-
|
317
|
-
static VALUE
|
318
|
-
fonts_iter_get_font_type(VALUE self)
|
319
|
-
{
|
320
|
-
CHECK_FITER_IS_VALID(self);
|
321
|
-
return GENUM2RVAL(poppler_fonts_iter_get_font_type(RVAL2FITER(self)),
|
322
|
-
POPPLER_TYPE_FONT_TYPE);
|
323
|
-
}
|
324
|
-
|
325
|
-
static VALUE
|
326
|
-
fonts_iter_is_embedded(VALUE self)
|
327
|
-
{
|
328
|
-
CHECK_FITER_IS_VALID(self);
|
329
|
-
return CBOOL2RVAL(poppler_fonts_iter_is_embedded(RVAL2FITER(self)));
|
330
|
-
}
|
331
|
-
|
332
|
-
static VALUE
|
333
|
-
fonts_iter_is_subset(VALUE self)
|
334
|
-
{
|
335
|
-
CHECK_FITER_IS_VALID(self);
|
336
|
-
return CBOOL2RVAL(poppler_fonts_iter_is_subset(RVAL2FITER(self)));
|
337
|
-
}
|
338
|
-
|
339
|
-
static VALUE
|
340
|
-
fonts_iter_next(VALUE self)
|
341
|
-
{
|
342
|
-
if (poppler_fonts_iter_next(RVAL2FITER(self))) {
|
343
|
-
return Qtrue;
|
344
|
-
} else {
|
345
|
-
rb_ivar_set(self, id_valid, Qfalse);
|
346
|
-
return Qfalse;
|
347
|
-
}
|
348
|
-
}
|
349
|
-
|
350
|
-
static VALUE
|
351
|
-
fonts_iter_each(VALUE self)
|
352
|
-
{
|
353
|
-
PopplerFontsIter *iter;
|
354
|
-
|
355
|
-
CHECK_FITER_IS_VALID(self);
|
356
|
-
iter = RVAL2FITER(self);
|
357
|
-
do {
|
358
|
-
rb_yield(self);
|
359
|
-
} while (poppler_fonts_iter_next(iter));
|
360
|
-
rb_ivar_set(self, id_valid, Qfalse);
|
361
|
-
|
362
|
-
return self;
|
363
|
-
}
|
364
|
-
|
365
|
-
|
366
|
-
/* Export to ps */
|
367
|
-
static VALUE
|
368
|
-
ps_file_initialize(VALUE self, VALUE document, VALUE filename,
|
369
|
-
VALUE first_page, VALUE n_pages)
|
370
|
-
{
|
371
|
-
PopplerPSFile *ps_file;
|
372
|
-
|
373
|
-
ps_file = poppler_ps_file_new(RVAL2GOBJ(document), RVAL2CSTR(filename),
|
374
|
-
NUM2INT(first_page), NUM2INT(n_pages));
|
375
|
-
|
376
|
-
if (!ps_file)
|
377
|
-
rb_raise(rb_eRuntimeError, "can't create Poppler::PSFile");
|
378
|
-
|
379
|
-
G_INITIALIZE(self, ps_file);
|
380
|
-
return Qnil;
|
381
|
-
}
|
382
|
-
|
383
|
-
static VALUE
|
384
|
-
ps_file_set_paper_size(VALUE self, VALUE width, VALUE height)
|
385
|
-
{
|
386
|
-
poppler_ps_file_set_paper_size(RVAL2GOBJ(self),
|
387
|
-
NUM2DBL(width), NUM2DBL(height));
|
388
|
-
return Qnil;
|
389
|
-
}
|
390
|
-
|
391
|
-
static VALUE
|
392
|
-
ps_file_set_duplex(VALUE self, VALUE duplex)
|
393
|
-
{
|
394
|
-
poppler_ps_file_set_duplex(RVAL2GOBJ(self), RVAL2CBOOL(duplex));
|
395
|
-
return Qnil;
|
396
|
-
}
|
397
|
-
|
398
183
|
void
|
399
184
|
Init_poppler_document(VALUE mPoppler)
|
400
185
|
{
|
401
|
-
VALUE
|
186
|
+
VALUE RG_TARGET_NAMESPACE;
|
187
|
+
cIndexIter = rb_const_get(mPoppler, rb_intern("IndexIter"));
|
188
|
+
cFontInfo = rb_const_get(mPoppler, rb_intern("FontInfo"));
|
402
189
|
|
403
190
|
id_new = rb_intern("new");
|
404
|
-
id_valid = rb_intern("valid?");
|
405
191
|
id_pdf_data_p = rb_intern("pdf_data?");
|
406
192
|
id_ensure_uri = rb_intern("ensure_uri");
|
407
193
|
|
408
|
-
|
409
|
-
cIndexIter = G_DEF_CLASS(POPPLER_TYPE_INDEX_ITER, "IndexIter", mPoppler);
|
410
|
-
cFontInfo = G_DEF_CLASS(POPPLER_TYPE_FONT_INFO, "FontInfo", mPoppler);
|
411
|
-
cFontsIter = G_DEF_CLASS(POPPLER_TYPE_FONTS_ITER, "FontsIter", mPoppler);
|
412
|
-
cPSFile = G_DEF_CLASS(POPPLER_TYPE_PS_FILE, "PSFile", mPoppler);
|
194
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS(POPPLER_TYPE_DOCUMENT, "Document", mPoppler);
|
413
195
|
|
414
196
|
G_DEF_CLASS(POPPLER_TYPE_PAGE_LAYOUT, "PageLayout", mPoppler);
|
415
197
|
G_DEF_CLASS(POPPLER_TYPE_PAGE_MODE, "PageMode", mPoppler);
|
@@ -417,76 +199,28 @@ Init_poppler_document(VALUE mPoppler)
|
|
417
199
|
G_DEF_CLASS(POPPLER_TYPE_VIEWER_PREFERENCES, "ViewerPreferences", mPoppler);
|
418
200
|
G_DEF_CLASS(POPPLER_TYPE_PERMISSIONS, "Permissions", mPoppler);
|
419
201
|
|
420
|
-
rb_include_module(
|
421
|
-
|
422
|
-
rb_define_method(cDocument, "initialize", doc_initialize, -1);
|
423
|
-
rb_define_method(cDocument, "save", doc_save, 1);
|
424
|
-
rb_define_method(cDocument, "save_a_copy", doc_save_a_copy, 1);
|
425
|
-
rb_define_method(cDocument, "n_pages", doc_get_n_pages, 0);
|
426
|
-
rb_define_alias(cDocument, "size", "n_pages");
|
427
|
-
rb_define_method(cDocument, "get_page", doc_get_page, 1);
|
428
|
-
rb_define_alias(cDocument, "[]", "get_page");
|
429
|
-
rb_define_method(cDocument, "has_attachments?", doc_has_attachments, 0);
|
430
|
-
rb_define_alias(cDocument, "have_attachments?", "has_attachments?");
|
431
|
-
rb_define_method(cDocument, "attachments", doc_get_attachments, 0);
|
432
|
-
rb_define_method(cDocument, "find_dest", doc_find_dest, 1);
|
433
|
-
rb_define_alias(cDocument, "get_destination", "find_dest");
|
434
|
-
|
435
|
-
rb_define_method(cDocument, "get_form_field", doc_get_form_field, 1);
|
436
|
-
|
437
|
-
rb_define_method(cDocument, "each", doc_each, 0);
|
438
|
-
rb_define_alias(cDocument, "pages", "to_a");
|
439
|
-
|
440
|
-
rb_define_method(cDocument, "index_iter", doc_get_index_iter, 0);
|
441
|
-
rb_define_method(cDocument, "font_info", doc_get_font_info, 0);
|
442
|
-
|
443
|
-
G_DEF_SETTERS(cDocument);
|
444
|
-
|
445
|
-
|
446
|
-
/* Interface for getting the Index of a poppler_document */
|
447
|
-
rb_include_module(cIndexIter, rb_mEnumerable);
|
448
|
-
|
449
|
-
rb_define_method(cIndexIter, "initialize", index_iter_initialize, 1);
|
450
|
-
rb_define_method(cIndexIter, "child", index_iter_get_child, 0);
|
451
|
-
rb_define_method(cIndexIter, "open?", index_iter_is_open, 0);
|
452
|
-
#ifndef HAVE_TYPE_POPPLERACTIONANY
|
453
|
-
rb_define_method(cIndexIter, "action", index_iter_get_action, 0);
|
454
|
-
#endif
|
455
|
-
rb_define_method(cIndexIter, "next", index_iter_next, 0);
|
456
|
-
|
457
|
-
rb_define_method(cIndexIter, "valid?", index_iter_valid_p, 0);
|
458
|
-
rb_define_method(cIndexIter, "each", index_iter_each, 0);
|
459
|
-
|
460
|
-
G_DEF_SETTERS(cIndexIter);
|
461
|
-
|
462
|
-
|
463
|
-
#if POPPLER_CHECK_VERSION(0, 6, 0)
|
464
|
-
rb_define_method(cFontInfo, "initialize", font_info_initialize, 1);
|
465
|
-
rb_define_method(cFontInfo, "scan", font_info_scan, 1);
|
466
|
-
G_DEF_SETTERS(cFontInfo);
|
467
|
-
#endif
|
468
|
-
|
469
|
-
rb_include_module(cFontsIter, rb_mEnumerable);
|
202
|
+
rb_include_module(RG_TARGET_NAMESPACE, rb_mEnumerable);
|
470
203
|
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
204
|
+
RG_DEF_METHOD(initialize, -1);
|
205
|
+
RG_DEF_METHOD(save, 1);
|
206
|
+
RG_DEF_METHOD(save_a_copy, 1);
|
207
|
+
RG_DEF_METHOD(n_pages, 0);
|
208
|
+
RG_DEF_ALIAS("size", "n_pages");
|
209
|
+
RG_DEF_METHOD(get_page, 1);
|
210
|
+
RG_DEF_ALIAS("[]", "get_page");
|
211
|
+
RG_DEF_METHOD_P(has_attachments, 0);
|
212
|
+
RG_DEF_ALIAS("have_attachments?", "has_attachments?");
|
213
|
+
RG_DEF_METHOD(attachments, 0);
|
214
|
+
RG_DEF_METHOD(find_dest, 1);
|
215
|
+
RG_DEF_ALIAS("get_destination", "find_dest");
|
480
216
|
|
481
|
-
|
482
|
-
rb_define_method(cFontsIter, "each", fonts_iter_each, 0);
|
217
|
+
RG_DEF_METHOD(get_form_field, 1);
|
483
218
|
|
484
|
-
|
219
|
+
RG_DEF_METHOD(each, 0);
|
220
|
+
RG_DEF_ALIAS("pages", "to_a");
|
485
221
|
|
486
|
-
|
487
|
-
|
488
|
-
rb_define_method(cPSFile, "set_paper_size", ps_file_set_paper_size, 2);
|
489
|
-
rb_define_method(cPSFile, "set_duplex", ps_file_set_duplex, 1);
|
222
|
+
RG_DEF_METHOD(index_iter, 0);
|
223
|
+
RG_DEF_METHOD(font_info, 0);
|
490
224
|
|
491
|
-
G_DEF_SETTERS(
|
225
|
+
G_DEF_SETTERS(RG_TARGET_NAMESPACE);
|
492
226
|
}
|