pdf-reader 0.8.5 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ v0.8.6 (27th August 2010)
2
+ - new method: hash#page_references
3
+ - returns references to all page objects, gives rapid access to objects
4
+ for a given page
5
+
1
6
  v0.8.5 (11th April 2010)
2
7
  - fix a regression introduced in 0.8.4.
3
8
  - Parameters passed to resource_font callback were inadvertently changed
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'rake/testtask'
6
6
  require "rake/gempackagetask"
7
7
  require 'spec/rake/spectask'
8
8
 
9
- PKG_VERSION = "0.8.5"
9
+ PKG_VERSION = "0.8.6"
10
10
  PKG_NAME = "pdf-reader"
11
11
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
12
12
 
@@ -198,8 +198,29 @@ module PDF
198
198
  ret
199
199
  end
200
200
 
201
+ # returns an array of PDF::Reader::References. Each reference in the
202
+ # array points a Page object, one for each page in the PDF. The first
203
+ # reference is page 1, second reference is page 2, etc.
204
+ #
205
+ def page_references
206
+ root = fetch(trailer[:Root])
207
+ @page_references ||= get_page_objects(root[:Pages]).flatten
208
+ end
209
+
201
210
  private
202
211
 
212
+ # returns a nested array of object references for all pages in this object store.
213
+ #
214
+ def get_page_objects(ref)
215
+ obj = fetch(ref)
216
+
217
+ if obj[:Type] == :Page
218
+ ref
219
+ elsif obj[:Type] == :Pages
220
+ obj[:Kids].map { |kid| get_page_objects(kid) }
221
+ end
222
+ end
223
+
203
224
  def read_version(io)
204
225
  io.seek(0)
205
226
  m, version = *io.read(10).match(/PDF-(\d.\d)/)
@@ -27,7 +27,8 @@ require 'enumerator'
27
27
 
28
28
  class PDF::Reader
29
29
  class Encoding
30
-
30
+ CONTROL_CHARS = [0,1,2,3,4,5,6,7,8,11,12,14,15,16,17,18,19,20,21,22,23,
31
+ 24,25,26,27,28,29,30,31]
31
32
  UNKNOWN_CHAR = 0x25AF # ▯
32
33
 
33
34
  attr_reader :differences, :unpack
@@ -121,6 +122,8 @@ class PDF::Reader
121
122
  PDF::Reader::Encoding::UNKNOWN_CHAR
122
123
  elsif mapping[num]
123
124
  mapping[num]
125
+ elsif PDF::Reader::Encoding::CONTROL_CHARS.include?(num)
126
+ PDF::Reader::Encoding::UNKNOWN_CHAR
124
127
  else
125
128
  num
126
129
  end
@@ -191,7 +191,7 @@ class PDF::Reader
191
191
 
192
192
  params.each do |p|
193
193
  case p
194
- when Float
194
+ when Float, Fixnum
195
195
  @state.last[:tj_adjustment] = p
196
196
  else
197
197
  show_text(p)
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdf-reader
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 51
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 8
8
- - 5
9
- version: 0.8.5
9
+ - 6
10
+ version: 0.8.6
10
11
  platform: ruby
11
12
  authors:
12
13
  - James Healy
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-04-11 00:00:00 +10:00
18
+ date: 2010-08-27 00:00:00 +10:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: Ascii85
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 25
27
30
  segments:
28
31
  - 0
29
32
  - 9
@@ -81,6 +84,9 @@ files:
81
84
  - lib/pdf/reader.rb
82
85
  - lib/pdf-reader.rb
83
86
  - Rakefile
87
+ - bin/pdf_object
88
+ - bin/pdf_text
89
+ - bin/pdf_list_callbacks
84
90
  - README.rdoc
85
91
  - TODO
86
92
  - CHANGELOG
@@ -99,23 +105,27 @@ rdoc_options:
99
105
  require_paths:
100
106
  - lib
101
107
  required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
102
109
  requirements:
103
110
  - - ">="
104
111
  - !ruby/object:Gem::Version
112
+ hash: 3
105
113
  segments:
106
114
  - 0
107
115
  version: "0"
108
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
+ none: false
109
118
  requirements:
110
119
  - - ">="
111
120
  - !ruby/object:Gem::Version
121
+ hash: 3
112
122
  segments:
113
123
  - 0
114
124
  version: "0"
115
125
  requirements: []
116
126
 
117
127
  rubyforge_project: pdf-reader
118
- rubygems_version: 1.3.6
128
+ rubygems_version: 1.3.7
119
129
  signing_key:
120
130
  specification_version: 3
121
131
  summary: A library for accessing the content of PDF files