combine_pdf 0.1.3 → 0.1.4

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: b66122d4b265048987ad995f6d20e832d70e1e67
4
- data.tar.gz: 06d4c4aa18793189a4b166eb535a089d71615768
3
+ metadata.gz: b732c13238534158bddb82ff89b5c0d14fdccdd2
4
+ data.tar.gz: 45ef6b52039c289ba1f71cce445c245d42c01bc1
5
5
  SHA512:
6
- metadata.gz: ae6a99d83dcc63459094fc9c438520aaa409591aef52f4e491b03228cb9636b40c53de8c6b08a656a22ad2a54aa4d4e9e54a83ede7db26cefcb471bade392551
7
- data.tar.gz: e4214c1f95fac5fee4c4617ad55d4fc1f704f52261ea0600b59cc89c083d473a89cff793ff1cbb6b7fd8d509ceec7b27f2a4bade651d7a29105e180b4bdaa7d5
6
+ metadata.gz: 0ac937aea55ebc4f5be4cb9a2a7c9fadd45cc4e3dd01ff86749486541e1056787e89795fd514f031036e4156d4c7807101e82d0b88c64d00b813966211f97b15
7
+ data.tar.gz: 1b89918e8c4e79e005dcd1961f8f89fcb89565ed95b57e429a7fb82a1cbabe009665d3396a54db0c6e38ced2b9dc72c720157348404b4a791d374bfae5669353
@@ -137,7 +137,10 @@ module CombinePDF
137
137
  if @need_to_rebuild_resources
138
138
  rebuild_resources
139
139
  end
140
- catalog = rebuild_catalog_and_objects #rebuild_catalog
140
+ #rebuild_catalog
141
+ catalog = rebuild_catalog_and_objects
142
+ # add ID and generation numbers to objects
143
+ renumber_object_ids
141
144
 
142
145
  warn "Formatting PDF output"
143
146
 
@@ -340,6 +343,22 @@ module CombinePDF
340
343
  pages_array
341
344
  end
342
345
 
346
+ # removes a PDF page from the file and the catalog
347
+ #
348
+ # returns the removed page.
349
+ #
350
+ # returns nil if failed or if out of bounds.
351
+ #
352
+ # page_index:: the page's index in the zero (0) based page array. negative numbers represent a count backwards (-1 being the end of the page array and 0 being the begining).
353
+ def remove(page_index)
354
+ catalog = rebuild_catalog
355
+ pages_array = catalog[:Pages][:referenced_object][:Kids]
356
+ removed_page = pages_array.delete_at page_index
357
+ catalog[:Pages][:referenced_object][:Count] = pages_array.length
358
+ removed_page
359
+ end
360
+
361
+
343
362
  # add page numbers to the PDF
344
363
  #
345
364
  # For unicode text, a unicode font(s) must first be registered. the registered font(s) must supply the
@@ -545,7 +564,6 @@ module CombinePDF
545
564
  end
546
565
  # @private
547
566
  def renumber_object_ids(start = nil)
548
- warn "Resetting Object Reference IDs"
549
567
  @set_start_id = start || @set_start_id
550
568
  start = @set_start_id
551
569
  history = {}
@@ -553,7 +571,6 @@ module CombinePDF
553
571
  obj[:indirect_reference_id] = start
554
572
  start += 1
555
573
  end
556
- warn "Finished serializing IDs"
557
574
  end
558
575
 
559
576
  # @private
@@ -588,8 +605,6 @@ module CombinePDF
588
605
 
589
606
  # @private
590
607
  def rebuild_catalog(*with_pages)
591
- warn "Re-Building Catalog"
592
-
593
608
  # # build page list v.1 Slow but WORKS
594
609
  # # Benchmark testing value: 26.708394
595
610
  # old_catalogs = @objects.select {|obj| obj.is_a?(Hash) && obj[:Type] == :Catalog}
@@ -635,7 +650,6 @@ module CombinePDF
635
650
  @objects = []
636
651
  @objects << catalog
637
652
  add_referenced catalog
638
- renumber_object_ids
639
653
  catalog
640
654
  end
641
655
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: combine_pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boaz Segev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-16 00:00:00.000000000 Z
12
+ date: 2014-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-rc4