combine_pdf 0.2.33 → 0.2.34

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: fc3b58971778d716ab9693eb7198523eff597e6a
4
- data.tar.gz: 33bfb23329e6f0ba2917bd1eb5c120c401fe91a6
3
+ metadata.gz: 978b43d9e325d4e5eba06ceebb396565c0413bc1
4
+ data.tar.gz: b3f85e2ff8d5fa57643f4aa516c620a0b9dadafc
5
5
  SHA512:
6
- metadata.gz: f314e20def37c16e4cdf35375cf214a5785ca3ab5b8a3ca07a8096f12d7601f1d0e5a4319ca7b4c0649dc488c668361a92058d4866aab54170d12b9ba4b8cd2b
7
- data.tar.gz: b688dc96f6de9d79028170efdb26341bd45d2a947389b250b3795513946756267b00b4bcbbe0e41fa002881f0605f228a5d5048cf928c2655c7dca16d051ce65
6
+ metadata.gz: f0b111a144fe3b0c8ea54bb7a138d1d97e3d0f59af48e296e6286ea40dfb575c7f1573061e526f278c84765c75c6d56c1ee8d96dccb7c93c2972e296c568fd24
7
+ data.tar.gz: 0bfbf5060a5f5210fd2349acf898b2feced9e2610cf9c734cb9a20c5c969dfbd361f81ac769e48e4274b23c7217e4476d651daf608ce8a25c139288deecbab03
@@ -120,9 +120,6 @@ module CombinePDF
120
120
  end
121
121
  end
122
122
 
123
- # Strings were unified, we can let them go..
124
- @strings_dictionary.clear
125
-
126
123
  # serialize_objects_and_references.catalog_pages
127
124
 
128
125
  # Benchmark.bm do |bm|
@@ -135,6 +132,9 @@ module CombinePDF
135
132
 
136
133
  catalog_pages
137
134
 
135
+ # Strings were unified, we can let them go..
136
+ @strings_dictionary.clear
137
+
138
138
  # collect any missing objects from the forms_data
139
139
  unless @forms_object.nil? || @forms_object.empty?
140
140
  @forms_object[:related_objects] = (@parsed.select { |o| o[:FT] }).map! { |o| { is_reference_only: true, referenced_object: o } }
@@ -222,6 +222,8 @@ module CombinePDF
222
222
  out << { indirect_without_dictionary: out.pop, indirect_generation_number: out.pop, indirect_reference_id: out.pop }
223
223
  end
224
224
  fresh = true
225
+ # fix wkhtmltopdf use of PDF 1.1 Dest using symbols instead of strings
226
+ out.last[:Dest] = unify_string(out.last[:Dest].to_s) if out.last[:Dest] && out.last[:Dest].is_a?(Symbol)
225
227
  # puts "!!!!!!!!! Error with :indirect_reference_id\n\nObject #{out.last} :indirect_reference_id = #{out.last[:indirect_reference_id]}" unless out.last[:indirect_reference_id].is_a?(Integer)
226
228
  ##########################################
227
229
  ## parse a Hex String
@@ -394,6 +396,8 @@ module CombinePDF
394
396
  else
395
397
  out << { indirect_without_dictionary: out.pop, indirect_generation_number: out.pop, indirect_reference_id: out.pop }
396
398
  end
399
+ # fix wkhtmltopdf use of PDF 1.1 Dest using symbols instead of strings
400
+ out.last[:Dest] = unify_string(out.last[:Dest].to_s) if out.last[:Dest] && out.last[:Dest].is_a?(Symbol)
397
401
  warn "'endobj' keyword was missing for Object ID: #{out.last[:indirect_reference_id]}, trying to auto-fix issue, but might fail."
398
402
 
399
403
  out << keep.pop
@@ -489,6 +493,11 @@ module CombinePDF
489
493
  @forms_object.update((catalogs[:AcroForm][:referenced_object] || catalogs[:AcroForm]), &self.class.method(:hash_update_proc_for_new)) if catalogs[:AcroForm]
490
494
  @names_object.update((catalogs[:Names][:referenced_object] || catalogs[:Names]), &self.class.method(:hash_update_proc_for_new)) if catalogs[:Names]
491
495
  @outlines_object.update((catalogs[:Outlines][:referenced_object] || catalogs[:Outlines]), &self.class.method(:hash_update_proc_for_new)) if catalogs[:Outlines]
496
+ if catalogs[:Dests] # convert PDF 1.1 Dests to PDF 1.2+ Dests
497
+ dests_arry = (@names_object[:Dests] ||= {})
498
+ dests_arry = ((dests_arry[:referenced_object] || dests_arry)[:Names] ||= [])
499
+ ((catalogs[:Dests][:referenced_object] || catalogs[:Dests])[:referenced_object] || (catalogs[:Dests][:referenced_object] || catalogs[:Dests])).each {|k,v| next if CombinePDF::PDF::PRIVATE_HASH_KEYS.include?(k); dests_arry << unify_string(k.to_s); dests_arry << v; }
500
+ end
492
501
  catalog_pages(catalogs[:Pages], inheritance_hash.dup) unless catalogs[:Pages].nil?
493
502
  end
494
503
  end
@@ -191,6 +191,7 @@ module CombinePDF
191
191
  if pos[0].is_a? String
192
192
  (pos.length / 2).times do |i|
193
193
  dic << (pos[i * 2].clear << base.next!)
194
+ pos[(i * 2) + 1][0] = {is_reference_only: true, referenced_object: pages[pos[(i * 2) + 1][0]]} if(pos[(i * 2) + 1].is_a?(Array) && pos[(i * 2) + 1][0].is_a?(Integer))
194
195
  dic << (pos[(i * 2) + 1].is_a?(Array) ? { is_reference_only: true, referenced_object: { indirect_without_dictionary: pos[(i * 2) + 1] } } : pos[(i * 2) + 1])
195
196
  # dic << pos[(i * 2) + 1]
196
197
  end
@@ -100,6 +100,8 @@ module CombinePDF
100
100
  @names = parser.names_object || {}
101
101
  @forms_data = parser.forms_object || {}
102
102
  @outlines = parser.outlines_object || {}
103
+ # rebuild the catalo, to fix wkhtmltopdf's use of static page numbers
104
+ rebuild_catalog
103
105
 
104
106
  # general globals
105
107
  @set_start_id = 1
@@ -1,3 +1,3 @@
1
1
  module CombinePDF
2
- VERSION = '0.2.33'.freeze
2
+ VERSION = '0.2.34'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: combine_pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.33
4
+ version: 0.2.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boaz Segev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-02 00:00:00.000000000 Z
11
+ date: 2017-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-rc4