pdf-reader 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -1
- data/lib/pdf-reader.rb +1 -0
- data/lib/pdf/hash.rb +1 -0
- data/lib/pdf/reader.rb +1 -0
- data/lib/pdf/reader/buffer.rb +11 -10
- data/lib/pdf/reader/cid_widths.rb +2 -0
- data/lib/pdf/reader/cmap.rb +1 -0
- data/lib/pdf/reader/encoding.rb +1 -0
- data/lib/pdf/reader/error.rb +1 -0
- data/lib/pdf/reader/filter.rb +1 -0
- data/lib/pdf/reader/filter/ascii85.rb +1 -0
- data/lib/pdf/reader/filter/ascii_hex.rb +2 -0
- data/lib/pdf/reader/filter/depredict.rb +1 -0
- data/lib/pdf/reader/filter/flate.rb +1 -0
- data/lib/pdf/reader/filter/lzw.rb +2 -0
- data/lib/pdf/reader/filter/null.rb +2 -0
- data/lib/pdf/reader/filter/run_length.rb +3 -1
- data/lib/pdf/reader/font.rb +1 -0
- data/lib/pdf/reader/font_descriptor.rb +1 -0
- data/lib/pdf/reader/form_xobject.rb +1 -0
- data/lib/pdf/reader/glyph_hash.rb +1 -0
- data/lib/pdf/reader/lzw.rb +2 -1
- data/lib/pdf/reader/null_security_handler.rb +1 -0
- data/lib/pdf/reader/object_cache.rb +1 -0
- data/lib/pdf/reader/object_hash.rb +1 -0
- data/lib/pdf/reader/object_stream.rb +1 -0
- data/lib/pdf/reader/orientation_detector.rb +1 -0
- data/lib/pdf/reader/page.rb +1 -0
- data/lib/pdf/reader/page_layout.rb +1 -0
- data/lib/pdf/reader/page_state.rb +1 -0
- data/lib/pdf/reader/page_text_receiver.rb +1 -0
- data/lib/pdf/reader/pages_strategy.rb +1 -0
- data/lib/pdf/reader/parser.rb +5 -4
- data/lib/pdf/reader/print_receiver.rb +1 -0
- data/lib/pdf/reader/reference.rb +1 -0
- data/lib/pdf/reader/register_receiver.rb +1 -0
- data/lib/pdf/reader/resource_methods.rb +1 -0
- data/lib/pdf/reader/standard_security_handler.rb +1 -0
- data/lib/pdf/reader/standard_security_handler_v5.rb +2 -0
- data/lib/pdf/reader/stream.rb +1 -0
- data/lib/pdf/reader/synchronized_cache.rb +1 -0
- data/lib/pdf/reader/text_run.rb +1 -0
- data/lib/pdf/reader/token.rb +1 -0
- data/lib/pdf/reader/transformation_matrix.rb +1 -0
- data/lib/pdf/reader/unimplemented_security_handler.rb +1 -0
- data/lib/pdf/reader/width_calculator.rb +1 -0
- data/lib/pdf/reader/width_calculator/built_in.rb +1 -0
- data/lib/pdf/reader/width_calculator/composite.rb +1 -0
- data/lib/pdf/reader/width_calculator/true_type.rb +2 -2
- data/lib/pdf/reader/width_calculator/type_one_or_three.rb +1 -0
- data/lib/pdf/reader/width_calculator/type_zero.rb +1 -0
- data/lib/pdf/reader/xref.rb +4 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfc4ed13692a51d8b78fc181d67fcf8b5e00fb1679dbca36137961f63365edaf
|
4
|
+
data.tar.gz: de5556fabc41642746fd242a2623c92c9424c56da2d845507c49624c312b646b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4074d5dd87f1ad9286f4022ad46a4160f44c6afed2341f9115029770770ae80b248ace9a8d5df0e444046bed662f9aa5a9334822b23222abec9574523d9e7c36
|
7
|
+
data.tar.gz: a69837921f7581d2aeb9226d0791b4b0dd5925a9f83e9cb4cee4dbaf43af33e6a7a570292650a14006ffc9d1759f2ea4ef268381e5aa63fc6da5c1a6d38f46a7
|
data/CHANGELOG
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
v2.
|
1
|
+
v2.2.0 (18th December 2018)
|
2
|
+
- Support additional XRef Stream variants (thanks Stefan Wienert)
|
3
|
+
- Add frozen_strings pragma to reduce object allocations on ruby 2.3+
|
4
|
+
- various bug fixes
|
5
|
+
|
6
|
+
v2.1.0 (15th February 2018)
|
2
7
|
- Support extra encrypted PDF variants (thanks to Gyuchang Jun)
|
3
8
|
- various bug fixes
|
4
9
|
|
data/lib/pdf-reader.rb
CHANGED
data/lib/pdf/hash.rb
CHANGED
data/lib/pdf/reader.rb
CHANGED
data/lib/pdf/reader/buffer.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: ASCII-8BIT
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
################################################################################
|
4
5
|
#
|
@@ -225,7 +226,7 @@ class PDF::Reader
|
|
225
226
|
end
|
226
227
|
|
227
228
|
def prepare_inline_token
|
228
|
-
str = ""
|
229
|
+
str = "".dup
|
229
230
|
|
230
231
|
buffer = []
|
231
232
|
|
@@ -248,7 +249,7 @@ class PDF::Reader
|
|
248
249
|
# we find a closing >
|
249
250
|
#
|
250
251
|
def prepare_hex_token
|
251
|
-
str = ""
|
252
|
+
str = "".dup
|
252
253
|
finished = false
|
253
254
|
|
254
255
|
while !finished
|
@@ -278,7 +279,7 @@ class PDF::Reader
|
|
278
279
|
# problem.
|
279
280
|
#
|
280
281
|
def prepare_literal_token
|
281
|
-
str = ""
|
282
|
+
str = "".dup
|
282
283
|
count = 1
|
283
284
|
|
284
285
|
while count > 0
|
@@ -308,7 +309,7 @@ class PDF::Reader
|
|
308
309
|
# to read up on it.
|
309
310
|
#
|
310
311
|
def prepare_regular_token
|
311
|
-
tok = ""
|
312
|
+
tok = "".dup
|
312
313
|
|
313
314
|
while byte = @io.getbyte
|
314
315
|
case byte
|
@@ -327,7 +328,7 @@ class PDF::Reader
|
|
327
328
|
while TOKEN_WHITESPACE.include?(peek_byte) && tok.size == 0
|
328
329
|
@io.getbyte
|
329
330
|
end
|
330
|
-
tok = ""
|
331
|
+
tok = "".dup
|
331
332
|
break
|
332
333
|
when 0x3C
|
333
334
|
# opening delimiter '<', start of new token
|
@@ -338,7 +339,7 @@ class PDF::Reader
|
|
338
339
|
else
|
339
340
|
@tokens << "<"
|
340
341
|
end
|
341
|
-
tok = ""
|
342
|
+
tok = "".dup
|
342
343
|
break
|
343
344
|
when 0x3E
|
344
345
|
# closing delimiter '>', start of new token
|
@@ -349,26 +350,26 @@ class PDF::Reader
|
|
349
350
|
else
|
350
351
|
@tokens << ">"
|
351
352
|
end
|
352
|
-
tok = ""
|
353
|
+
tok = "".dup
|
353
354
|
break
|
354
355
|
when 0x28, 0x5B, 0x7B
|
355
356
|
# opening delimiter, start of new token
|
356
357
|
@tokens << tok if tok.size > 0
|
357
358
|
@tokens << byte.chr
|
358
|
-
tok = ""
|
359
|
+
tok = "".dup
|
359
360
|
break
|
360
361
|
when 0x29, 0x5D, 0x7D
|
361
362
|
# closing delimiter
|
362
363
|
@tokens << tok if tok.size > 0
|
363
364
|
@tokens << byte.chr
|
364
|
-
tok = ""
|
365
|
+
tok = "".dup
|
365
366
|
break
|
366
367
|
when 0x2F
|
367
368
|
# PDF name, start of new token
|
368
369
|
@tokens << tok if tok.size > 0
|
369
370
|
@tokens << byte.chr
|
370
371
|
@tokens << "" if byte == 0x2F && ([nil, 0x20, 0x0A] + TOKEN_DELIMITER).include?(peek_byte)
|
371
|
-
tok = ""
|
372
|
+
tok = "".dup
|
372
373
|
break
|
373
374
|
else
|
374
375
|
tok << byte
|
data/lib/pdf/reader/cmap.rb
CHANGED
data/lib/pdf/reader/encoding.rb
CHANGED
data/lib/pdf/reader/error.rb
CHANGED
data/lib/pdf/reader/filter.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
#
|
3
5
|
class PDF::Reader # :nodoc:
|
4
6
|
module Filter # :nodoc:
|
@@ -12,7 +14,7 @@ class PDF::Reader # :nodoc:
|
|
12
14
|
# Decode the specified data with the RunLengthDecode compression algorithm
|
13
15
|
def filter(data)
|
14
16
|
pos = 0
|
15
|
-
out = ""
|
17
|
+
out = "".dup
|
16
18
|
|
17
19
|
while pos < data.length
|
18
20
|
length = data.getbyte(pos)
|
data/lib/pdf/reader/font.rb
CHANGED
data/lib/pdf/reader/lzw.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module PDF
|
4
5
|
|
@@ -82,7 +83,7 @@ module PDF
|
|
82
83
|
#
|
83
84
|
def self.decode(data)
|
84
85
|
stream = BitStream.new data.to_s, 9 # size of codes between 9 and 12 bits
|
85
|
-
result =
|
86
|
+
result = "".dup
|
86
87
|
until (code = stream.read) == CODE_EOD
|
87
88
|
if code == CODE_CLEAR_TABLE
|
88
89
|
stream.set_bits_in_chunk(9)
|
data/lib/pdf/reader/page.rb
CHANGED
data/lib/pdf/reader/parser.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
################################################################################
|
4
5
|
#
|
@@ -132,7 +133,7 @@ class PDF::Reader
|
|
132
133
|
# reads a PDF name from the buffer and converts it to a Ruby Symbol
|
133
134
|
def pdf_name
|
134
135
|
tok = @buffer.token
|
135
|
-
tok.gsub
|
136
|
+
tok = tok.dup.gsub(/#([A-Fa-f0-9]{2})/) do |match|
|
136
137
|
match[1, 2].hex.chr
|
137
138
|
end
|
138
139
|
tok.to_sym
|
@@ -154,7 +155,7 @@ class PDF::Reader
|
|
154
155
|
################################################################################
|
155
156
|
# Reads a PDF hex string from the buffer and converts it to a Ruby String
|
156
157
|
def hex_string
|
157
|
-
str = ""
|
158
|
+
str = "".dup
|
158
159
|
|
159
160
|
loop do
|
160
161
|
token = @buffer.token
|
@@ -171,11 +172,11 @@ class PDF::Reader
|
|
171
172
|
# Reads a PDF String from the buffer and converts it to a Ruby String
|
172
173
|
def string
|
173
174
|
str = @buffer.token
|
174
|
-
return "".force_encoding("binary") if str == ")"
|
175
|
+
return "".dup.force_encoding("binary") if str == ")"
|
175
176
|
Error.assert_equal(parse_token, ")")
|
176
177
|
|
177
178
|
str.gsub!(/\\([nrtbf()\\\n]|\d{1,3})?|\r\n?|\n\r/m) do |match|
|
178
|
-
MAPPING[match] || ""
|
179
|
+
MAPPING[match] || "".dup
|
179
180
|
end
|
180
181
|
str.force_encoding("binary")
|
181
182
|
end
|
data/lib/pdf/reader/reference.rb
CHANGED
data/lib/pdf/reader/stream.rb
CHANGED
data/lib/pdf/reader/text_run.rb
CHANGED
data/lib/pdf/reader/token.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
class PDF::Reader
|
4
5
|
module WidthCalculator
|
@@ -17,8 +18,7 @@ class PDF::Reader
|
|
17
18
|
|
18
19
|
def glyph_width(code_point)
|
19
20
|
return 0 if code_point.nil? || code_point < 0
|
20
|
-
|
21
|
-
glyph_width_from_font(code_point) || glyph_width_from_descriptor(code_point)
|
21
|
+
glyph_width_from_font(code_point) || glyph_width_from_descriptor(code_point) || 0
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
data/lib/pdf/reader/xref.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
################################################################################
|
4
5
|
#
|
@@ -203,8 +204,10 @@ class PDF::Reader
|
|
203
204
|
("\x00" + bytes).unpack("N")[0]
|
204
205
|
elsif bytes.size == 4
|
205
206
|
bytes.unpack("N")[0]
|
207
|
+
elsif bytes.size == 8
|
208
|
+
bytes.unpack("Q>")[0]
|
206
209
|
else
|
207
|
-
raise UnsupportedFeatureError, "Unable to unpack xref stream entries
|
210
|
+
raise UnsupportedFeatureError, "Unable to unpack xref stream entries of #{bytes.size} bytes"
|
208
211
|
end
|
209
212
|
end
|
210
213
|
################################################################################
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdf-reader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Healy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -296,7 +296,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
296
296
|
version: '0'
|
297
297
|
requirements: []
|
298
298
|
rubyforge_project:
|
299
|
-
rubygems_version: 2.7.
|
299
|
+
rubygems_version: 2.7.6
|
300
300
|
signing_key:
|
301
301
|
specification_version: 4
|
302
302
|
summary: A library for accessing the content of PDF files
|