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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b9a5c1641dc902aa348cde39fc68095598a9272
4
- data.tar.gz: b727cf80698603cdb2a2655bb99749c0502ebdab
3
+ metadata.gz: 603e7e64eff68bee1e5a908796ad10f7c0fc0788
4
+ data.tar.gz: 7a677ef67c5730072525efc8079e66d3f7c56e8e
5
5
  SHA512:
6
- metadata.gz: fe2982f6b42a1c90f8137ee05397286ec3eda52d84d88e0e777cb5edc709b65df039bd0b60236cdabe8edcbffec80139733210723a379566430169a403cfbd50
7
- data.tar.gz: cb3d7370d3c3afc3bfa9c783d2305fc768de6318e0d1b725aa1f2d8d55604c6fe9a3360e13cbbd674f112a626157ae45f88831cdd9955f2a8f14a13b859de416
6
+ metadata.gz: d1b85990788133340d5c3377ce5efc725360a27868e25a132da5d7b082c8a9bef83fed1cf196b14bd2e6318d4a74474c49d864d036dde6c09bc7b6371187066d
7
+ data.tar.gz: c2bcb1ea6e5fc621a11fb0e95d01795c0fc74324835eee3e4057bc59bd7605a34d62980cf698997c769cf8aa4dffab207c7c0dd4d524d7a6e9737b4da16d4abf
@@ -0,0 +1,44 @@
1
+ # Copyright (C) 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
+ require "pkg-config"
18
+ require "native-package-installer"
19
+
20
+ if File.exist?(File.join(__dir__, "..", "vendor"))
21
+ task :default => "nothing"
22
+ else
23
+ task :default => "dependency:check"
24
+ end
25
+
26
+ task :nothing do
27
+ end
28
+
29
+ namespace :dependency do
30
+ desc "Check dependency"
31
+ task :check do
32
+ unless PKGConfig.check_version?("poppler", 0, 12, 0)
33
+ unless NativePackageInstaller.install(:alt_linux => "libpoppler-glib-devel",
34
+ :debian => "libpoppler-glib-dev",
35
+ :redhat => "poppler-glib-devel",
36
+ :arch_linux => "poppler",
37
+ :homebrew => "poppler",
38
+ :macports => "poppler",
39
+ :msys2 => "poppler")
40
+ exit(false)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,122 +1,36 @@
1
- # Copyright(C) 2006-2015 Ruby-GNOME2 Project.
1
+ # Copyright (C) 2017 Ruby-GNOME2 Project Team
2
2
  #
3
- # This library is free software: you can redistribute it and/or modify
4
- # it under the terms of the GNU Lesser General Public License as published by
5
- # the Free Software Foundation, either version 2.1 of the License.
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.
6
7
  #
7
- # Foobar is distributed in the hope that it will be useful,
8
+ # This library is distributed in the hope that it will be useful,
8
9
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- # GNU Lesser General Public License for more details.
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
11
12
  #
12
- # You should have received a copy of the GNU Lesser General Public License
13
- # along with Foobar. If not, see <http://www.gnu.org/licenses/>.
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
14
16
 
15
- require "tempfile"
16
- require "date"
17
- require "glib2"
18
- require "gdk_pixbuf2"
19
- require "cairo"
17
+ require "gobject-introspection"
18
+ require "gio2"
19
+ require "cairo-gobject"
20
20
 
21
21
  base_dir = Pathname.new(__FILE__).dirname.dirname.expand_path
22
22
  vendor_dir = base_dir + "vendor" + "local"
23
23
  vendor_bin_dir = vendor_dir + "bin"
24
24
  GLib.prepend_dll_path(vendor_bin_dir)
25
- begin
26
- major, minor, = RUBY_VERSION.split(/\./)
27
- require "#{major}.#{minor}/poppler.so"
28
- rescue LoadError
29
- require "poppler.so"
30
- end
25
+ vendor_girepository_dir = vendor_dir + "lib" + "girepository-1.0"
26
+ GObjectIntrospection.prepend_typelib_path(vendor_girepository_dir)
27
+
28
+ require "poppler/loader"
31
29
 
32
30
  module Poppler
33
31
  LOG_DOMAIN = "Poppler"
32
+ GLib::Log.set_log_domain(LOG_DOMAIN)
34
33
 
35
- VERSION = version.split(".").collect {|x| x.to_i}
36
-
37
- module Version
38
- MAJOR, MINOR, MICRO = BUILD_VERSION
39
- STRING = "#{MAJOR}.#{MINOR}.#{MICRO}"
40
-
41
- class << self
42
- def or_later?(major, minor, micro=nil)
43
- micro || 0
44
- version = [
45
- MAJOR,
46
- MINOR,
47
- MICRO,
48
- ]
49
- (version <=> [major, minor, micro]) >= 0
50
- end
51
- end
52
- end
53
-
54
- class Document
55
- private
56
- def pdf_data?(data)
57
- data.start_with?("%PDF-1.")
58
- end
59
-
60
- def ensure_uri(uri)
61
- if pdf_data?(uri)
62
- @pdf = Tempfile.new("ruby-poppler-pdf")
63
- @pdf.binmode
64
- @pdf.print(uri)
65
- @pdf.close
66
- uri = @pdf.path
67
- end
68
-
69
- if GLib.path_is_absolute?(uri)
70
- GLib.filename_to_uri(uri)
71
- elsif /\A[a-zA-Z][a-zA-Z\d\-+.]*:/.match(uri)
72
- uri
73
- else
74
- GLib.filename_to_uri(File.expand_path(uri))
75
- end
76
- end
77
- end
78
-
79
- if defined?(TextField)
80
- class TextField
81
- def multiline?
82
- type == FormTextType::MULTILINE
83
- end
84
-
85
- def file_select?
86
- type == FormTextType::FILE_SELECT
87
- end
88
-
89
- def normal?
90
- type == FormTextType::NORMAL
91
- end
92
- end
93
- end
94
-
95
- if defined?(ChoiceField)
96
- class ChoiceField
97
- def combo?
98
- type == FormChioceType::COMBO
99
- end
100
-
101
- def list?
102
- type == FormChoiceType::LIST
103
- end
104
- end
105
- end
34
+ loader = Loader.new(self)
35
+ loader.load("Poppler")
106
36
  end
107
-
108
- if Poppler.cairo_available?
109
- module Cairo
110
- class Context
111
- def render_poppler_page(page, *args, &block)
112
- page.render(self, *args, &block)
113
- end
114
-
115
- def render_poppler_page_selection(page, *args, &block)
116
- page.render_selection(self, *args, &block)
117
- end
118
- end
119
- end
120
- end
121
-
122
- GLib::Log.set_log_domain(Poppler::LOG_DOMAIN)
@@ -0,0 +1,57 @@
1
+ # Copyright (C) 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
+ module Poppler
18
+ class AnnotCalloutLine
19
+ alias_method :initialize_raw, :initialize
20
+ def initialize(*args)
21
+ initialize_raw
22
+
23
+ return if args.empty?
24
+
25
+ if args.size == 1 and args[0].is_a?(Hash)
26
+ options = args[0]
27
+ self.multiline = options[:multiline]
28
+ self.x1 = options[:x1] || 0.0
29
+ self.y1 = options[:y1] || 0.0
30
+ self.x2 = options[:x2] || 0.0
31
+ self.y2 = options[:y2] || 0.0
32
+ self.x3 = options[:x3] || 0.0
33
+ self.y3 = options[:y3] || 0.0
34
+ elsif args.size == 7
35
+ self.multiline = args[0]
36
+ self.x1 = args[1]
37
+ self.y1 = args[2]
38
+ self.x2 = args[3]
39
+ self.y2 = args[4]
40
+ self.x3 = args[5]
41
+ self.y3 = args[6]
42
+ else
43
+ message =
44
+ "must be " +
45
+ "Hash({:multiline => true/false, :x1 => Float, :y1 => Float, " +
46
+ ":x2 => Float, :y2 => Float, :x3 => Float, :y3 => Float}) or " +
47
+ "Array([multiline(true/false), x1(Float), y1(Float), x2(Float), " +
48
+ "y2(Float), x3(Float), y3(Float)])"
49
+ raise(ArgumentError, message)
50
+ end
51
+ end
52
+
53
+ def to_a
54
+ [multiline?, x1, y1, x2, y2, x3, y3]
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,23 @@
1
+ # Copyright (C) 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
+ module Cairo
18
+ class Context
19
+ def render_poppler_page(page, options={})
20
+ page.render(self)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,36 @@
1
+ # Copyright (C) 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
+ module Poppler
18
+ class Color
19
+ alias_method :initialize_raw, :initialize
20
+ def initialize(red, green, blue)
21
+ initialize_raw
22
+ self.red = red
23
+ self.green = green
24
+ self.blue = blue
25
+ end
26
+
27
+ def to_a
28
+ [red, green, blue]
29
+ end
30
+
31
+ alias_method :inspect_raw, :inspect
32
+ def inspect
33
+ inspect_raw[0..-2] + ": [#{to_a.join(", ")}]>"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,67 @@
1
+ # Copyright (C) 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
+ module Poppler
18
+ extend GLib::Deprecatable
19
+
20
+ define_deprecated_singleton_method(:cairo_available?,
21
+ :warn => "cairo is always available") do
22
+ true
23
+ end
24
+
25
+ define_deprecated_const(:Annotation, "Poppler::Annot")
26
+ define_deprecated_const(:AnnotationType, "Poppler::AnnotType")
27
+ define_deprecated_const(:AnnotationFlag, "Poppler::AnnotFlag")
28
+ define_deprecated_const(:AnnotationMarkupReplyType,
29
+ "Poppler::AnnotMarkupReplyType")
30
+ define_deprecated_const(:AnnotationExternalDataType,
31
+ "Poppler::AnnotExternalDataType")
32
+ define_deprecated_const(:AnnotationTextState, "Poppler::AnnotTextSate")
33
+ define_deprecated_const(:AnnotationFreeTextQuadding,
34
+ "Poppler::AnnotFreeTextQuadding")
35
+ define_deprecated_const(:AnnotationMarkup,
36
+ "Poppler::AnnotMarkup")
37
+ define_deprecated_const(:AnnotationText,
38
+ "Poppler::AnnotText")
39
+ define_deprecated_const(:AnnotationFreeText,
40
+ "Poppler::AnnotFreeText")
41
+ define_deprecated_const(:AnnotationMapping,
42
+ "Poppler::AnnotMapping")
43
+
44
+ define_deprecated_const(:ActionURI,
45
+ "Poppler::ActionUri")
46
+ define_deprecated_const(:ActionJavaScript,
47
+ "Poppler::ActionJavascript")
48
+
49
+ class AnnotMapping
50
+ extend GLib::Deprecatable
51
+
52
+ define_deprecated_method(:annotation, :annot)
53
+ end
54
+
55
+ class Page
56
+ extend GLib::Deprecatable
57
+
58
+ define_deprecated_method(:annotation_mapping, :annot_mapping)
59
+ define_deprecated_method_by_hash_args(:get_text,
60
+ "area=nil, style=nil",
61
+ ":area => Poppler::Rectangle, " +
62
+ ":style => Poppler::SelectionStyle"
63
+ ) do |page, *args, &block|
64
+ [{:area => args[0], :style => args[1]}]
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,108 @@
1
+ # Copyright (C) 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
+ module Poppler
18
+ class Document
19
+ include Enumerable
20
+
21
+ alias_method :initialize_raw, :initialize
22
+ def initialize(*args)
23
+ if args.size == 1 and args[0].is_a?(Hash)
24
+ options = args[0]
25
+ data = options[:data]
26
+ uri = options[:uri]
27
+ path = options[:path]
28
+ stream = options[:stream]
29
+ length = options[:length]
30
+ file = options[:file]
31
+ password = options[:password]
32
+
33
+ if data
34
+ initialize_new_from_data(data, password)
35
+ elsif uri
36
+ initialize_new_from_file(uri, password)
37
+ elsif path
38
+ uri = ensure_uri(path)
39
+ initialize_new_from_file(uri, password)
40
+ elsif stream
41
+ if length.nil?
42
+ raise(ArgumentError,
43
+ "must specify :length for :stream: #{options.inspect}")
44
+ end
45
+ initialize_new_from_stream(stream, length, password)
46
+ elsif file
47
+ if file.is_a?(String)
48
+ initialize(path: file, password: password)
49
+ else
50
+ initialize_new_from_gfile(file, password)
51
+ end
52
+ else
53
+ message =
54
+ "must specify one of :data, :uri, :path, :stream or :file: " +
55
+ options.inspect
56
+ raise(ArgumentError, message)
57
+ end
58
+ else
59
+ uri_or_data, password = args
60
+ if pdf_data?(uri_or_data)
61
+ initialize_new_from_data(uri_or_data, password)
62
+ else
63
+ uri = ensure_uri(uri_or_data)
64
+ initialize_new_from_file(uri, password)
65
+ end
66
+ end
67
+ end
68
+
69
+ alias_method :[], :get_page
70
+
71
+ def each
72
+ return to_enum(__method__) unless block_given?
73
+
74
+ n_pages.times do |i|
75
+ yield get_page(i)
76
+ end
77
+ end
78
+
79
+ alias_method :save_raw, :save
80
+ def save(uri)
81
+ save_raw(ensure_uri(uri))
82
+ end
83
+
84
+ alias_method :save_a_copy_raw, :save_a_copy
85
+ def save_a_copy(uri)
86
+ save_a_copy_raw(ensure_uri(uri))
87
+ end
88
+
89
+ def index_iter
90
+ IndexIter.new(self)
91
+ end
92
+
93
+ private
94
+ def pdf_data?(data)
95
+ data.start_with?("%PDF-1.")
96
+ end
97
+
98
+ def ensure_uri(uri)
99
+ if GLib.path_is_absolute?(uri)
100
+ GLib.filename_to_uri(uri)
101
+ elsif /\A[a-zA-Z][a-zA-Z\d\-+.]*:/.match(uri)
102
+ uri
103
+ else
104
+ GLib.filename_to_uri(File.expand_path(uri))
105
+ end
106
+ end
107
+ end
108
+ end