poppler 3.1.8-x86-mingw32 → 3.1.9-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dependency-check/Rakefile +44 -0
- data/lib/poppler.rb +21 -107
- data/lib/poppler/annot-callout-line.rb +57 -0
- data/lib/poppler/cairo.rb +23 -0
- data/lib/poppler/color.rb +36 -0
- data/lib/poppler/deprecated.rb +67 -0
- data/lib/poppler/document.rb +108 -0
- data/lib/poppler/image-mapping.rb +25 -0
- data/lib/poppler/index-iter.rb +30 -0
- data/lib/poppler/loader.rb +139 -0
- data/lib/poppler/page.rb +61 -0
- data/lib/poppler/rectangle.rb +40 -0
- data/lib/poppler/version.rb +35 -0
- data/sample/number-pdf.rb +21 -2
- data/sample/pdf2.rb +0 -4
- data/sample/pdf2svg.rb +1 -1
- data/sample/pdf2text.rb +1 -1
- data/sample/pdfcrop.rb +1 -1
- data/sample/pdfdiv.rb +1 -1
- data/test/fixtures/image.odt +0 -0
- data/test/fixtures/image.pdf +0 -0
- data/test/fixtures/multiple-pages.odt +0 -0
- data/test/fixtures/multiple-pages.pdf +0 -0
- data/test/fixtures/text-field.odt +0 -0
- data/test/fixtures/text-field.pdf +0 -0
- data/test/poppler-test-utils.rb +24 -16
- data/test/run-test.rb +26 -4
- data/test/test-annotation.rb +76 -0
- data/test/{test_color.rb → test-color.rb} +0 -3
- data/test/test-constants.rb +16 -0
- data/test/{test_document.rb → test-document.rb} +26 -10
- data/test/test-page.rb +101 -0
- data/vendor/local/bin/cjpeg.exe +0 -0
- data/vendor/local/bin/djpeg.exe +0 -0
- data/vendor/local/bin/jpegtran.exe +0 -0
- data/vendor/local/bin/libjpeg-9.dll +0 -0
- data/vendor/local/bin/libopenjp2.dll +0 -0
- data/vendor/local/bin/libpoppler-59.dll +0 -0
- data/vendor/local/bin/libpoppler-cpp-0.dll +0 -0
- data/vendor/local/bin/libpoppler-glib-8.dll +0 -0
- data/vendor/local/bin/libsqlite3-0.dll +0 -0
- data/vendor/local/bin/opj_compress.exe +0 -0
- data/vendor/local/bin/opj_decompress.exe +0 -0
- data/vendor/local/bin/opj_dump.exe +0 -0
- data/vendor/local/bin/pdfdetach.exe +0 -0
- data/vendor/local/bin/pdffonts.exe +0 -0
- data/vendor/local/bin/pdfimages.exe +0 -0
- data/vendor/local/bin/pdfinfo.exe +0 -0
- data/vendor/local/bin/pdfseparate.exe +0 -0
- data/vendor/local/bin/pdftocairo.exe +0 -0
- data/vendor/local/bin/pdftohtml.exe +0 -0
- data/vendor/local/bin/pdftoppm.exe +0 -0
- data/vendor/local/bin/pdftops.exe +0 -0
- data/vendor/local/bin/pdftotext.exe +0 -0
- data/vendor/local/bin/pdfunite.exe +0 -0
- data/vendor/local/bin/rdjpgcom.exe +0 -0
- data/vendor/local/bin/sqlite3.exe +0 -0
- data/vendor/local/bin/wrjpgcom.exe +0 -0
- data/vendor/local/lib/libjpeg.dll.a +0 -0
- data/vendor/local/lib/libopenjp2.dll.a +0 -0
- data/vendor/local/lib/libpoppler-cpp.dll.a +0 -0
- data/vendor/local/lib/libpoppler-glib.a +0 -0
- data/vendor/local/lib/libpoppler-glib.dll.a +0 -0
- data/vendor/local/lib/libpoppler.a +0 -0
- data/vendor/local/lib/libpoppler.dll.a +0 -0
- data/vendor/local/lib/libsqlite3.dll.a +0 -0
- metadata +26 -46
- data/README +0 -35
- data/ext/poppler/depend +0 -6
- data/ext/poppler/extconf.rb +0 -73
- data/ext/poppler/poppler.def +0 -2
- data/ext/poppler/rbpoppler-action.c +0 -402
- data/ext/poppler/rbpoppler-annotation-callout-line.c +0 -127
- data/ext/poppler/rbpoppler-annotation-free-text.c +0 -46
- data/ext/poppler/rbpoppler-annotation-mapping.c +0 -72
- data/ext/poppler/rbpoppler-annotation-markup.c +0 -98
- data/ext/poppler/rbpoppler-annotation-text.c +0 -53
- data/ext/poppler/rbpoppler-annotation.c +0 -74
- data/ext/poppler/rbpoppler-attachment.c +0 -124
- data/ext/poppler/rbpoppler-button-field.c +0 -56
- data/ext/poppler/rbpoppler-choice-field.c +0 -131
- data/ext/poppler/rbpoppler-color.c +0 -107
- data/ext/poppler/rbpoppler-document.c +0 -224
- data/ext/poppler/rbpoppler-font-info.c +0 -59
- data/ext/poppler/rbpoppler-fonts-iter.c +0 -127
- data/ext/poppler/rbpoppler-form-field-mapping.c +0 -44
- data/ext/poppler/rbpoppler-form-field.c +0 -98
- data/ext/poppler/rbpoppler-image-mapping.c +0 -48
- data/ext/poppler/rbpoppler-index-iter.c +0 -130
- data/ext/poppler/rbpoppler-link-mapping.c +0 -47
- data/ext/poppler/rbpoppler-page-transition.c +0 -59
- data/ext/poppler/rbpoppler-page.c +0 -322
- data/ext/poppler/rbpoppler-private.h +0 -77
- data/ext/poppler/rbpoppler-ps-file.c +0 -66
- data/ext/poppler/rbpoppler-rectangle.c +0 -92
- data/ext/poppler/rbpoppler-text-field.c +0 -91
- data/ext/poppler/rbpoppler.c +0 -110
- data/ext/poppler/rbpoppler.h +0 -61
- data/ext/poppler/rbpopplerconversions.h +0 -105
- data/extconf.rb +0 -49
- data/lib/2.2/poppler.so +0 -0
- data/lib/2.3/poppler.so +0 -0
- data/lib/2.4/poppler.so +0 -0
- data/test/fixtures/image.png +0 -0
- data/test/test_annotation.rb +0 -86
- data/test/test_constants.rb +0 -30
- data/test/test_page.rb +0 -51
@@ -1,124 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
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 cAttachment
|
25
|
-
#define SELF(self) (RVAL2POPPLERATTACHMENT(self))
|
26
|
-
|
27
|
-
static ID id_call;
|
28
|
-
|
29
|
-
static gboolean
|
30
|
-
attachment_save_func(const gchar *buf, gsize count, gpointer data,
|
31
|
-
G_GNUC_UNUSED GError **error)
|
32
|
-
{
|
33
|
-
VALUE result;
|
34
|
-
VALUE callback = (VALUE)data;
|
35
|
-
|
36
|
-
result = rb_funcall(callback, id_call, 1, rb_str_new(buf, count));
|
37
|
-
return RVAL2CBOOL(result);
|
38
|
-
}
|
39
|
-
|
40
|
-
static VALUE
|
41
|
-
rg_save(int argc, VALUE *argv, VALUE self)
|
42
|
-
{
|
43
|
-
VALUE filename;
|
44
|
-
gboolean result;
|
45
|
-
GError *error = NULL;
|
46
|
-
|
47
|
-
rb_scan_args(argc, argv, "01", &filename);
|
48
|
-
|
49
|
-
if (NIL_P(filename)) {
|
50
|
-
if (rb_block_given_p()) {
|
51
|
-
gpointer user_data = (gpointer)rb_block_proc();
|
52
|
-
result = poppler_attachment_save_to_callback(SELF(self),
|
53
|
-
attachment_save_func,
|
54
|
-
user_data,
|
55
|
-
&error);
|
56
|
-
} else {
|
57
|
-
rb_raise(rb_eArgError, "must provide filename or block");
|
58
|
-
}
|
59
|
-
} else {
|
60
|
-
result = poppler_attachment_save(SELF(self), RVAL2CSTR(filename),
|
61
|
-
&error);
|
62
|
-
}
|
63
|
-
|
64
|
-
if (error)
|
65
|
-
RAISE_GERROR(error);
|
66
|
-
|
67
|
-
return CBOOL2RVAL(result);
|
68
|
-
}
|
69
|
-
|
70
|
-
static VALUE
|
71
|
-
rg_name(VALUE self)
|
72
|
-
{
|
73
|
-
return CSTR2RVAL(SELF(self)->name);
|
74
|
-
}
|
75
|
-
|
76
|
-
static VALUE
|
77
|
-
rg_description(VALUE self)
|
78
|
-
{
|
79
|
-
return CSTR2RVAL(SELF(self)->description);
|
80
|
-
}
|
81
|
-
|
82
|
-
static VALUE
|
83
|
-
rg_size(VALUE self)
|
84
|
-
{
|
85
|
-
return INT2NUM(SELF(self)->size);
|
86
|
-
}
|
87
|
-
|
88
|
-
static VALUE
|
89
|
-
rg_mtime(VALUE self)
|
90
|
-
{
|
91
|
-
return rb_time_new(SELF(self)->mtime, 0);
|
92
|
-
}
|
93
|
-
|
94
|
-
static VALUE
|
95
|
-
rg_ctime(VALUE self)
|
96
|
-
{
|
97
|
-
return rb_time_new(SELF(self)->ctime, 0);
|
98
|
-
}
|
99
|
-
|
100
|
-
static VALUE
|
101
|
-
rg_checksum(VALUE self)
|
102
|
-
{
|
103
|
-
GString *checksum;
|
104
|
-
checksum = SELF(self)->checksum;
|
105
|
-
return rb_str_new(checksum->str, checksum->len);
|
106
|
-
}
|
107
|
-
|
108
|
-
void
|
109
|
-
Init_poppler_attachment(VALUE mPoppler)
|
110
|
-
{
|
111
|
-
VALUE RG_TARGET_NAMESPACE;
|
112
|
-
|
113
|
-
id_call = rb_intern("call");
|
114
|
-
|
115
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(POPPLER_TYPE_ATTACHMENT, "Attachment", mPoppler);
|
116
|
-
|
117
|
-
RG_DEF_METHOD(save, -1);
|
118
|
-
RG_DEF_METHOD(name, 0);
|
119
|
-
RG_DEF_METHOD(description, 0);
|
120
|
-
RG_DEF_METHOD(size, 0);
|
121
|
-
RG_DEF_METHOD(mtime, 0);
|
122
|
-
RG_DEF_METHOD(ctime, 0);
|
123
|
-
RG_DEF_METHOD(checksum, 0);
|
124
|
-
}
|
@@ -1,56 +0,0 @@
|
|
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
|
-
}
|
@@ -1,131 +0,0 @@
|
|
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
|
-
}
|
@@ -1,107 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011-2013 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
|
-
return RVAL2BOXED(color, POPPLER_TYPE_COLOR);
|
33
|
-
}
|
34
|
-
|
35
|
-
VALUE
|
36
|
-
rb_poppler_ruby_object_from_color_with_free(PopplerColor *color)
|
37
|
-
{
|
38
|
-
VALUE rb_color;
|
39
|
-
|
40
|
-
rb_color = POPPLERCOLOR2RVAL(color);
|
41
|
-
g_free(color);
|
42
|
-
return rb_color;
|
43
|
-
}
|
44
|
-
|
45
|
-
static VALUE
|
46
|
-
rg_initialize(VALUE self, VALUE red, VALUE green, VALUE blue)
|
47
|
-
{
|
48
|
-
PopplerColor color;
|
49
|
-
|
50
|
-
color.red = NUM2UINT(red);
|
51
|
-
color.green = NUM2UINT(green);
|
52
|
-
color.blue = NUM2UINT(blue);
|
53
|
-
|
54
|
-
G_INITIALIZE(self, g_boxed_copy(POPPLER_TYPE_COLOR, &color));
|
55
|
-
return Qnil;
|
56
|
-
}
|
57
|
-
|
58
|
-
DEF_ACCESSOR(color, red, RVAL2POPPLERCOLOR, UINT2NUM, NUM2UINT)
|
59
|
-
DEF_ACCESSOR(color, green, RVAL2POPPLERCOLOR, UINT2NUM, NUM2UINT)
|
60
|
-
DEF_ACCESSOR(color, blue, RVAL2POPPLERCOLOR, UINT2NUM, NUM2UINT)
|
61
|
-
|
62
|
-
static VALUE
|
63
|
-
rg_to_a(VALUE self)
|
64
|
-
{
|
65
|
-
PopplerColor *color;
|
66
|
-
color = RVAL2POPPLERCOLOR(self);
|
67
|
-
return rb_ary_new3(3,
|
68
|
-
UINT2NUM(color->red),
|
69
|
-
UINT2NUM(color->green),
|
70
|
-
UINT2NUM(color->blue));
|
71
|
-
}
|
72
|
-
|
73
|
-
static VALUE
|
74
|
-
rg_inspect(VALUE self)
|
75
|
-
{
|
76
|
-
VALUE inspected;
|
77
|
-
gchar *rgb;
|
78
|
-
PopplerColor *color;
|
79
|
-
|
80
|
-
color = RVAL2POPPLERCOLOR(self);
|
81
|
-
inspected = rb_call_super(0, NULL);
|
82
|
-
rb_str_resize(inspected, RSTRING_LEN(inspected) - 1);
|
83
|
-
rgb = g_strdup_printf(": [%u, %u, %u]>",
|
84
|
-
color->red, color->green, color->blue);
|
85
|
-
rb_str_cat2(inspected, rgb);
|
86
|
-
g_free(rgb);
|
87
|
-
return inspected;
|
88
|
-
}
|
89
|
-
#endif
|
90
|
-
|
91
|
-
void
|
92
|
-
Init_poppler_color(VALUE mPoppler)
|
93
|
-
{
|
94
|
-
#ifdef POPPLER_TYPE_COLOR
|
95
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(POPPLER_TYPE_COLOR, "Color", mPoppler);
|
96
|
-
|
97
|
-
RG_DEF_METHOD(initialize, 3);
|
98
|
-
rbg_define_method(RG_TARGET_NAMESPACE, "red", color_get_red, 0);
|
99
|
-
rbg_define_method(RG_TARGET_NAMESPACE, "green", color_get_green, 0);
|
100
|
-
rbg_define_method(RG_TARGET_NAMESPACE, "blue", color_get_blue, 0);
|
101
|
-
rbg_define_method(RG_TARGET_NAMESPACE, "set_red", color_set_red, 1);
|
102
|
-
rbg_define_method(RG_TARGET_NAMESPACE, "set_green", color_set_green, 1);
|
103
|
-
rbg_define_method(RG_TARGET_NAMESPACE, "set_blue", color_set_blue, 1);
|
104
|
-
RG_DEF_METHOD(to_a, 0);
|
105
|
-
RG_DEF_METHOD(inspect, 0);
|
106
|
-
#endif
|
107
|
-
}
|
@@ -1,224 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
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;
|
27
|
-
static VALUE cIndexIter;
|
28
|
-
static VALUE cFontInfo;
|
29
|
-
|
30
|
-
static VALUE
|
31
|
-
rg_initialize(int argc, VALUE *argv, VALUE self)
|
32
|
-
{
|
33
|
-
PopplerDocument *document = NULL;
|
34
|
-
GError *error = NULL;
|
35
|
-
VALUE uri_or_data, rb_password;
|
36
|
-
const char *password;
|
37
|
-
|
38
|
-
rb_scan_args(argc, argv, "11", &uri_or_data, &rb_password);
|
39
|
-
|
40
|
-
password = RVAL2CSTR_ACCEPT_NIL(rb_password);
|
41
|
-
|
42
|
-
if (RVAL2CBOOL(rb_funcall(self, id_pdf_data_p, 1, uri_or_data))) {
|
43
|
-
document = poppler_document_new_from_data(RSTRING_PTR(uri_or_data),
|
44
|
-
RSTRING_LEN(uri_or_data),
|
45
|
-
password, &error);
|
46
|
-
}
|
47
|
-
|
48
|
-
if (!document && !error) {
|
49
|
-
uri_or_data = rb_funcall(self, id_ensure_uri, 1, uri_or_data);
|
50
|
-
document = poppler_document_new_from_file(RVAL2CSTR(uri_or_data),
|
51
|
-
password, &error);
|
52
|
-
}
|
53
|
-
|
54
|
-
if (error)
|
55
|
-
RAISE_GERROR(error);
|
56
|
-
|
57
|
-
G_INITIALIZE(self, document);
|
58
|
-
return Qnil;
|
59
|
-
}
|
60
|
-
|
61
|
-
static VALUE
|
62
|
-
rg_save(VALUE self, VALUE uri)
|
63
|
-
{
|
64
|
-
gboolean result;
|
65
|
-
GError *error = NULL;
|
66
|
-
|
67
|
-
uri = rb_funcall(self, id_ensure_uri, 1, uri);
|
68
|
-
result = poppler_document_save(RVAL2POPPLERDOCUMENT(self), RVAL2CSTR(uri), &error);
|
69
|
-
|
70
|
-
if (error)
|
71
|
-
RAISE_GERROR(error);
|
72
|
-
|
73
|
-
return CBOOL2RVAL(result);
|
74
|
-
}
|
75
|
-
|
76
|
-
static VALUE
|
77
|
-
rg_save_a_copy(VALUE self, VALUE uri)
|
78
|
-
{
|
79
|
-
gboolean result;
|
80
|
-
GError *error = NULL;
|
81
|
-
|
82
|
-
uri = rb_funcall(self, id_ensure_uri, 1, uri);
|
83
|
-
result = poppler_document_save_a_copy(RVAL2POPPLERDOCUMENT(self), RVAL2CSTR(uri),
|
84
|
-
&error);
|
85
|
-
|
86
|
-
if (error)
|
87
|
-
RAISE_GERROR(error);
|
88
|
-
|
89
|
-
return CBOOL2RVAL(result);
|
90
|
-
}
|
91
|
-
|
92
|
-
static VALUE
|
93
|
-
rg_n_pages(VALUE self)
|
94
|
-
{
|
95
|
-
return INT2NUM(poppler_document_get_n_pages(RVAL2POPPLERDOCUMENT(self)));
|
96
|
-
}
|
97
|
-
|
98
|
-
static VALUE
|
99
|
-
rg_get_page(VALUE self, VALUE index_or_label)
|
100
|
-
{
|
101
|
-
VALUE rb_page;
|
102
|
-
PopplerPage *page;
|
103
|
-
|
104
|
-
if (RVAL2CBOOL(rb_obj_is_kind_of(index_or_label, rb_cInteger))) {
|
105
|
-
page = poppler_document_get_page(RVAL2POPPLERDOCUMENT(self),
|
106
|
-
NUM2INT(index_or_label));
|
107
|
-
} else if (RVAL2CBOOL(rb_obj_is_kind_of(index_or_label, rb_cString))) {
|
108
|
-
page = poppler_document_get_page_by_label(RVAL2POPPLERDOCUMENT(self),
|
109
|
-
RVAL2CSTR(index_or_label));
|
110
|
-
} else {
|
111
|
-
VALUE inspect;
|
112
|
-
inspect = rb_inspect(index_or_label);
|
113
|
-
rb_raise(rb_eArgError, "%s must be Integer or String",
|
114
|
-
RVAL2CSTR(inspect));
|
115
|
-
}
|
116
|
-
|
117
|
-
rb_page = GOBJ2RVAL(page);
|
118
|
-
if (page)
|
119
|
-
g_object_unref(page);
|
120
|
-
return rb_page;
|
121
|
-
}
|
122
|
-
|
123
|
-
static VALUE
|
124
|
-
rg_has_attachments_p(VALUE self)
|
125
|
-
{
|
126
|
-
return CBOOL2RVAL(poppler_document_has_attachments(RVAL2POPPLERDOCUMENT(self)));
|
127
|
-
}
|
128
|
-
|
129
|
-
static VALUE
|
130
|
-
rg_attachments(VALUE self)
|
131
|
-
{
|
132
|
-
return GLIST2ARYF(poppler_document_get_attachments(RVAL2POPPLERDOCUMENT(self)));
|
133
|
-
}
|
134
|
-
|
135
|
-
static VALUE
|
136
|
-
rg_find_dest(VALUE self, VALUE link_name)
|
137
|
-
{
|
138
|
-
PopplerDest *dest;
|
139
|
-
dest = poppler_document_find_dest(RVAL2POPPLERDOCUMENT(self), RVAL2CSTR(link_name));
|
140
|
-
return POPPLERDEST2RVAL(dest);
|
141
|
-
}
|
142
|
-
|
143
|
-
static VALUE
|
144
|
-
rg_get_form_field(VALUE self, VALUE id)
|
145
|
-
{
|
146
|
-
return GOBJ2RVAL(poppler_document_get_form_field(RVAL2POPPLERDOCUMENT(self),
|
147
|
-
NUM2INT(id)));
|
148
|
-
}
|
149
|
-
|
150
|
-
static VALUE
|
151
|
-
rg_each(VALUE self)
|
152
|
-
{
|
153
|
-
PopplerDocument *document;
|
154
|
-
int i, n_pages;
|
155
|
-
|
156
|
-
document = RVAL2POPPLERDOCUMENT(self);
|
157
|
-
n_pages = poppler_document_get_n_pages(document);
|
158
|
-
for (i = 0; i < n_pages; i++) {
|
159
|
-
PopplerPage *page;
|
160
|
-
VALUE rb_page;
|
161
|
-
|
162
|
-
page = poppler_document_get_page(document, i);
|
163
|
-
rb_page = GOBJ2RVAL(page);
|
164
|
-
if (page)
|
165
|
-
g_object_unref(page);
|
166
|
-
rb_yield(rb_page);
|
167
|
-
}
|
168
|
-
return self;
|
169
|
-
}
|
170
|
-
|
171
|
-
static VALUE
|
172
|
-
rg_index_iter(VALUE self)
|
173
|
-
{
|
174
|
-
return rb_funcall(cIndexIter, id_new, 1, self);
|
175
|
-
}
|
176
|
-
|
177
|
-
static VALUE
|
178
|
-
rg_font_info(VALUE self)
|
179
|
-
{
|
180
|
-
return rb_funcall(cFontInfo, id_new, 1, self);
|
181
|
-
}
|
182
|
-
|
183
|
-
void
|
184
|
-
Init_poppler_document(VALUE mPoppler)
|
185
|
-
{
|
186
|
-
VALUE RG_TARGET_NAMESPACE;
|
187
|
-
cIndexIter = rb_const_get(mPoppler, rb_intern("IndexIter"));
|
188
|
-
cFontInfo = rb_const_get(mPoppler, rb_intern("FontInfo"));
|
189
|
-
|
190
|
-
id_new = rb_intern("new");
|
191
|
-
id_pdf_data_p = rb_intern("pdf_data?");
|
192
|
-
id_ensure_uri = rb_intern("ensure_uri");
|
193
|
-
|
194
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(POPPLER_TYPE_DOCUMENT, "Document", mPoppler);
|
195
|
-
|
196
|
-
G_DEF_CLASS(POPPLER_TYPE_PAGE_LAYOUT, "PageLayout", mPoppler);
|
197
|
-
G_DEF_CLASS(POPPLER_TYPE_PAGE_MODE, "PageMode", mPoppler);
|
198
|
-
G_DEF_CLASS(POPPLER_TYPE_FONT_TYPE, "FontType", mPoppler);
|
199
|
-
G_DEF_CLASS(POPPLER_TYPE_VIEWER_PREFERENCES, "ViewerPreferences", mPoppler);
|
200
|
-
G_DEF_CLASS(POPPLER_TYPE_PERMISSIONS, "Permissions", mPoppler);
|
201
|
-
|
202
|
-
rb_include_module(RG_TARGET_NAMESPACE, rb_mEnumerable);
|
203
|
-
|
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");
|
216
|
-
|
217
|
-
RG_DEF_METHOD(get_form_field, 1);
|
218
|
-
|
219
|
-
RG_DEF_METHOD(each, 0);
|
220
|
-
RG_DEF_ALIAS("pages", "to_a");
|
221
|
-
|
222
|
-
RG_DEF_METHOD(index_iter, 0);
|
223
|
-
RG_DEF_METHOD(font_info, 0);
|
224
|
-
}
|