poppler 3.1.8-x86-mingw32 → 3.1.9-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65505bccd82fd325cc850807ec87f89223d03ceb
|
4
|
+
data.tar.gz: 541577b1c64e45272e926c74b0c46d6eedabc1ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed3a7ae50afdf478b44a76815f854177742ebe3a7759479abbe73b97710b2c2163bd01967845e42a2332d2e9b758de1b5c90f5bb9f3604178453e18dae6494b8
|
7
|
+
data.tar.gz: b27cf394dae5c19a24d4a28a2834c747c6be08b1e4aba27967e93bdadb149509d53a7510d15e5b4a1f502f6488f793dbd80ac8a4f1ea78cf977857a90504fa79
|
@@ -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
|
data/lib/poppler.rb
CHANGED
@@ -1,122 +1,36 @@
|
|
1
|
-
# Copyright(C)
|
1
|
+
# Copyright (C) 2017 Ruby-GNOME2 Project Team
|
2
2
|
#
|
3
|
-
# This library is free software
|
4
|
-
# it under the terms of the GNU Lesser General Public
|
5
|
-
# the Free Software Foundation
|
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
|
-
#
|
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
|
-
#
|
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
|
13
|
-
# along with
|
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 "
|
16
|
-
require "
|
17
|
-
require "
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
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
|