poppler 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +369 -0
- data/README +37 -0
- data/Rakefile +72 -0
- data/extconf.rb +49 -0
- data/sample/number-pdf.rb +32 -0
- data/sample/pdf2.rb +107 -0
- data/sample/pdf2svg.rb +26 -0
- data/sample/pdf2text.rb +16 -0
- data/sample/pdfdiv.rb +36 -0
- data/src/lib/poppler.rb +108 -0
- data/src/rbpoppler-action.c +222 -0
- data/src/rbpoppler-annotation.c +307 -0
- data/src/rbpoppler-attachment.c +116 -0
- data/src/rbpoppler-document.c +492 -0
- data/src/rbpoppler-form-field.c +291 -0
- data/src/rbpoppler-page.c +773 -0
- data/src/rbpoppler-private.h +56 -0
- data/src/rbpoppler.c +90 -0
- data/src/rbpoppler.h +60 -0
- data/src/rbpopplerversion.h +24 -0
- data/test/poppler-test-utils.rb +47 -0
- data/test/run-test.rb +27 -0
- data/test/test_annotation.rb +84 -0
- data/test/test_color.rb +26 -0
- data/test/test_constants.rb +30 -0
- data/test/test_document.rb +41 -0
- data/test/test_page.rb +78 -0
- metadata +122 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
#ifndef __RBPOPPLER_PRIVATE_H__
|
2
|
+
#define __RBPOPPLER_PRIVATE_H__
|
3
|
+
|
4
|
+
#include "rbpoppler.h"
|
5
|
+
|
6
|
+
#ifdef POPPLER_WITH_GDK
|
7
|
+
# include <rbgdk.h>
|
8
|
+
#endif
|
9
|
+
|
10
|
+
extern void Init_poppler_document(VALUE mPoppler);
|
11
|
+
extern void Init_poppler_page(VALUE mPoppler);
|
12
|
+
extern void Init_poppler_attachment(VALUE mPoppler);
|
13
|
+
extern void Init_poppler_action(VALUE mPoppler);
|
14
|
+
extern void Init_poppler_annotation(VALUE mPoppler);
|
15
|
+
extern void Init_poppler_form_field(VALUE mPoppler);
|
16
|
+
|
17
|
+
#define DEF_READER(prefix, name, member, self_to_c, member_to_rb) \
|
18
|
+
static VALUE \
|
19
|
+
prefix ## _get_ ## name(VALUE self) \
|
20
|
+
{ \
|
21
|
+
return member_to_rb((self_to_c(self))->member); \
|
22
|
+
}
|
23
|
+
|
24
|
+
#define DEF_WRITER(prefix, name, member, self_to_c, value_to_c) \
|
25
|
+
static VALUE \
|
26
|
+
prefix ## _set_ ## name(VALUE self, VALUE value) \
|
27
|
+
{ \
|
28
|
+
(self_to_c(self))->member = value_to_c(value); \
|
29
|
+
return Qnil; \
|
30
|
+
}
|
31
|
+
|
32
|
+
#define DEF_WRITER_WITH_SETTER(prefix, name, member, \
|
33
|
+
self_to_c, value_setter) \
|
34
|
+
static VALUE \
|
35
|
+
prefix ## _set_ ## name(VALUE self, VALUE value) \
|
36
|
+
{ \
|
37
|
+
value_setter((self_to_c(self))->member, value); \
|
38
|
+
return Qnil; \
|
39
|
+
}
|
40
|
+
|
41
|
+
#define DEF_ACCESSOR(prefix, member, self_to_c, member_to_rb, value_to_c) \
|
42
|
+
DEF_READER(prefix, member, member, self_to_c, member_to_rb) \
|
43
|
+
DEF_WRITER(prefix, member, member, self_to_c, value_to_c) \
|
44
|
+
|
45
|
+
#define DEF_ACCESSOR_WITH_SETTER(prefix, member, self_to_c, \
|
46
|
+
member_to_rb, value_setter) \
|
47
|
+
DEF_READER(prefix, member, member, self_to_c, member_to_rb) \
|
48
|
+
DEF_WRITER_WITH_SETTER(prefix, member, member, self_to_c, value_setter)
|
49
|
+
|
50
|
+
#define DEF_ACCESSOR_WITH_NAME(prefix, name, member, self_to_c, \
|
51
|
+
member_to_rb, value_to_c) \
|
52
|
+
DEF_READER(prefix, name, member, self_to_c, member_to_rb) \
|
53
|
+
DEF_WRITER(prefix, name, member, self_to_c, value_to_c)
|
54
|
+
|
55
|
+
|
56
|
+
#endif
|
data/src/rbpoppler.c
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
/* -*- c-file-style: "ruby" -*- */
|
2
|
+
/**********************************************************************
|
3
|
+
|
4
|
+
rbpoppler.c -
|
5
|
+
|
6
|
+
Copyright (C) 2006-2008 Ruby-GNOME2 Project Team
|
7
|
+
|
8
|
+
**********************************************************************/
|
9
|
+
|
10
|
+
#include "rbpoppler-private.h"
|
11
|
+
|
12
|
+
static VALUE
|
13
|
+
get_backend(VALUE self)
|
14
|
+
{
|
15
|
+
return GENUM2RVAL(poppler_get_backend(), POPPLER_TYPE_BACKEND);
|
16
|
+
}
|
17
|
+
|
18
|
+
static VALUE
|
19
|
+
get_version(VALUE self)
|
20
|
+
{
|
21
|
+
return CSTR2RVAL(poppler_get_version());
|
22
|
+
}
|
23
|
+
|
24
|
+
static VALUE
|
25
|
+
cairo_available(VALUE self)
|
26
|
+
{
|
27
|
+
#ifdef RB_POPPLER_CAIRO_AVAILABLE
|
28
|
+
return Qtrue;
|
29
|
+
#else
|
30
|
+
return Qfalse;
|
31
|
+
#endif
|
32
|
+
}
|
33
|
+
|
34
|
+
|
35
|
+
void
|
36
|
+
Init_poppler(void)
|
37
|
+
{
|
38
|
+
VALUE mPoppler;
|
39
|
+
|
40
|
+
mPoppler = rb_define_module("Poppler");
|
41
|
+
|
42
|
+
rb_define_const(mPoppler, "BUILD_VERSION",
|
43
|
+
rb_ary_new3(3,
|
44
|
+
INT2FIX(POPPLER_MAJOR_VERSION),
|
45
|
+
INT2FIX(POPPLER_MINOR_VERSION),
|
46
|
+
INT2FIX(POPPLER_MICRO_VERSION)));
|
47
|
+
|
48
|
+
G_DEF_CLASS(POPPLER_TYPE_ERROR, "Error", mPoppler);
|
49
|
+
G_DEF_CLASS(POPPLER_TYPE_ORIENTATION, "Orientation", mPoppler);
|
50
|
+
|
51
|
+
G_DEF_CLASS(POPPLER_TYPE_PAGE_TRANSITION_TYPE,
|
52
|
+
"PageTransitionType", mPoppler);
|
53
|
+
G_DEF_CLASS(POPPLER_TYPE_PAGE_TRANSITION_ALIGNMENT,
|
54
|
+
"PageTransitionAlignment", mPoppler);
|
55
|
+
G_DEF_CLASS(POPPLER_TYPE_PAGE_TRANSITION_DIRECTION,
|
56
|
+
"PageTransitionDirection", mPoppler);
|
57
|
+
G_DEF_CLASS(POPPLER_TYPE_SELECTION_STYLE, "SelectionStyle", mPoppler);
|
58
|
+
G_DEF_CLASS(POPPLER_TYPE_FORM_BUTTON_TYPE, "FormButtonType", mPoppler);
|
59
|
+
G_DEF_CLASS(POPPLER_TYPE_FORM_TEXT_TYPE, "FormTextType", mPoppler);
|
60
|
+
G_DEF_CLASS(POPPLER_TYPE_FORM_CHOICE_TYPE, "FormChoiceType", mPoppler);
|
61
|
+
|
62
|
+
G_RENAME_NICK("3D", "TYPE_3D");
|
63
|
+
G_DEF_CLASS(POPPLER_TYPE_ANNOT_TYPE, "AnnotationType", mPoppler);
|
64
|
+
G_DEF_CLASS(POPPLER_TYPE_ANNOT_FLAG, "AnnotationFlag", mPoppler);
|
65
|
+
G_DEF_CLASS(POPPLER_TYPE_ANNOT_MARKUP_REPLY_TYPE,
|
66
|
+
"AnnotationMarkupReplyType", mPoppler);
|
67
|
+
G_RENAME_NICK("3D", "TYPE_3D");
|
68
|
+
G_DEF_CLASS(POPPLER_TYPE_ANNOT_EXTERNAL_DATA_TYPE,
|
69
|
+
"AnnotationExternalDataType", mPoppler);
|
70
|
+
# if !POPPLER_CHECK_VERSION(0, 9, 0)
|
71
|
+
G_DEF_CLASS(POPPLER_TYPE_ANNOT_TEXT_ICON, "AnnotationTextIcon", mPoppler);
|
72
|
+
# endif
|
73
|
+
G_DEF_CLASS(POPPLER_TYPE_ANNOT_TEXT_STATE, "AnnotationTextState", mPoppler);
|
74
|
+
G_DEF_CLASS(POPPLER_TYPE_ANNOT_FREE_TEXT_QUADDING,
|
75
|
+
"AnnotationFreeTextQuadding", mPoppler);
|
76
|
+
|
77
|
+
|
78
|
+
G_DEF_CLASS(POPPLER_TYPE_BACKEND, "Backend", mPoppler);
|
79
|
+
|
80
|
+
rb_define_module_function(mPoppler, "backend", get_backend, 0);
|
81
|
+
rb_define_module_function(mPoppler, "version", get_version, 0);
|
82
|
+
rb_define_module_function(mPoppler, "cairo_available?", cairo_available, 0);
|
83
|
+
|
84
|
+
Init_poppler_document(mPoppler);
|
85
|
+
Init_poppler_page(mPoppler);
|
86
|
+
Init_poppler_attachment(mPoppler);
|
87
|
+
Init_poppler_action(mPoppler);
|
88
|
+
Init_poppler_annotation(mPoppler);
|
89
|
+
Init_poppler_form_field(mPoppler);
|
90
|
+
}
|
data/src/rbpoppler.h
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#ifndef __RBPOPPLER_H__
|
2
|
+
#define __RBPOPPLER_H__
|
3
|
+
|
4
|
+
#include "rbpopplerversion.h"
|
5
|
+
|
6
|
+
#include <ruby.h>
|
7
|
+
|
8
|
+
#include <rbglib.h>
|
9
|
+
#include <rbgobject.h>
|
10
|
+
|
11
|
+
#include <poppler.h>
|
12
|
+
#include "rbglib.h"
|
13
|
+
|
14
|
+
#define RBPOPPLER_MAJOR_VERSION RBGLIB_MAJOR_VERSION
|
15
|
+
#define RBPOPPLER_MINOR_VERSION RBGLIB_MINOR_VERSION
|
16
|
+
#define RBPOPPLER_MICRO_VERSION RBGLIB_MICRO_VERSION
|
17
|
+
|
18
|
+
#ifndef POPPLER_TYPE_INDEX_ITER
|
19
|
+
# define POPPLER_TYPE_INDEX_ITER (poppler_index_iter_get_type ())
|
20
|
+
#endif
|
21
|
+
#ifndef POPPLER_TYPE_FONTS_ITER
|
22
|
+
# define POPPLER_TYPE_FONTS_ITER (poppler_fonts_iter_get_type ())
|
23
|
+
#endif
|
24
|
+
|
25
|
+
#ifndef POPPLER_TYPE_DEST
|
26
|
+
extern GType poppler_dest_get_type (void) G_GNUC_CONST;
|
27
|
+
# define POPPLER_TYPE_DEST (poppler_dest_get_type ())
|
28
|
+
# define RB_POPPLER_TYPE_DEST_NOT_DEFINED
|
29
|
+
#endif
|
30
|
+
|
31
|
+
#if defined(HAVE_RB_CAIRO_H) && defined(POPPLER_HAS_CAIRO)
|
32
|
+
# define RB_POPPLER_CAIRO_AVAILABLE 1
|
33
|
+
# include <rb_cairo.h>
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#define POPPLER_RECT2RVAL(obj) (BOXED2RVAL(obj, POPPLER_TYPE_RECTANGLE))
|
37
|
+
#define RVAL2POPPLER_RECT(obj) ((PopplerRectangle *)RVAL2BOXED(obj, POPPLER_TYPE_RECTANGLE))
|
38
|
+
|
39
|
+
#ifdef POPPLER_TYPE_COLOR
|
40
|
+
extern PopplerColor *rb_poppler_ruby_object_to_color(VALUE color);
|
41
|
+
extern VALUE rb_poppler_ruby_object_from_color_with_free(PopplerColor *color);
|
42
|
+
# define RVAL2POPPLER_COLOR(obj) (rb_poppler_ruby_object_to_color(obj))
|
43
|
+
# define POPPLER_COLOR2RVAL(obj) (BOXED2RVAL(obj, POPPLER_TYPE_COLOR))
|
44
|
+
# define POPPLER_COLOR2RVAL_FREE(obj) (rb_poppler_ruby_object_from_color_with_free(obj))
|
45
|
+
#endif
|
46
|
+
|
47
|
+
|
48
|
+
#define POPPLER_ANNOT2RVAL(obj) (GOBJ2RVAL(obj))
|
49
|
+
#define RVAL2POPPLER_ANNOT(obj) (POPPLER_ANNOT(RVAL2GOBJ(obj)))
|
50
|
+
|
51
|
+
#define POPPLER_ACTION2RVAL(obj) (rb_poppler_ruby_object_from_action(obj))
|
52
|
+
#define RVAL2POPPLER_ACTION(obj) (rb_poppler_action_from_ruby_object(obj))
|
53
|
+
#define POPPLER_FORM_FIELD2RVAL(obj) (rb_poppler_ruby_object_from_form_field(obj))
|
54
|
+
#define RVAL2POPPLER_FORM_FIELD(obj) (POPPLER_FORM_FIELD(RVAL2GOBJ(obj)))
|
55
|
+
|
56
|
+
extern VALUE rb_poppler_ruby_object_from_action(PopplerAction *action);
|
57
|
+
extern PopplerAction *rb_poppler_action_from_ruby_object(VALUE action);
|
58
|
+
extern VALUE rb_poppler_ruby_object_from_form_field(PopplerFormField *field);
|
59
|
+
|
60
|
+
#endif
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/************************************************
|
3
|
+
|
4
|
+
rbpopplerversion.h -
|
5
|
+
|
6
|
+
This file was generated by mkmf-gnome2.rb.
|
7
|
+
|
8
|
+
************************************************/
|
9
|
+
|
10
|
+
#ifndef __RBPOPPLER_VERSION_H__
|
11
|
+
#define __RBPOPPLER_VERSION_H__
|
12
|
+
|
13
|
+
#define POPPLER_MAJOR_VERSION (0)
|
14
|
+
#define POPPLER_MINOR_VERSION (12)
|
15
|
+
#define POPPLER_MICRO_VERSION (1)
|
16
|
+
|
17
|
+
#define POPPLER_CHECK_VERSION(major,minor,micro) \
|
18
|
+
(POPPLER_MAJOR_VERSION > (major) || \
|
19
|
+
(POPPLER_MAJOR_VERSION == (major) && POPPLER_MINOR_VERSION > (minor)) || \
|
20
|
+
(POPPLER_MAJOR_VERSION == (major) && POPPLER_MINOR_VERSION == (minor) && \
|
21
|
+
POPPLER_MICRO_VERSION >= (micro)))
|
22
|
+
|
23
|
+
|
24
|
+
#endif /* __RBPOPPLER_VERSION_H__ */
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module PopplerTestUtils
|
5
|
+
def ensure_dir(dir)
|
6
|
+
FileUtils.mkdir_p(dir)
|
7
|
+
dir
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_dir
|
11
|
+
File.expand_path(File.dirname(__FILE__))
|
12
|
+
end
|
13
|
+
|
14
|
+
def fixtures_dir
|
15
|
+
ensure_dir(File.join(test_dir, "fixtures"))
|
16
|
+
end
|
17
|
+
|
18
|
+
def tmp_dir
|
19
|
+
ensure_dir(File.join(test_dir, "tmp"))
|
20
|
+
end
|
21
|
+
|
22
|
+
def form_pdf
|
23
|
+
file = File.join(fixtures_dir, "form.pdf")
|
24
|
+
return file if File.exist?(file)
|
25
|
+
pdf = open("http://www.irs.gov/pub/irs-pdf/fw9.pdf").read
|
26
|
+
File.open(file, "wb") do |output|
|
27
|
+
output.print(pdf)
|
28
|
+
end
|
29
|
+
file
|
30
|
+
end
|
31
|
+
|
32
|
+
def image_pdf
|
33
|
+
File.join(fixtures_dir, "image.pdf")
|
34
|
+
end
|
35
|
+
|
36
|
+
def later_version?(major, minor, micro=nil)
|
37
|
+
micro ||= 0
|
38
|
+
(Poppler::BUILD_VERSION <=> [major, minor, micro]) >= 0
|
39
|
+
end
|
40
|
+
|
41
|
+
def only_poppler_version(major, minor, micro=nil)
|
42
|
+
micro ||= 0
|
43
|
+
unless later_version?(major, minor, micro)
|
44
|
+
omit("Require Poppler >= #{major}.#{minor}.#{micro}")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/test/run-test.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
4
|
+
|
5
|
+
if system("which make > /dev/null")
|
6
|
+
system("cd #{base_dir.dump} && make > /dev/null") or exit(1)
|
7
|
+
end
|
8
|
+
|
9
|
+
glib_dir = File.expand_path(File.join(base_dir, "..", "glib"))
|
10
|
+
gtk_dir = File.expand_path(File.join(base_dir, "..", "gtk"))
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(glib_dir)
|
13
|
+
require 'test/glib-test-init'
|
14
|
+
|
15
|
+
[gtk_dir, glib_dir, base_dir].each do |dir|
|
16
|
+
$LOAD_PATH.unshift(File.join(dir, "src"))
|
17
|
+
$LOAD_PATH.unshift(File.join(dir, "src", "lib"))
|
18
|
+
end
|
19
|
+
require "poppler"
|
20
|
+
|
21
|
+
$LOAD_PATH.unshift(File.join(base_dir, "test"))
|
22
|
+
require 'poppler-test-utils'
|
23
|
+
class Test::Unit::TestCase
|
24
|
+
include PopplerTestUtils
|
25
|
+
end
|
26
|
+
|
27
|
+
exit Test::Unit::AutoRunner.run(true)
|
@@ -0,0 +1,84 @@
|
|
1
|
+
class TestAnnotation < Test::Unit::TestCase
|
2
|
+
def test_type
|
3
|
+
only_poppler_version(0, 7, 2)
|
4
|
+
assert_kind_of(Poppler::AnnotationType, annotation.type)
|
5
|
+
end
|
6
|
+
|
7
|
+
def test_contents
|
8
|
+
only_poppler_version(0, 7, 2)
|
9
|
+
assert_nil(annotation.contents)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_name
|
13
|
+
only_poppler_version(0, 7, 2)
|
14
|
+
assert_nil(annotation.name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_modified
|
18
|
+
only_poppler_version(0, 7, 2)
|
19
|
+
assert_nil(annotation.modified)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_flags
|
23
|
+
only_poppler_version(0, 7, 2)
|
24
|
+
assert_kind_of(Poppler::AnnotationFlag, annotation.flags)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_color
|
28
|
+
only_poppler_version(0, 7, 2)
|
29
|
+
assert_nil(annotation.color)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_markup
|
33
|
+
only_poppler_version(0, 7, 2)
|
34
|
+
# We don't have a PDF that has annotation markup...
|
35
|
+
assert_method_defined(Poppler::AnnotationMarkup, :label)
|
36
|
+
assert_method_defined(Poppler::AnnotationMarkup, :popup_is_open?)
|
37
|
+
assert_method_defined(Poppler::AnnotationMarkup, :opacity)
|
38
|
+
assert_method_defined(Poppler::AnnotationMarkup, :date)
|
39
|
+
assert_method_defined(Poppler::AnnotationMarkup, :subject)
|
40
|
+
assert_method_defined(Poppler::AnnotationMarkup, :reply_to)
|
41
|
+
assert_method_defined(Poppler::AnnotationMarkup, :external_data)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_text
|
45
|
+
only_poppler_version(0, 7, 2)
|
46
|
+
# We don't have a PDF that has annotation text...
|
47
|
+
assert_method_defined(Poppler::AnnotationText, :open?)
|
48
|
+
assert_method_defined(Poppler::AnnotationText, :icon)
|
49
|
+
assert_method_defined(Poppler::AnnotationText, :state)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_free_text
|
53
|
+
only_poppler_version(0, 7, 2)
|
54
|
+
# We don't have a PDF that has annotation free text...
|
55
|
+
assert_method_defined(Poppler::AnnotationFreeText, :quadding)
|
56
|
+
assert_method_defined(Poppler::AnnotationFreeText, :callout_line)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_callout_line
|
60
|
+
only_poppler_version(0, 7, 2)
|
61
|
+
callout_line = Poppler::AnnotationCalloutLine.new(true,
|
62
|
+
1.1, 2.2, 3.3,
|
63
|
+
4.4, 5.5, 6.6)
|
64
|
+
assert(callout_line.multiline?)
|
65
|
+
assert_equal(1.1, callout_line.x1)
|
66
|
+
assert_equal(2.2, callout_line.y1)
|
67
|
+
assert_equal(3.3, callout_line.x2)
|
68
|
+
assert_equal(4.4, callout_line.y2)
|
69
|
+
assert_equal(5.5, callout_line.x3)
|
70
|
+
assert_equal(6.6, callout_line.y3)
|
71
|
+
assert_equal([true, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6], callout_line.to_a)
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
def annotation
|
76
|
+
document = Poppler::Document.new(form_pdf)
|
77
|
+
page = document[0]
|
78
|
+
page.annotation_mapping[0].annotation
|
79
|
+
end
|
80
|
+
|
81
|
+
def assert_method_defined(object, method)
|
82
|
+
assert_send([object, :method_defined?, method])
|
83
|
+
end
|
84
|
+
end
|
data/test/test_color.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
class TestColor < Test::Unit::TestCase
|
2
|
+
def test_initialize
|
3
|
+
only_poppler_version(0, 7, 2)
|
4
|
+
rose = Poppler::Color.new(65535, 0, 32639)
|
5
|
+
assert_equal([65535, 0, 32639], [rose.red, rose.green, rose.blue])
|
6
|
+
assert_equal([65535, 0, 32639], rose.to_a)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_accessor
|
10
|
+
only_poppler_version(0, 7, 2)
|
11
|
+
white = Poppler::Color.new(65535, 65535, 65535)
|
12
|
+
red = white.dup
|
13
|
+
red.green = 0
|
14
|
+
red.blue = 0
|
15
|
+
assert_equal([65535, 65535, 65535], [white.red, white.green, white.blue])
|
16
|
+
assert_equal([65535, 0, 0], [red.red, red.green, red.blue])
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_inspect
|
20
|
+
only_poppler_version(0, 7, 2)
|
21
|
+
color = Poppler::Color.new(0, 32767, 65535)
|
22
|
+
rgb = '[0, 32767, 65535]'
|
23
|
+
assert_match(/\A#<Poppler::Color:.*: #{Regexp.escape(rgb)}>\z/,
|
24
|
+
color.inspect)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class TestConstants < Test::Unit::TestCase
|
2
|
+
def test_annotation
|
3
|
+
if later_version?(0, 7, 2)
|
4
|
+
assertion = :assert_const_defined
|
5
|
+
else
|
6
|
+
assertion = :assert_not_const_defined
|
7
|
+
end
|
8
|
+
send(assertion, Poppler, :AnnotationType)
|
9
|
+
if assertion == :assert_const_defined
|
10
|
+
assert_equal("3d", Poppler::AnnotationType::TYPE_3D.nick)
|
11
|
+
end
|
12
|
+
send(assertion, Poppler, :AnnotationFlag)
|
13
|
+
send(assertion, Poppler, :AnnotationMarkupReplyType)
|
14
|
+
send(assertion, Poppler, :AnnotationExternalDataType)
|
15
|
+
if assertion == :assert_const_defined
|
16
|
+
assert_equal("3d", Poppler::AnnotationExternalDataType::TYPE_3D.nick)
|
17
|
+
end
|
18
|
+
if later_version?(0, 9, 0)
|
19
|
+
assert_not_const_defined(Poppler, :AnnotationTextIcon)
|
20
|
+
else
|
21
|
+
send(assertion, Poppler, :AnnotationTextIcon)
|
22
|
+
end
|
23
|
+
send(assertion, Poppler, :AnnotationTextState)
|
24
|
+
send(assertion, Poppler, :AnnotationFreeTextQuadding)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_permissions
|
28
|
+
assert_const_defined(Poppler, :Permissions)
|
29
|
+
end
|
30
|
+
end
|