poppler 3.3.2 → 3.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/poppler/document.rb +5 -2
- data/test/test-document.rb +37 -8
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2480ac17782c4bf82a0147711e6ec95953218ec58936c36c09a12ad5c5b2bbf
|
4
|
+
data.tar.gz: 6179294b81290156d47075d34a9e6f011fcffd377a669e1becdde1c7f4a46088
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dec213783ea375fd5859c6966b412753a557367ab3e7492fb3f9602927fa58ade6638cc642420de32557bc90e6fd62c3301ec1173a1064e431d3f362b4fc9f92
|
7
|
+
data.tar.gz: eb68eea6875b4303bef009a1b1be302a08b21acf6daf0916f04f2f795b56693ca85f1cb633604fe7969f0a6a176f4ef394a2011383d993862ba0a2aed5ae8992
|
data/lib/poppler/document.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2017-
|
1
|
+
# Copyright (C) 2017-2019 Ruby-GNOME2 Project Team
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -56,6 +56,7 @@ module Poppler
|
|
56
56
|
# initialize_new_from_data(data, password)
|
57
57
|
|
58
58
|
@file = Tempfile.new(["poppler", ".pdf"])
|
59
|
+
@file.binmode
|
59
60
|
@file.write(data)
|
60
61
|
@file.close
|
61
62
|
initialize_new_from_file(ensure_uri(@file.path), password)
|
@@ -71,7 +72,8 @@ module Poppler
|
|
71
72
|
end
|
72
73
|
initialize_new_from_stream(stream, length, password)
|
73
74
|
elsif file
|
74
|
-
|
75
|
+
case file
|
76
|
+
when String, Pathname
|
75
77
|
initialize(path: file, password: password)
|
76
78
|
else
|
77
79
|
initialize_new_from_gfile(file, password)
|
@@ -118,6 +120,7 @@ module Poppler
|
|
118
120
|
end
|
119
121
|
|
120
122
|
def ensure_uri(uri)
|
123
|
+
uri = uri.to_path if uri.respond_to?(:to_path)
|
121
124
|
if GLib.path_is_absolute?(uri)
|
122
125
|
GLib.filename_to_uri(uri)
|
123
126
|
elsif /\A[a-zA-Z][a-zA-Z\d\-+.]*:/.match(uri)
|
data/test/test-document.rb
CHANGED
@@ -1,14 +1,43 @@
|
|
1
1
|
class TestDocument < Test::Unit::TestCase
|
2
2
|
sub_test_case("#initialize") do
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
sub_test_case(":data") do
|
4
|
+
def with_default_internal(encoding)
|
5
|
+
original_verbose = $VERBOSE
|
6
|
+
original_encoding = Encoding.default_internal
|
7
|
+
begin
|
8
|
+
$VERBOSE = false
|
9
|
+
Encoding.default_internal = encoding
|
10
|
+
yield
|
11
|
+
ensure
|
12
|
+
Encoding.default_internal = original_encoding
|
13
|
+
$VERBOSE = original_verbose
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_default_internal
|
18
|
+
pdf = StringIO.new("".b)
|
19
|
+
surface = Cairo::PDFSurface.new(pdf, 100, 100)
|
20
|
+
context = Cairo::Context.new(surface)
|
21
|
+
context.show_text("Hello")
|
22
|
+
surface.finish
|
23
|
+
|
24
|
+
document = with_default_internal(Encoding::UTF_8) do
|
25
|
+
Poppler::Document.new(:data => pdf.string)
|
26
|
+
end
|
27
|
+
assert_equal("Hello", document[0].text)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
sub_test_case(":path") do
|
32
|
+
def test_string
|
33
|
+
document = Poppler::Document.new(path: multiple_pages_pdf)
|
34
|
+
assert_equal("The first page", document[0].text)
|
35
|
+
end
|
9
36
|
|
10
|
-
|
11
|
-
|
37
|
+
def test_pathname
|
38
|
+
document = Poppler::Document.new(path: Pathname(multiple_pages_pdf))
|
39
|
+
assert_equal("The first page", document[0].text)
|
40
|
+
end
|
12
41
|
end
|
13
42
|
end
|
14
43
|
|
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.3.
|
4
|
+
version: 3.3.3
|
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: 2019-
|
11
|
+
date: 2019-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cairo-gobject
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.3.
|
19
|
+
version: 3.3.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.3.
|
26
|
+
version: 3.3.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: gio2
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.3.
|
33
|
+
version: 3.3.3
|
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.3.
|
40
|
+
version: 3.3.3
|
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: []
|