poppler 3.1.8-x86-mingw32 → 3.1.9-x86-mingw32
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
- 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
@@ -0,0 +1,25 @@
|
|
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 ImageMapping
|
19
|
+
attr_accessor :page
|
20
|
+
|
21
|
+
def image
|
22
|
+
@page.get_image(image_id)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
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 IndexIter
|
19
|
+
include Enumerable
|
20
|
+
|
21
|
+
def each
|
22
|
+
return to_enum(__method__) unless block_given?
|
23
|
+
|
24
|
+
loop do
|
25
|
+
yield(self)
|
26
|
+
break unless self.next
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,139 @@
|
|
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 Loader < GObjectIntrospection::Loader
|
19
|
+
private
|
20
|
+
def pre_load(repository, namespace)
|
21
|
+
@form_field_classes = {}
|
22
|
+
end
|
23
|
+
|
24
|
+
def post_load(repository, namespace)
|
25
|
+
require_libraries
|
26
|
+
convert_action_classes
|
27
|
+
convert_field_classes
|
28
|
+
end
|
29
|
+
|
30
|
+
def require_libraries
|
31
|
+
require "poppler/version"
|
32
|
+
|
33
|
+
require "poppler/annot-callout-line"
|
34
|
+
require "poppler/cairo"
|
35
|
+
require "poppler/color"
|
36
|
+
require "poppler/document"
|
37
|
+
require "poppler/image-mapping"
|
38
|
+
require "poppler/index-iter"
|
39
|
+
require "poppler/page"
|
40
|
+
require "poppler/rectangle"
|
41
|
+
|
42
|
+
require "poppler/deprecated"
|
43
|
+
end
|
44
|
+
|
45
|
+
def load_enum_info(info)
|
46
|
+
case info.name
|
47
|
+
when "AnnotType"
|
48
|
+
self.class.register_constant_rename_map("3D", "TYPE_3D")
|
49
|
+
when "AnnotExternalDataType"
|
50
|
+
self.class.register_constant_rename_map("3D", "TYPE_3D")
|
51
|
+
when "StructureGlyphOrientation"
|
52
|
+
self.class.register_constant_rename_map("0", "DEGREE_0")
|
53
|
+
self.class.register_constant_rename_map("90", "DEGREE_90")
|
54
|
+
self.class.register_constant_rename_map("180", "DEGREE_180")
|
55
|
+
self.class.register_constant_rename_map("270", "DEGREE_270")
|
56
|
+
end
|
57
|
+
super
|
58
|
+
end
|
59
|
+
|
60
|
+
def load_method_info(info, klass, method_name)
|
61
|
+
case klass.name
|
62
|
+
when "Poppler::Annot"
|
63
|
+
case method_name
|
64
|
+
when "annot_type"
|
65
|
+
method_name = "type"
|
66
|
+
end
|
67
|
+
when "Poppler::FormField"
|
68
|
+
case method_name
|
69
|
+
when /\Abutton_/
|
70
|
+
klass = define_field_class("ButtonField")
|
71
|
+
method_name = rubyish_method_name(info, prefix: "button_")
|
72
|
+
method_name = "type" if method_name == "button_type"
|
73
|
+
when /\Atext_/
|
74
|
+
klass = define_field_class("TextField")
|
75
|
+
method_name = rubyish_method_name(info, prefix: "text_")
|
76
|
+
method_name = "type" if method_name == "text_type"
|
77
|
+
when /\Achoice_/
|
78
|
+
klass = define_field_class("ChoiceField")
|
79
|
+
method_name = rubyish_method_name(info, prefix: "choice_")
|
80
|
+
method_name = "type" if method_name == "choice_type"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
super(info, klass, method_name)
|
84
|
+
end
|
85
|
+
|
86
|
+
def define_struct(info, options={})
|
87
|
+
case info.name
|
88
|
+
when /\AAction.+/
|
89
|
+
options[:parent] = Action
|
90
|
+
end
|
91
|
+
super(info, options)
|
92
|
+
end
|
93
|
+
|
94
|
+
def convert_action_classes
|
95
|
+
unknown_class = Class.new(Action)
|
96
|
+
@base_module.const_set("ActionUnknown", unknown_class)
|
97
|
+
|
98
|
+
action_map = {
|
99
|
+
ActionType::UNKNOWN => unknown_class,
|
100
|
+
ActionType::GOTO_DEST => ActionGotoDest,
|
101
|
+
ActionType::GOTO_REMOTE => ActionGotoRemote,
|
102
|
+
ActionType::LAUNCH => ActionLaunch,
|
103
|
+
ActionType::URI => ActionUri,
|
104
|
+
ActionType::NAMED => ActionNamed,
|
105
|
+
ActionType::MOVIE => ActionMovie,
|
106
|
+
ActionType::RENDITION => ActionRendition,
|
107
|
+
ActionType::OCG_STATE => ActionOCGState,
|
108
|
+
ActionType::JAVASCRIPT => ActionJavascript,
|
109
|
+
}
|
110
|
+
self.class.register_boxed_class_converter(Action.gtype) do |action|
|
111
|
+
action_map[action.type] || Action
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def define_field_class(name)
|
116
|
+
klass = @form_field_classes[name]
|
117
|
+
return klass if klass
|
118
|
+
|
119
|
+
field_class = @base_module.const_get("FormField")
|
120
|
+
klass = @form_field_classes[name] = Class.new(field_class)
|
121
|
+
@base_module.const_set(name, klass)
|
122
|
+
klass
|
123
|
+
end
|
124
|
+
|
125
|
+
def convert_field_classes
|
126
|
+
define_field_class("SignatureField")
|
127
|
+
|
128
|
+
field_map = {
|
129
|
+
FormFieldType::BUTTON => ButtonField,
|
130
|
+
FormFieldType::TEXT => TextField,
|
131
|
+
FormFieldType::CHOICE => ChoiceField,
|
132
|
+
FormFieldType::SIGNATURE => SignatureField,
|
133
|
+
}
|
134
|
+
self.class.register_object_class_converter(FormField.gtype) do |field|
|
135
|
+
field_map[field.field_type] || FormField
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
data/lib/poppler/page.rb
ADDED
@@ -0,0 +1,61 @@
|
|
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 Page
|
19
|
+
alias_method :text_layout_raw, :text_layout
|
20
|
+
def text_layout
|
21
|
+
success, rectangles = text_layout_raw
|
22
|
+
if success
|
23
|
+
rectangles
|
24
|
+
else
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
alias_method :image_mapping_raw, :image_mapping
|
30
|
+
def image_mapping
|
31
|
+
mappings = image_mapping_raw
|
32
|
+
mappings.each do |mapping|
|
33
|
+
mapping.page = self
|
34
|
+
end
|
35
|
+
mappings
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_text(options={})
|
39
|
+
area = options[:area]
|
40
|
+
style = options[:style]
|
41
|
+
if area
|
42
|
+
if style
|
43
|
+
get_selected_text(style, area)
|
44
|
+
else
|
45
|
+
get_text_for_area(area)
|
46
|
+
end
|
47
|
+
else
|
48
|
+
text
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
alias_method :find_text_raw, :find_text
|
53
|
+
def find_text(text, options=nil)
|
54
|
+
if options.nil?
|
55
|
+
find_text_raw(text)
|
56
|
+
else
|
57
|
+
find_text_with_options(text, options)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,40 @@
|
|
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 Rectangle
|
19
|
+
alias_method :initialize_raw, :initialize
|
20
|
+
def initialize(*args)
|
21
|
+
super()
|
22
|
+
return if args.empty?
|
23
|
+
|
24
|
+
self.x1 = args[0]
|
25
|
+
self.y1 = args[1]
|
26
|
+
self.x2 = args[2]
|
27
|
+
self.y2 = args[3]
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_a
|
31
|
+
[x1, y1, x2, y2]
|
32
|
+
end
|
33
|
+
|
34
|
+
def inspect
|
35
|
+
super.gsub(/>\z/) do
|
36
|
+
": [%g, %g, %g, %g]>" % to_a
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,35 @@
|
|
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
|
+
module Version
|
19
|
+
MAJOR = MAJOR_VERSION
|
20
|
+
MINOR = MINOR_VERSION
|
21
|
+
MICRO = MICRO_VERSION
|
22
|
+
STRING = "#{MAJOR_VERSION}.#{MINOR_VERSION}.#{MICRO_VERSION}"
|
23
|
+
class << self
|
24
|
+
def or_later?(major, minor, micro=nil)
|
25
|
+
micro ||= 0
|
26
|
+
version = [
|
27
|
+
MAJOR_VERSION,
|
28
|
+
MINOR_VERSION,
|
29
|
+
MICRO_VERSION,
|
30
|
+
]
|
31
|
+
(version <=> [major, minor, micro]) >= 0
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/sample/number-pdf.rb
CHANGED
@@ -1,6 +1,25 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# Copyright (C) 2017 Ruby-GNOME2 Project Team
|
3
|
+
#
|
4
|
+
# This library is free software; you can redistribute it and/or
|
5
|
+
# modify it under the terms of the GNU Lesser General Public
|
6
|
+
# License as published by the Free Software Foundation; either
|
7
|
+
# version 2.1 of the License, or (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This library is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
# Lesser General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU Lesser General Public
|
15
|
+
# License along with this library; if not, write to the Free Software
|
16
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2
17
|
|
3
|
-
|
18
|
+
# usage :
|
19
|
+
# ruby number-pdf.rb example.pdf
|
20
|
+
|
21
|
+
require "poppler"
|
22
|
+
require "pango"
|
4
23
|
|
5
24
|
input = ARGV.first
|
6
25
|
output = input.sub(/\.pdf$/, "-numbered.pdf")
|
@@ -21,7 +40,7 @@ Cairo::PDFSurface.new(output, *first_page.size) do |surface|
|
|
21
40
|
layout = context.create_pango_layout
|
22
41
|
layout.text = i.to_s
|
23
42
|
layout.width = width * Pango::SCALE
|
24
|
-
layout.alignment =
|
43
|
+
layout.alignment = :center
|
25
44
|
layout.font_description = Pango::FontDescription.new("Sans 288")
|
26
45
|
context.move_to(0, (height - layout.pixel_size[1]) / 2.0)
|
27
46
|
context.set_source_rgba(0.1, 0.1, 0.1, 0.5)
|
data/sample/pdf2.rb
CHANGED
@@ -118,10 +118,6 @@ def to_pixbuf_with_cairo(input, page_number, scale, rotate)
|
|
118
118
|
GdkPixbuf::Pixbuf.new(:file => temp.path)
|
119
119
|
end
|
120
120
|
|
121
|
-
unless Poppler.cairo_available?
|
122
|
-
puts "cairo isn't available."
|
123
|
-
exit(false)
|
124
|
-
end
|
125
121
|
pixbuf = to_pixbuf_with_cairo(input, page, scale, rotate)
|
126
122
|
|
127
123
|
if pixbuf.nil?
|
data/sample/pdf2svg.rb
CHANGED
data/sample/pdf2text.rb
CHANGED
data/sample/pdfcrop.rb
CHANGED
data/sample/pdfdiv.rb
CHANGED
Binary file
|
data/test/fixtures/image.pdf
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/test/poppler-test-utils.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "open-uri"
|
2
|
+
require "fileutils"
|
3
3
|
|
4
4
|
module PopplerTestUtils
|
5
5
|
def ensure_dir(dir)
|
@@ -15,47 +15,55 @@ module PopplerTestUtils
|
|
15
15
|
ensure_dir(File.join(test_dir, "fixtures"))
|
16
16
|
end
|
17
17
|
|
18
|
+
def fixture_path(*components)
|
19
|
+
File.join(fixtures_dir, *components)
|
20
|
+
end
|
21
|
+
|
18
22
|
def tmp_dir
|
19
23
|
ensure_dir(File.join(test_dir, "tmp"))
|
20
24
|
end
|
21
25
|
|
22
26
|
def form_pdf
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
path = fixture_path("form.pdf")
|
28
|
+
unless File.exist?(path)
|
29
|
+
pdf = open("https://www.irs.gov/pub/irs-pdf/fw9.pdf").read
|
30
|
+
File.open(path, "wb") do |output|
|
31
|
+
output.print(pdf)
|
32
|
+
end
|
28
33
|
end
|
29
|
-
|
34
|
+
path
|
35
|
+
end
|
36
|
+
|
37
|
+
def text_field_pdf
|
38
|
+
fixture_path("text-field.pdf")
|
30
39
|
end
|
31
40
|
|
32
41
|
def image_pdf
|
33
|
-
|
42
|
+
fixture_path("image.pdf")
|
34
43
|
end
|
35
44
|
|
36
45
|
def image_png
|
37
|
-
|
46
|
+
fixture_path("image.png")
|
38
47
|
end
|
39
48
|
|
40
49
|
def outline_pdf
|
41
|
-
|
50
|
+
fixture_path("outline.pdf")
|
42
51
|
end
|
43
52
|
|
44
|
-
def
|
45
|
-
|
46
|
-
(Poppler::BUILD_VERSION <=> [major, minor, micro]) >= 0
|
53
|
+
def multiple_pages_pdf
|
54
|
+
fixture_path("multiple-pages.pdf")
|
47
55
|
end
|
48
56
|
|
49
57
|
def only_poppler_version(major, minor, micro=nil)
|
50
58
|
micro ||= 0
|
51
|
-
unless
|
59
|
+
unless Poppler::Version.or_later?(major, minor, micro)
|
52
60
|
omit("Require Poppler >= #{major}.#{minor}.#{micro}")
|
53
61
|
end
|
54
62
|
end
|
55
63
|
|
56
64
|
def only_old_poppler_version(major, minor, micro=nil)
|
57
65
|
micro ||= 0
|
58
|
-
if
|
66
|
+
if Poppler::Version.or_later?(major, minor, micro)
|
59
67
|
omit("Require Poppler < #{major}.#{minor}.#{micro}")
|
60
68
|
end
|
61
69
|
end
|