poppler 3.1.8 → 3.1.9
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
- metadata +28 -45
- 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/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
data/extconf.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'pathname'
|
4
|
-
require 'mkmf'
|
5
|
-
require 'rbconfig'
|
6
|
-
require 'fileutils'
|
7
|
-
|
8
|
-
package = "poppler"
|
9
|
-
|
10
|
-
base_dir = Pathname(__FILE__).dirname.expand_path
|
11
|
-
ext_dir = base_dir + "ext" + package
|
12
|
-
mkmf_gnome2_dir = base_dir + 'lib'
|
13
|
-
|
14
|
-
ruby = File.join(RbConfig::CONFIG['bindir'],
|
15
|
-
RbConfig::CONFIG['ruby_install_name'] +
|
16
|
-
RbConfig::CONFIG["EXEEXT"])
|
17
|
-
|
18
|
-
build_dir = Pathname("ext") + package
|
19
|
-
FileUtils.mkdir_p(build_dir.to_s) unless build_dir.exist?
|
20
|
-
extconf_rb_path = ext_dir + "extconf.rb"
|
21
|
-
system(ruby, "-C", build_dir.to_s, extconf_rb_path.to_s, *ARGV) || exit(false)
|
22
|
-
|
23
|
-
create_makefile(package)
|
24
|
-
FileUtils.mv("Makefile", "Makefile.lib")
|
25
|
-
|
26
|
-
File.open("Makefile", "w") do |makefile|
|
27
|
-
makefile.puts(<<-EOM)
|
28
|
-
all:
|
29
|
-
(cd ext/#{package} && $(MAKE))
|
30
|
-
$(MAKE) -f Makefile.lib
|
31
|
-
|
32
|
-
install:
|
33
|
-
(cd ext/#{package} && $(MAKE) install)
|
34
|
-
$(MAKE) -f Makefile.lib install
|
35
|
-
|
36
|
-
site-install:
|
37
|
-
(cd ext/#{package} && $(MAKE) site-install)
|
38
|
-
$(MAKE) -f Makefile.lib site-install
|
39
|
-
|
40
|
-
clean:
|
41
|
-
(cd ext/#{package} && $(MAKE) clean)
|
42
|
-
$(MAKE) -f Makefile.lib clean
|
43
|
-
|
44
|
-
distclean:
|
45
|
-
(cd ext/#{package} && $(MAKE) distclean)
|
46
|
-
$(MAKE) -f Makefile.lib distclean
|
47
|
-
@rm -f Makefile.lib
|
48
|
-
EOM
|
49
|
-
end
|
data/test/fixtures/image.png
DELETED
Binary file
|
data/test/test_annotation.rb
DELETED
@@ -1,86 +0,0 @@
|
|
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 do
|
83
|
-
object.method_defined?(method)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
data/test/test_constants.rb
DELETED
@@ -1,30 +0,0 @@
|
|
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
|
data/test/test_page.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
class TestPage < Test::Unit::TestCase
|
2
|
-
def test_get_image
|
3
|
-
omit("We don't have PDF that has image...")
|
4
|
-
document = Poppler::Document.new(image_pdf)
|
5
|
-
page, mapping = find_first_image_mapping(document)
|
6
|
-
assert_kind_of(Cairo::ImageSurface, page.get_image(mapping.image_id))
|
7
|
-
assert_kind_of(Cairo::ImageSurface, mapping.image)
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_selection_region
|
11
|
-
document = Poppler::Document.new(form_pdf)
|
12
|
-
page = document[0]
|
13
|
-
rectangle = Poppler::Rectangle.new(0, 0, *page.size)
|
14
|
-
region = page.get_selection_region(0.5, :word, rectangle)
|
15
|
-
if later_version?(0, 7, 2)
|
16
|
-
assert_kind_of(Poppler::Rectangle, region[0])
|
17
|
-
else
|
18
|
-
assert_kind_of(Gdk::Region, region)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_annotation_mapping
|
23
|
-
only_poppler_version(0, 7, 2)
|
24
|
-
document = Poppler::Document.new(form_pdf)
|
25
|
-
page = document[0]
|
26
|
-
assert_equal([Poppler::AnnotationMapping],
|
27
|
-
page.annotation_mapping.collect {|mapping| mapping.class}.uniq)
|
28
|
-
mapping = page.annotation_mapping[0]
|
29
|
-
assert_kind_of(Poppler::Rectangle, mapping.area)
|
30
|
-
assert_kind_of(Poppler::Annotation, mapping.annotation)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_text_layout
|
34
|
-
only_poppler_version(0, 16, 0)
|
35
|
-
document = Poppler::Document.new(form_pdf)
|
36
|
-
page = document[0]
|
37
|
-
layout = page.text_layout
|
38
|
-
assert_equal([60, 31, 79, 60],
|
39
|
-
layout[0].to_a.collect(&:round))
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
def find_first_image_mapping(document)
|
44
|
-
document.each do |page|
|
45
|
-
page.image_mapping.each do |mapping|
|
46
|
-
return [page, mapping]
|
47
|
-
end
|
48
|
-
end
|
49
|
-
nil
|
50
|
-
end
|
51
|
-
end
|