pdf-core 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 856ce23b0a77d7b4687cd99c414882f097415a95
4
- data.tar.gz: f7ce63a444efce6fe3d2eed4d07259e995eff222
3
+ metadata.gz: c82f9b6d4628406f50c582c41acd34a87877665a
4
+ data.tar.gz: dfc8e85e060c5c4fbfca3f08172237fc76fe6fab
5
5
  SHA512:
6
- metadata.gz: 307093911891cb9419417101a762987e88f0b1e7df402d87924f03bb61bbc7addd76654699a271d0df9bd5fc54d980476cf998b92232737dde823a225d51976a
7
- data.tar.gz: 1d360e308f28ca08263ffb09356a7210ff3929feec74c16e6d1f82ce4c308a4217a2fe2cba151e515a8b97491e06735bce3d794c469328cb2029987a9d3869ac
6
+ metadata.gz: be3d2a5a9f2ae4e13ab6968ebd077bca6c3cac533d6b16572df103e3977d9340197f7c6ad274e3b95c8653d72e6b68f343d56395568b9bb2b66a90e768a8e072
7
+ data.tar.gz: 829e5ce883da56c582dcdf185388087d98247d13b05952258577dbd472cc25e9cf1b2f0502f70a73e2628d282cecafdd4bde1004674fd24804b759532cddf4c0
@@ -18,14 +18,13 @@ module PDF
18
18
  @compress = options.fetch(:compress, false)
19
19
  @encrypt = options.fetch(:encrypt, false)
20
20
  @encryption_key = options[:encryption_key]
21
- @optimize_objects = options.fetch(:optimize_objects, false)
22
21
  @skip_encoding = options.fetch(:skip_encoding, false)
23
22
  @before_render_callbacks = []
24
23
  @on_page_create_callback = nil
25
24
  end
26
25
 
27
26
  attr_accessor :store, :version, :pages, :page, :trailer, :compress,
28
- :encrypt, :encryption_key, :optimize_objects, :skip_encoding,
27
+ :encrypt, :encryption_key, :skip_encoding,
29
28
  :before_render_callbacks, :on_page_create_callback
30
29
 
31
30
  def populate_pages_from_store(document)
@@ -66,7 +65,6 @@ module PDF
66
65
  end
67
66
 
68
67
  def render_body(output)
69
- store.compact if optimize_objects
70
68
  store.each do |ref|
71
69
  ref.offset = output.size
72
70
  output << (@encrypt ? ref.encrypted_object(@encryption_key) :
@@ -13,8 +13,6 @@ module PDF
13
13
 
14
14
  attr_reader :min_version
15
15
 
16
- BASE_OBJECTS = %w[info pages root]
17
-
18
16
  def initialize(opts = {})
19
17
  @objects = {}
20
18
  @identifiers = []
@@ -84,35 +82,6 @@ module PDF
84
82
  end
85
83
  alias_method :length, :size
86
84
 
87
- def compact
88
- # Clear live markers
89
- each { |o| o.live = false }
90
-
91
- # Recursively mark reachable objects live, starting from the roots
92
- # (the only objects referenced in the trailer)
93
- root.mark_live
94
- info.mark_live
95
-
96
- # Renumber live objects to eliminate gaps (shrink the xref table)
97
- if @objects.any?{ |_, o| !o.live }
98
- new_id = 1
99
- new_objects = {}
100
- new_identifiers = []
101
-
102
- each do |obj|
103
- if obj.live
104
- obj.identifier = new_id
105
- new_objects[new_id] = obj
106
- new_identifiers << new_id
107
- new_id += 1
108
- end
109
- end
110
-
111
- @objects = new_objects
112
- @identifiers = new_identifiers
113
- end
114
- end
115
-
116
85
  # returns the object ID for a particular page in the document. Pages
117
86
  # are indexed starting at 1 (not 0!).
118
87
  #
@@ -11,7 +11,7 @@ module PDF
11
11
  module Core
12
12
  class Reference #:nodoc:
13
13
 
14
- attr_accessor :gen, :data, :offset, :stream, :live, :identifier
14
+ attr_accessor :gen, :data, :offset, :stream, :identifier
15
15
 
16
16
  def initialize(id, data)
17
17
  @identifier = id
@@ -67,31 +67,6 @@ module PDF
67
67
  @data = other_ref.data
68
68
  @stream = other_ref.stream
69
69
  end
70
-
71
- # Marks this and all referenced objects live, recursively.
72
- def mark_live
73
- return if defined?(@live) && @live
74
- @live = true
75
- referenced_objects.each { |o| o.mark_live }
76
- end
77
-
78
- private
79
-
80
- # All objects referenced by this one. Used for GC.
81
- def referenced_objects(obj=@data)
82
- case obj
83
- when self.class
84
- []
85
- when ::Hash
86
- obj.values.map{|v| [v] + referenced_objects(v) }
87
- when Array
88
- obj.map{|v| [v] + referenced_objects(v) }
89
- when PDF::Core::OutlineRoot, PDF::Core::OutlineItem
90
- referenced_objects(obj.to_hash)
91
- else []
92
- end.flatten.grep(self.class)
93
- end
94
-
95
70
  end
96
71
 
97
72
  module_function
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdf-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory Brown
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-02-16 00:00:00.000000000 Z
15
+ date: 2014-02-20 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: pdf-reader
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  version: 1.3.6
134
134
  requirements: []
135
135
  rubyforge_project: prawn
136
- rubygems_version: 2.2.1
136
+ rubygems_version: 2.2.0
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: PDF::Core is used by Prawn to render PDF documents