combine_pdf 0.0.9 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/combine_pdf.rb +7 -7
- data/lib/combine_pdf/combine_pdf_basic_writer.rb +10 -10
- data/lib/combine_pdf/combine_pdf_decrypt.rb +2 -0
- data/lib/combine_pdf/combine_pdf_filter.rb +2 -0
- data/lib/combine_pdf/combine_pdf_fonts.rb +289 -18
- data/lib/combine_pdf/combine_pdf_operations.rb +7 -2
- data/lib/combine_pdf/combine_pdf_parser.rb +2 -0
- data/lib/combine_pdf/combine_pdf_pdf.rb +8 -4
- metadata +1 -1
@@ -15,10 +15,12 @@ module CombinePDF
|
|
15
15
|
#
|
16
16
|
# this Hash lists the private Hash keys that the CombinePDF library uses to
|
17
17
|
# differentiate between complex PDF objects.
|
18
|
-
PRIVATE_HASH_KEYS = [:indirect_reference_id, :indirect_generation_number, :raw_stream_content, :is_reference_only, :referenced_object, :indirect_without_dictionary]
|
18
|
+
PRIVATE_HASH_KEYS = [:indirect_reference_id, :indirect_generation_number, :raw_stream_content, :is_reference_only, :referenced_object, :indirect_without_dictionary, :linked_fonts]
|
19
19
|
#@private
|
20
20
|
#:nodoc: all
|
21
21
|
|
22
|
+
protected
|
23
|
+
|
22
24
|
|
23
25
|
# This is an internal class. you don't need it.
|
24
26
|
module PDFOperations
|
@@ -106,10 +108,13 @@ module CombinePDF
|
|
106
108
|
resources.each do |k,v|
|
107
109
|
if v.is_a?(Hash)
|
108
110
|
new_dictionary = {}
|
111
|
+
new_name = "Combine" + SecureRandom.urlsafe_base64() + "PDF"
|
112
|
+
i = 1
|
109
113
|
v.each do |old_key, value|
|
110
|
-
new_key = (
|
114
|
+
new_key = (new_name + i.to_s).to_sym
|
111
115
|
names_dictionary[old_key] = new_key
|
112
116
|
new_dictionary[new_key] = value
|
117
|
+
i += 1
|
113
118
|
end
|
114
119
|
resources[k] = new_dictionary
|
115
120
|
end
|
@@ -157,10 +157,13 @@ module CombinePDF
|
|
157
157
|
out << "/Info #{PDFOperations._object_to_pdf @info}"
|
158
158
|
end
|
159
159
|
out << ">>\nstartxref\n#{xref_location.to_s}\n%%EOF"
|
160
|
+
# when finished, remove the numbering system and keep only pointers
|
161
|
+
PDFOperations.remove_old_ids @objects
|
162
|
+
# output the pdf stream
|
160
163
|
out.join("\n").force_encoding(Encoding::ASCII_8BIT)
|
161
164
|
end
|
162
165
|
|
163
|
-
#
|
166
|
+
# Save the PDF to file.
|
164
167
|
#
|
165
168
|
# file_name:: is a string or path object for the output.
|
166
169
|
#
|
@@ -420,7 +423,7 @@ module CombinePDF
|
|
420
423
|
end
|
421
424
|
end
|
422
425
|
# @private
|
423
|
-
# run block of code on evey object (Hash)
|
426
|
+
# run block of code on evey PDF object (PDF objects are class Hash)
|
424
427
|
def each_object(&block)
|
425
428
|
PDFOperations._each_object(@objects, &block)
|
426
429
|
end
|
@@ -484,7 +487,7 @@ module CombinePDF
|
|
484
487
|
# @private
|
485
488
|
def renumber_object_ids(start = nil)
|
486
489
|
warn "Resetting Object Reference IDs"
|
487
|
-
@set_start_id
|
490
|
+
@set_start_id = start || @set_start_id
|
488
491
|
start = @set_start_id
|
489
492
|
history = {}
|
490
493
|
all_indirect_object.each do |obj|
|
@@ -511,7 +514,8 @@ module CombinePDF
|
|
511
514
|
end
|
512
515
|
# @private
|
513
516
|
def all_indirect_object
|
514
|
-
[].tap {|out| @objects.each {|obj| out << obj if (obj.is_a?(Hash) && obj[:is_reference_only].nil?) } }
|
517
|
+
# [].tap {|out| @objects.each {|obj| out << obj if (obj.is_a?(Hash) && obj[:is_reference_only].nil?) } }
|
518
|
+
@objects
|
515
519
|
end
|
516
520
|
# @private
|
517
521
|
def sort_objects_by_id
|