combine_pdf 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/combine_pdf/pdf_protected.rb +21 -2
- data/lib/combine_pdf/pdf_public.rb +6 -4
- data/lib/combine_pdf/version.rb +1 -1
- data/test/automated +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb9d21d934a1001210f09268503f3ebc0282aedf
|
4
|
+
data.tar.gz: fc180c13f7789f87e32e06f0307093a485dfe560
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b9d84a43b214ab50f9c9aca37ddb4d1532f2c72d5ec8b441119f0bfb33e2b295267def67acc6787254cd0760f8e44ba358054cd311eb6619a9d5edc125095b6
|
7
|
+
data.tar.gz: 7bed5345b025c0633c2cad6bd7b861d34e962f17f002d840f99a9159ec7d5d3529ebfff10026fe8d082bd47c4eeafaa404fedd828dd9ed5ff526c676d0a7c22c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
**Fix**: Fix NilError when calling `fonts` for a page that has no fonts. Credit to Pavel Slabý (@paulslaby) for PR#110.
|
4
|
+
|
5
|
+
**Fix**: Fix issue #109 where nested differences between objects weren't detected properly, causing loss of data if objects (specifically images that use image masks) would merge. The fix implements a manual equality checks with up to three (3) levels of recursion, protecting against stack overflow that can be caused by the combinations of complex PDF files and Ruby's limitless recursion on `eql?`. Credit to Ryan Scott (@Subtletree) exposing the issue.
|
6
|
+
|
3
7
|
***
|
4
8
|
|
5
9
|
#### Change log v.1.0.1
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Quick rundown:
|
|
18
18
|
|
19
19
|
* When reading PDF Forms, some form data might be lost. I tried fixing this to the best of my ability, but I'm not sure it all works just yet.
|
20
20
|
|
21
|
-
* When combining PDF Forms, form data might be unified. I couldn't fix this because this is how PDF forms work (filling a
|
21
|
+
* When combining PDF Forms, form data might be unified. I couldn't fix this because this is how PDF forms work (filling a field fills in the data in any field with the same name), but frankly, I kinda liked the issue... it's almost a feature.
|
22
22
|
|
23
23
|
* When unifying the same TOC data more then once, one of the references will be unified with the other (meaning that if the pages look the same, both references will link to the same page instead of linking to two different pages). You can fix this by adding content to the pages before merging the PDF files (i.e. add empty text boxes to all the pages).
|
24
24
|
|
@@ -33,8 +33,12 @@ module CombinePDF
|
|
33
33
|
if obj.is_a?(Hash)
|
34
34
|
referenced = obj[:referenced_object]
|
35
35
|
if referenced && referenced.any?
|
36
|
-
|
37
|
-
tmp
|
36
|
+
tmp = resolved[referenced.object_id]
|
37
|
+
if !tmp && referenced[:raw_stream_content]
|
38
|
+
tmp = existing[referenced[:raw_stream_content]]
|
39
|
+
# Avoid endless recursion by limiting it to a number of layers (default == 2)
|
40
|
+
tmp = nil unless equal_layers(tmp, referenced)
|
41
|
+
end
|
38
42
|
if tmp
|
39
43
|
obj[:referenced_object] = tmp
|
40
44
|
else
|
@@ -339,6 +343,21 @@ module CombinePDF
|
|
339
343
|
|
340
344
|
private
|
341
345
|
|
346
|
+
def equal_layers obj1, obj2, layer = 3
|
347
|
+
return true if(layer == 0)
|
348
|
+
if obj1.is_a? Hash
|
349
|
+
return false unless obj2.is_a? Hash
|
350
|
+
keys = obj1.keys;
|
351
|
+
return false if (keys - obj2.keys).any?
|
352
|
+
keys.each {|k| return false unless equal_layers( obj1[k], obj2[k], layer-1) }
|
353
|
+
elsif obj1.is_a? Array
|
354
|
+
return false unless obj2.is_a? Array
|
355
|
+
(obj1-obj2).any?
|
356
|
+
else
|
357
|
+
obj1 == obj2
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
342
361
|
def renaming_dictionary(object = nil, dictionary = {})
|
343
362
|
object ||= @names
|
344
363
|
case object
|
@@ -253,10 +253,12 @@ module CombinePDF
|
|
253
253
|
def fonts(limit_to_type0 = false)
|
254
254
|
fonts_array = []
|
255
255
|
pages.each do |p|
|
256
|
-
p[:Resources][:Font]
|
257
|
-
|
258
|
-
|
259
|
-
|
256
|
+
if p[:Resources][:Font]
|
257
|
+
p[:Resources][:Font].values.each do |f|
|
258
|
+
f = f[:referenced_object] if f[:referenced_object]
|
259
|
+
if (limit_to_type0 || f[:Subtype] = :Type0) && f[:Type] == :Font && !fonts_array.include?(f)
|
260
|
+
fonts_array << f
|
261
|
+
end
|
260
262
|
end
|
261
263
|
end
|
262
264
|
end
|
data/lib/combine_pdf/version.rb
CHANGED
data/test/automated
CHANGED
@@ -33,6 +33,9 @@ pdf.save '03_01_nil_value_conflict.pdf'
|
|
33
33
|
pdf = CombinePDF.load './Ruby/test pdfs/space_after_streram_keyword.pdf'
|
34
34
|
pdf.save '03_02_extra_space_after_stream_keyword.pdf'
|
35
35
|
|
36
|
+
pdf = CombinePDF.load './Ruby/test pdfs/nested_difference.pdf'
|
37
|
+
pdf.save '03_03_nested_difference.pdf'
|
38
|
+
|
36
39
|
pdf = CombinePDF.load './Ruby/test pdfs/names_go_haywire_0.pdf'
|
37
40
|
pdf << CombinePDF.load('./Ruby/test pdfs/names_go_haywire_1.pdf')
|
38
41
|
pdf.save '04_check_view_and_names_reference.pdf'
|
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: 1.0.
|
4
|
+
version: 1.0.2
|
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-
|
11
|
+
date: 2017-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-rc4
|