poppler 3.1.8 → 3.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/dependency-check/Rakefile +44 -0
  3. data/lib/poppler.rb +21 -107
  4. data/lib/poppler/annot-callout-line.rb +57 -0
  5. data/lib/poppler/cairo.rb +23 -0
  6. data/lib/poppler/color.rb +36 -0
  7. data/lib/poppler/deprecated.rb +67 -0
  8. data/lib/poppler/document.rb +108 -0
  9. data/lib/poppler/image-mapping.rb +25 -0
  10. data/lib/poppler/index-iter.rb +30 -0
  11. data/lib/poppler/loader.rb +139 -0
  12. data/lib/poppler/page.rb +61 -0
  13. data/lib/poppler/rectangle.rb +40 -0
  14. data/lib/poppler/version.rb +35 -0
  15. data/sample/number-pdf.rb +21 -2
  16. data/sample/pdf2.rb +0 -4
  17. data/sample/pdf2svg.rb +1 -1
  18. data/sample/pdf2text.rb +1 -1
  19. data/sample/pdfcrop.rb +1 -1
  20. data/sample/pdfdiv.rb +1 -1
  21. data/test/fixtures/image.odt +0 -0
  22. data/test/fixtures/image.pdf +0 -0
  23. data/test/fixtures/multiple-pages.odt +0 -0
  24. data/test/fixtures/multiple-pages.pdf +0 -0
  25. data/test/fixtures/text-field.odt +0 -0
  26. data/test/fixtures/text-field.pdf +0 -0
  27. data/test/poppler-test-utils.rb +24 -16
  28. data/test/run-test.rb +26 -4
  29. data/test/test-annotation.rb +76 -0
  30. data/test/{test_color.rb → test-color.rb} +0 -3
  31. data/test/test-constants.rb +16 -0
  32. data/test/{test_document.rb → test-document.rb} +26 -10
  33. data/test/test-page.rb +101 -0
  34. metadata +28 -45
  35. data/README +0 -35
  36. data/ext/poppler/depend +0 -6
  37. data/ext/poppler/extconf.rb +0 -73
  38. data/ext/poppler/poppler.def +0 -2
  39. data/ext/poppler/rbpoppler-action.c +0 -402
  40. data/ext/poppler/rbpoppler-annotation-callout-line.c +0 -127
  41. data/ext/poppler/rbpoppler-annotation-free-text.c +0 -46
  42. data/ext/poppler/rbpoppler-annotation-mapping.c +0 -72
  43. data/ext/poppler/rbpoppler-annotation-markup.c +0 -98
  44. data/ext/poppler/rbpoppler-annotation-text.c +0 -53
  45. data/ext/poppler/rbpoppler-annotation.c +0 -74
  46. data/ext/poppler/rbpoppler-attachment.c +0 -124
  47. data/ext/poppler/rbpoppler-button-field.c +0 -56
  48. data/ext/poppler/rbpoppler-choice-field.c +0 -131
  49. data/ext/poppler/rbpoppler-color.c +0 -107
  50. data/ext/poppler/rbpoppler-document.c +0 -224
  51. data/ext/poppler/rbpoppler-font-info.c +0 -59
  52. data/ext/poppler/rbpoppler-fonts-iter.c +0 -127
  53. data/ext/poppler/rbpoppler-form-field-mapping.c +0 -44
  54. data/ext/poppler/rbpoppler-form-field.c +0 -98
  55. data/ext/poppler/rbpoppler-image-mapping.c +0 -48
  56. data/ext/poppler/rbpoppler-index-iter.c +0 -130
  57. data/ext/poppler/rbpoppler-link-mapping.c +0 -47
  58. data/ext/poppler/rbpoppler-page-transition.c +0 -59
  59. data/ext/poppler/rbpoppler-page.c +0 -322
  60. data/ext/poppler/rbpoppler-private.h +0 -77
  61. data/ext/poppler/rbpoppler-ps-file.c +0 -66
  62. data/ext/poppler/rbpoppler-rectangle.c +0 -92
  63. data/ext/poppler/rbpoppler-text-field.c +0 -91
  64. data/ext/poppler/rbpoppler.c +0 -110
  65. data/ext/poppler/rbpoppler.h +0 -61
  66. data/ext/poppler/rbpopplerconversions.h +0 -105
  67. data/extconf.rb +0 -49
  68. data/test/fixtures/image.png +0 -0
  69. data/test/test_annotation.rb +0 -86
  70. data/test/test_constants.rb +0 -30
  71. data/test/test_page.rb +0 -51
@@ -1,4 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (C) 2017 Ruby-GNOME2 Project Team
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+
2
19
 
3
20
  base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
4
21
 
@@ -7,14 +24,19 @@ have_make = system("which make > /dev/null")
7
24
  glib_dir = File.expand_path(File.join(base_dir, "..", "glib2"))
8
25
  gdk_pixbuf_dir = File.expand_path(File.join(base_dir, "..", "gdk_pixbuf2"))
9
26
  pango_dir = File.join(File.join(base_dir, ".." , "pango"))
27
+ gobject_introspection_dir =
28
+ File.join(File.join(base_dir, ".." , "gobject-introspection"))
10
29
 
11
30
  $LOAD_PATH.unshift(File.join(glib_dir, "test"))
12
31
  require 'glib-test-init'
13
32
 
14
- [[gdk_pixbuf_dir, "gdk_pixbuf2"],
15
- [pango_dir, "pango"],
16
- [glib_dir, "glib2"],
17
- [base_dir, "poppler"]].each do |dir, module_name|
33
+ [
34
+ [glib_dir, "glib2"],
35
+ [gdk_pixbuf_dir, "gdk_pixbuf2"],
36
+ [pango_dir, "pango"],
37
+ [gobject_introspection_dir, "gobject-introspection"],
38
+ [base_dir, "poppler"],
39
+ ].each do |dir, module_name|
18
40
  if File.exist?(File.join(dir, "Makefile"))
19
41
  if have_make
20
42
  system("cd #{dir.dump} && make > /dev/null") or exit(false)
@@ -0,0 +1,76 @@
1
+ class TestAnnotation < Test::Unit::TestCase
2
+ def test_type
3
+ assert_kind_of(Poppler::AnnotType, annotation.type)
4
+ end
5
+
6
+ def test_contents
7
+ assert_nil(annotation.contents)
8
+ end
9
+
10
+ def test_name
11
+ assert_nil(annotation.name)
12
+ end
13
+
14
+ def test_modified
15
+ assert_nil(annotation.modified)
16
+ end
17
+
18
+ def test_flags
19
+ assert_kind_of(Poppler::AnnotFlag, annotation.flags)
20
+ end
21
+
22
+ def test_color
23
+ assert_nil(annotation.color)
24
+ end
25
+
26
+ def test_markup
27
+ # We don't have a PDF that has annotation markup...
28
+ assert_method_defined(Poppler::AnnotMarkup, :label)
29
+ assert_method_defined(Poppler::AnnotMarkup, :popup_is_open?)
30
+ assert_method_defined(Poppler::AnnotMarkup, :opacity)
31
+ assert_method_defined(Poppler::AnnotMarkup, :date)
32
+ assert_method_defined(Poppler::AnnotMarkup, :subject)
33
+ assert_method_defined(Poppler::AnnotMarkup, :reply_to)
34
+ assert_method_defined(Poppler::AnnotMarkup, :external_data)
35
+ end
36
+
37
+ def test_text
38
+ # We don't have a PDF that has annotation text...
39
+ assert_method_defined(Poppler::AnnotText, :open?)
40
+ assert_method_defined(Poppler::AnnotText, :icon)
41
+ assert_method_defined(Poppler::AnnotText, :state)
42
+ end
43
+
44
+ def test_free_text
45
+ # We don't have a PDF that has annotation free text...
46
+ assert_method_defined(Poppler::AnnotFreeText, :quadding)
47
+ assert_method_defined(Poppler::AnnotFreeText, :callout_line)
48
+ end
49
+
50
+ def test_callout_line
51
+ callout_line = Poppler::AnnotCalloutLine.new(true,
52
+ 1.1, 2.2, 3.3,
53
+ 4.4, 5.5, 6.6)
54
+ assert(callout_line.multiline?)
55
+ assert_equal(1.1, callout_line.x1)
56
+ assert_equal(2.2, callout_line.y1)
57
+ assert_equal(3.3, callout_line.x2)
58
+ assert_equal(4.4, callout_line.y2)
59
+ assert_equal(5.5, callout_line.x3)
60
+ assert_equal(6.6, callout_line.y3)
61
+ assert_equal([true, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6], callout_line.to_a)
62
+ end
63
+
64
+ private
65
+ def annotation
66
+ document = Poppler::Document.new(form_pdf)
67
+ page = document[0]
68
+ page.annot_mapping[0].annot
69
+ end
70
+
71
+ def assert_method_defined(object, method)
72
+ assert do
73
+ object.method_defined?(method)
74
+ end
75
+ end
76
+ end
@@ -1,13 +1,11 @@
1
1
  class TestColor < Test::Unit::TestCase
2
2
  def test_initialize
3
- only_poppler_version(0, 7, 2)
4
3
  rose = Poppler::Color.new(65535, 0, 32639)
5
4
  assert_equal([65535, 0, 32639], [rose.red, rose.green, rose.blue])
6
5
  assert_equal([65535, 0, 32639], rose.to_a)
7
6
  end
8
7
 
9
8
  def test_accessor
10
- only_poppler_version(0, 7, 2)
11
9
  white = Poppler::Color.new(65535, 65535, 65535)
12
10
  red = white.dup
13
11
  red.green = 0
@@ -17,7 +15,6 @@ class TestColor < Test::Unit::TestCase
17
15
  end
18
16
 
19
17
  def test_inspect
20
- only_poppler_version(0, 7, 2)
21
18
  color = Poppler::Color.new(0, 32767, 65535)
22
19
  rgb = '[0, 32767, 65535]'
23
20
  assert_match(/\A#<Poppler::Color:.*: #{Regexp.escape(rgb)}>\z/,
@@ -0,0 +1,16 @@
1
+ class TestConstants < Test::Unit::TestCase
2
+ def test_annotation
3
+ assert_const_defined(Poppler, :AnnotType)
4
+ assert_equal("3d", Poppler::AnnotType::TYPE_3D.nick)
5
+ assert_const_defined(Poppler, :AnnotFlag)
6
+ assert_const_defined(Poppler, :AnnotMarkupReplyType)
7
+ assert_const_defined(Poppler, :AnnotExternalDataType)
8
+ assert_equal("3d", Poppler::AnnotExternalDataType::TYPE_3D.nick)
9
+ assert_const_defined(Poppler, :AnnotTextState)
10
+ assert_const_defined(Poppler, :AnnotFreeTextQuadding)
11
+ end
12
+
13
+ def test_permissions
14
+ assert_const_defined(Poppler, :Permissions)
15
+ end
16
+ end
@@ -3,32 +3,48 @@ class TestDocument < Test::Unit::TestCase
3
3
  saved_pdf = File.join(tmp_dir, "saved.pdf")
4
4
  FileUtils.rm_f(saved_pdf)
5
5
 
6
- document = Poppler::Document.new(form_pdf)
6
+ document = Poppler::Document.new(text_field_pdf)
7
7
  find_first_text_field(document).text = "XXX"
8
- assert(document.save(saved_pdf))
9
- assert(File.exist?(saved_pdf))
10
-
11
- only_poppler_version(0, 8, 2)
8
+ document.save(saved_pdf)
12
9
  reread_document = Poppler::Document.new(saved_pdf)
13
10
  assert_equal("XXX", find_first_text_field(reread_document).text)
14
11
  end
15
12
 
16
13
  def test_save_a_copy
17
- only_poppler_version(0, 7, 2)
18
14
  copied_pdf = File.join(tmp_dir, "copied.pdf")
19
15
  FileUtils.rm_f(copied_pdf)
20
16
 
21
- document = Poppler::Document.new(form_pdf)
17
+ document = Poppler::Document.new(text_field_pdf)
22
18
  first_text_field = find_first_text_field(document)
23
19
  default_text = first_text_field.text
24
20
  first_text_field.text = "XXX"
25
- assert(document.save_a_copy(copied_pdf))
26
- assert(File.exist?(copied_pdf))
27
-
21
+ document.save_a_copy(copied_pdf)
28
22
  reread_document = Poppler::Document.new(copied_pdf)
29
23
  assert_equal(default_text, find_first_text_field(reread_document).text)
30
24
  end
31
25
 
26
+ def test_each
27
+ document = Poppler::Document.new(multiple_pages_pdf)
28
+ texts = []
29
+ document.each do |page|
30
+ texts << page.text
31
+ end
32
+ assert_equal(["The first page", "The second page"],
33
+ texts)
34
+ end
35
+
36
+ def test_each_enumerator
37
+ document = Poppler::Document.new(multiple_pages_pdf)
38
+ assert_equal(["The first page", "The second page"],
39
+ document.each.collect(&:text))
40
+ end
41
+
42
+ def test_enumerable
43
+ document = Poppler::Document.new(multiple_pages_pdf)
44
+ assert_equal(["The first page", "The second page"],
45
+ document.collect(&:text))
46
+ end
47
+
32
48
  private
33
49
  def find_first_text_field(document)
34
50
  document.each do |page|
@@ -0,0 +1,101 @@
1
+ # Copyright (C) 2008-2017 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestPage < Test::Unit::TestCase
18
+ def test_get_image
19
+ document = Poppler::Document.new(image_pdf)
20
+ page, mapping = find_first_image_mapping(document)
21
+ assert_kind_of(Cairo::ImageSurface, page.get_image(mapping.image_id))
22
+ assert_kind_of(Cairo::ImageSurface, mapping.image)
23
+ end
24
+
25
+ def test_selection_region
26
+ document = Poppler::Document.new(form_pdf)
27
+ page = document[0]
28
+ rectangle = Poppler::Rectangle.new(0, 0, *page.size)
29
+ region = page.get_selection_region(0.5, :word, rectangle)
30
+ assert_kind_of(Poppler::Rectangle, region[0])
31
+ end
32
+
33
+ def test_annot_mapping
34
+ document = Poppler::Document.new(form_pdf)
35
+ page = document[0]
36
+ assert_equal([Poppler::AnnotMapping],
37
+ page.annot_mapping.collect {|mapping| mapping.class}.uniq)
38
+ mapping = page.annot_mapping[0]
39
+ assert_kind_of(Poppler::Rectangle, mapping.area)
40
+ assert_kind_of(Poppler::Annot, mapping.annot)
41
+ end
42
+
43
+ def test_text_layout
44
+ only_poppler_version(0, 16, 0)
45
+ document = Poppler::Document.new(form_pdf)
46
+ page = document[0]
47
+ layout = page.text_layout
48
+ assert_equal([60, 31, 79, 60],
49
+ layout[0].to_a.collect(&:round))
50
+ end
51
+
52
+ sub_test_case("#find_text") do
53
+ def normalize_rectangles(rectangles)
54
+ rectangles.collect do |rectangle|
55
+ rectangle.to_a.collect(&:round)
56
+ end
57
+ end
58
+
59
+ test "no options" do
60
+ document = Poppler::Document.new(multiple_pages_pdf)
61
+ page = document[0]
62
+ text_areas = page.find_text("firs")
63
+ assert_equal([[78, 771, 94, 785]],
64
+ normalize_rectangles(text_areas))
65
+ end
66
+
67
+ test "with default option" do
68
+ document = Poppler::Document.new(multiple_pages_pdf)
69
+ page = document[0]
70
+ text_areas = page.find_text("firs", :default)
71
+ assert_equal([[78, 771, 94, 785]],
72
+ normalize_rectangles(text_areas))
73
+ end
74
+
75
+ test "with options and bad text" do
76
+ document = Poppler::Document.new(multiple_pages_pdf)
77
+ page = document[0]
78
+ text_areas = page.find_text("fIrs", [:whole_words_only, :case_sensitive])
79
+ assert_equal([],
80
+ normalize_rectangles(text_areas))
81
+ end
82
+
83
+ test "with options and good text" do
84
+ document = Poppler::Document.new(multiple_pages_pdf)
85
+ page = document[0]
86
+ text_areas = page.find_text("first", [:whole_words_only, :case_sensitive])
87
+ assert_equal([[78, 771, 98, 785]],
88
+ normalize_rectangles(text_areas))
89
+ end
90
+ end
91
+
92
+ private
93
+ def find_first_image_mapping(document)
94
+ document.each do |page|
95
+ page.image_mapping.each do |mapping|
96
+ return [page, mapping]
97
+ end
98
+ end
99
+ nil
100
+ end
101
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poppler
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.8
4
+ version: 3.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Ruby-GNOME2 Project Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-15 00:00:00.000000000 Z
11
+ date: 2017-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cairo
@@ -30,75 +30,58 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 3.1.8
33
+ version: 3.1.9
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 3.1.8
40
+ version: 3.1.9
41
41
  description: Ruby/Poppler is a Ruby binding of poppler-glib.
42
42
  email: ruby-gnome2-devel-en@lists.sourceforge.net
43
43
  executables: []
44
44
  extensions:
45
- - ext/poppler/extconf.rb
45
+ - dependency-check/Rakefile
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - README
49
48
  - Rakefile
50
- - ext/poppler/depend
51
- - ext/poppler/extconf.rb
52
- - ext/poppler/poppler.def
53
- - ext/poppler/rbpoppler-action.c
54
- - ext/poppler/rbpoppler-annotation-callout-line.c
55
- - ext/poppler/rbpoppler-annotation-free-text.c
56
- - ext/poppler/rbpoppler-annotation-mapping.c
57
- - ext/poppler/rbpoppler-annotation-markup.c
58
- - ext/poppler/rbpoppler-annotation-text.c
59
- - ext/poppler/rbpoppler-annotation.c
60
- - ext/poppler/rbpoppler-attachment.c
61
- - ext/poppler/rbpoppler-button-field.c
62
- - ext/poppler/rbpoppler-choice-field.c
63
- - ext/poppler/rbpoppler-color.c
64
- - ext/poppler/rbpoppler-document.c
65
- - ext/poppler/rbpoppler-font-info.c
66
- - ext/poppler/rbpoppler-fonts-iter.c
67
- - ext/poppler/rbpoppler-form-field-mapping.c
68
- - ext/poppler/rbpoppler-form-field.c
69
- - ext/poppler/rbpoppler-image-mapping.c
70
- - ext/poppler/rbpoppler-index-iter.c
71
- - ext/poppler/rbpoppler-link-mapping.c
72
- - ext/poppler/rbpoppler-page-transition.c
73
- - ext/poppler/rbpoppler-page.c
74
- - ext/poppler/rbpoppler-private.h
75
- - ext/poppler/rbpoppler-ps-file.c
76
- - ext/poppler/rbpoppler-rectangle.c
77
- - ext/poppler/rbpoppler-text-field.c
78
- - ext/poppler/rbpoppler.c
79
- - ext/poppler/rbpoppler.h
80
- - ext/poppler/rbpopplerconversions.h
81
- - extconf.rb
49
+ - dependency-check/Rakefile
82
50
  - lib/poppler.rb
51
+ - lib/poppler/annot-callout-line.rb
52
+ - lib/poppler/cairo.rb
53
+ - lib/poppler/color.rb
54
+ - lib/poppler/deprecated.rb
55
+ - lib/poppler/document.rb
56
+ - lib/poppler/image-mapping.rb
57
+ - lib/poppler/index-iter.rb
58
+ - lib/poppler/loader.rb
59
+ - lib/poppler/page.rb
60
+ - lib/poppler/rectangle.rb
61
+ - lib/poppler/version.rb
83
62
  - sample/number-pdf.rb
84
63
  - sample/pdf2.rb
85
64
  - sample/pdf2svg.rb
86
65
  - sample/pdf2text.rb
87
66
  - sample/pdfcrop.rb
88
67
  - sample/pdfdiv.rb
68
+ - test/fixtures/image.odt
89
69
  - test/fixtures/image.pdf
90
- - test/fixtures/image.png
70
+ - test/fixtures/multiple-pages.odt
71
+ - test/fixtures/multiple-pages.pdf
91
72
  - test/fixtures/outline.odt
92
73
  - test/fixtures/outline.pdf
74
+ - test/fixtures/text-field.odt
75
+ - test/fixtures/text-field.pdf
93
76
  - test/poppler-test-utils.rb
94
77
  - test/run-test.rb
78
+ - test/test-annotation.rb
79
+ - test/test-color.rb
80
+ - test/test-constants.rb
81
+ - test/test-document.rb
95
82
  - test/test-index-iter.rb
83
+ - test/test-page.rb
96
84
  - test/test-version.rb
97
- - test/test_annotation.rb
98
- - test/test_color.rb
99
- - test/test_constants.rb
100
- - test/test_document.rb
101
- - test/test_page.rb
102
85
  homepage: http://ruby-gnome2.sourceforge.jp/
103
86
  licenses:
104
87
  - LGPL-2.1+
@@ -119,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
102
  version: '0'
120
103
  requirements: []
121
104
  rubyforge_project:
122
- rubygems_version: 2.5.2
105
+ rubygems_version: 2.5.2.1
123
106
  signing_key:
124
107
  specification_version: 4
125
108
  summary: Ruby/Poppler is a Ruby binding of poppler-glib.