combine_pdf 0.2.21 → 0.2.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +54 -0
- data/LICENSE.txt +2 -1
- data/README.md +30 -0
- data/lib/combine_pdf.rb +12 -18
- data/lib/combine_pdf/api.rb +156 -153
- data/lib/combine_pdf/basic_writer.rb +41 -53
- data/lib/combine_pdf/decrypt.rb +235 -228
- data/lib/combine_pdf/filter.rb +79 -90
- data/lib/combine_pdf/fonts.rb +451 -459
- data/lib/combine_pdf/page_methods.rb +864 -877
- data/lib/combine_pdf/parser.rb +649 -578
- data/lib/combine_pdf/pdf_protected.rb +377 -218
- data/lib/combine_pdf/pdf_public.rb +490 -462
- data/lib/combine_pdf/renderer.rb +157 -163
- data/lib/combine_pdf/version.rb +1 -1
- data/test/automated +79 -0
- data/test/console +4 -4
- data/test/named_dest +84 -0
- metadata +6 -2
data/lib/combine_pdf/renderer.rb
CHANGED
@@ -1,167 +1,161 @@
|
|
1
1
|
module CombinePDF
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
return object.dup
|
160
|
-
else
|
161
|
-
return object # objects that aren't Strings, Arrays or Hashes (such as Symbols and Fixnums) won't be edited inplace.
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
2
|
+
################################################################
|
3
|
+
## These are common functions, used within the different classes
|
4
|
+
## These functions aren't open to the public.
|
5
|
+
################################################################
|
6
|
+
|
7
|
+
# This is an internal module used to render ruby objects into pdf objects.
|
8
|
+
module Renderer
|
9
|
+
# @!visibility private
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
# Formats an object into PDF format. This is used my the PDF object to format the PDF file and it is used in the secure injection which is still being developed.
|
14
|
+
def object_to_pdf(object)
|
15
|
+
if object.nil?
|
16
|
+
return 'null'
|
17
|
+
elsif object.is_a?(String)
|
18
|
+
return format_string_to_pdf object
|
19
|
+
elsif object.is_a?(Symbol)
|
20
|
+
return format_name_to_pdf object
|
21
|
+
elsif object.is_a?(Array)
|
22
|
+
return format_array_to_pdf object
|
23
|
+
elsif object.is_a?(Fixnum) || object.is_a?(Float) || object.is_a?(TrueClass) || object.is_a?(FalseClass)
|
24
|
+
return object.to_s + ' '
|
25
|
+
elsif object.is_a?(Hash)
|
26
|
+
return format_hash_to_pdf object
|
27
|
+
else
|
28
|
+
return ''
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
STRING_REPLACEMENT_HASH = { "\x0A" => '\\n',
|
33
|
+
"\x0D" => '\\r',
|
34
|
+
"\x09" => '\\t',
|
35
|
+
"\x08" => '\\b',
|
36
|
+
"\xFF" => '\\f',
|
37
|
+
"\x28" => '\\(',
|
38
|
+
"\x29" => '\\)',
|
39
|
+
"\x5C" => '\\\\' }.dup
|
40
|
+
32.times { |i| STRING_REPLACEMENT_HASH[i.chr] ||= "\\#{i}" }
|
41
|
+
(256 - 128).times { |i| STRING_REPLACEMENT_HASH[(i + 127).chr] ||= "\\#{i + 127}" }
|
42
|
+
|
43
|
+
def format_string_to_pdf(object)
|
44
|
+
# object.force_encoding(Encoding::ASCII_8BIT)
|
45
|
+
if !object.match(/[^D\:\d\+\-\Z\']/) # if format is set to Literal and string isn't a date
|
46
|
+
('(' + ([].tap { |out| object.bytes.to_a.each { |byte| STRING_REPLACEMENT_HASH[byte.chr] ? (STRING_REPLACEMENT_HASH[byte.chr].bytes.each { |b| out << b }) : out << byte } }).pack('C*') + ')').force_encoding(Encoding::ASCII_8BIT)
|
47
|
+
else
|
48
|
+
# A hexadecimal string shall be written as a sequence of hexadecimal digits (0–9 and either A–F or a–f)
|
49
|
+
# encoded as ASCII characters and enclosed within angle brackets (using LESS-THAN SIGN (3Ch) and GREATER- THAN SIGN (3Eh)).
|
50
|
+
"<#{object.unpack('H*')[0]}>".force_encoding(Encoding::ASCII_8BIT)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def format_name_to_pdf(object)
|
55
|
+
# a name object is an atomic symbol uniquely defined by a sequence of ANY characters (8-bit values) except null (character code 0).
|
56
|
+
# print name as a simple string. all characters between ~ and ! (except #) can be raw
|
57
|
+
# the rest will have a number sign and their HEX equivalant
|
58
|
+
# from the standard:
|
59
|
+
# When writing a name in a PDF file, a SOLIDUS (2Fh) (/) shall be used to introduce a name. The SOLIDUS is not part of the name but is a prefix indicating that what follows is a sequence of characters representing the name in the PDF file and shall follow these rules:
|
60
|
+
# a) A NUMBER SIGN (23h) (#) in a name shall be written by using its 2-digit hexadecimal code (23), preceded by the NUMBER SIGN.
|
61
|
+
# b) Any character in a name that is a regular character (other than NUMBER SIGN) shall be written as itself or by using its 2-digit hexadecimal code, preceded by the NUMBER SIGN.
|
62
|
+
# c) Any character that is not a regular character shall be written using its 2-digit hexadecimal code, preceded by the NUMBER SIGN only.
|
63
|
+
# [0x00, 0x09, 0x0a, 0x0c, 0x0d, 0x20, 0x28, 0x29, 0x3c, 0x3e, 0x5b, 0x5d, 0x7b, 0x7d, 0x2f, 0x25]
|
64
|
+
out = object.to_s.bytes.to_a.map do |b|
|
65
|
+
case b
|
66
|
+
when 0..15
|
67
|
+
'#0' + b.to_s(16)
|
68
|
+
when 15..32, 35, 37, 40, 41, 47, 60, 62, 91, 93, 123, 125, 127..256
|
69
|
+
'#' + b.to_s(16)
|
70
|
+
else
|
71
|
+
b.chr
|
72
|
+
end
|
73
|
+
end
|
74
|
+
'/' + out.join
|
75
|
+
end
|
76
|
+
|
77
|
+
def format_array_to_pdf(object)
|
78
|
+
# An array shall be written as a sequence of objects enclosed in SQUARE BRACKETS (using LEFT SQUARE BRACKET (5Bh) and RIGHT SQUARE BRACKET (5Dh)).
|
79
|
+
# EXAMPLE [549 3.14 false (Ralph) /SomeName]
|
80
|
+
('[' + (object.collect { |item| object_to_pdf(item) }).join(' ') + ']').force_encoding(Encoding::ASCII_8BIT)
|
81
|
+
end
|
82
|
+
|
83
|
+
def format_hash_to_pdf(object)
|
84
|
+
# if the object is only a reference:
|
85
|
+
# special conditions apply, and there is only the setting of the reference (if needed) and output
|
86
|
+
if object[:is_reference_only]
|
87
|
+
#
|
88
|
+
if object[:referenced_object] && object[:referenced_object].is_a?(Hash)
|
89
|
+
object[:indirect_reference_id] = object[:referenced_object][:indirect_reference_id]
|
90
|
+
object[:indirect_generation_number] = object[:referenced_object][:indirect_generation_number]
|
91
|
+
end
|
92
|
+
object[:indirect_reference_id] ||= 0
|
93
|
+
object[:indirect_generation_number] ||= 0
|
94
|
+
return "#{object[:indirect_reference_id]} #{object[:indirect_generation_number]} R".force_encoding(Encoding::ASCII_8BIT)
|
95
|
+
end
|
96
|
+
|
97
|
+
# if the object is indirect...
|
98
|
+
out = []
|
99
|
+
if object[:indirect_reference_id]
|
100
|
+
object[:indirect_reference_id] ||= 0
|
101
|
+
object[:indirect_generation_number] ||= 0
|
102
|
+
out << "#{object[:indirect_reference_id]} #{object[:indirect_generation_number]} obj\n".force_encoding(Encoding::ASCII_8BIT)
|
103
|
+
if object[:indirect_without_dictionary]
|
104
|
+
out << object_to_pdf(object[:indirect_without_dictionary])
|
105
|
+
out << "\nendobj\n"
|
106
|
+
return out.join.force_encoding(Encoding::ASCII_8BIT)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
# remove extra page references.
|
110
|
+
object[:Contents].delete(is_reference_only: true, referenced_object: { indirect_reference_id: 0, raw_stream_content: '' }) if object[:Type] == :Page
|
111
|
+
# correct stream length, if the object is a stream.
|
112
|
+
object[:Length] = object[:raw_stream_content].bytesize if object[:raw_stream_content]
|
113
|
+
|
114
|
+
# if the object is not a simple object, it is a dictionary
|
115
|
+
# A dictionary shall be written as a sequence of key-value pairs enclosed in double angle brackets (<<...>>)
|
116
|
+
# (using LESS-THAN SIGNs (3Ch) and GREATER-THAN SIGNs (3Eh)).
|
117
|
+
out << "<<\n".force_encoding(Encoding::ASCII_8BIT)
|
118
|
+
object.each do |key, value|
|
119
|
+
out << "#{object_to_pdf key} #{object_to_pdf value}\n".force_encoding(Encoding::ASCII_8BIT) unless PDF::PRIVATE_HASH_KEYS.include? key
|
120
|
+
end
|
121
|
+
object.delete :Length
|
122
|
+
out << '>>'.force_encoding(Encoding::ASCII_8BIT)
|
123
|
+
out << "\nstream\n#{object[:raw_stream_content]}\nendstream".force_encoding(Encoding::ASCII_8BIT) if object[:raw_stream_content]
|
124
|
+
out << "\nendobj\n" if object[:indirect_reference_id]
|
125
|
+
out.join.force_encoding(Encoding::ASCII_8BIT)
|
126
|
+
end
|
127
|
+
|
128
|
+
def actual_object(obj)
|
129
|
+
obj.is_a?(Hash) ? (obj[:referenced_object] || obj) : obj
|
130
|
+
end
|
131
|
+
|
132
|
+
def actual_value(obj)
|
133
|
+
return obj unless obj.is_a?(Hash)
|
134
|
+
obj = obj[:referenced_object] || obj
|
135
|
+
obj[:indirect_without_dictionary] || obj
|
136
|
+
end
|
137
|
+
|
138
|
+
# Ruby normally assigns pointes.
|
139
|
+
# noramlly:
|
140
|
+
# a = [1,2,3] # => [1,2,3]
|
141
|
+
# b = a # => [1,2,3]
|
142
|
+
# a << 4 # => [1,2,3,4]
|
143
|
+
# b # => [1,2,3,4]
|
144
|
+
# This method makes sure that the memory is copied instead of a pointer assigned.
|
145
|
+
# this works using recursion, so that arrays and hashes within arrays and hashes are also copied and not pointed to.
|
146
|
+
# One needs to be careful of infinit loops using this function.
|
147
|
+
def create_deep_copy(object)
|
148
|
+
if object.is_a?(Array)
|
149
|
+
return object.map { |e| create_deep_copy e }
|
150
|
+
elsif object.is_a?(Hash)
|
151
|
+
return {}.tap { |out| object.each { |k, v| out[create_deep_copy(k)] = create_deep_copy(v) unless k == :Parent } }
|
152
|
+
elsif object.is_a?(String)
|
153
|
+
return object.dup
|
154
|
+
else
|
155
|
+
return object # objects that aren't Strings, Arrays or Hashes (such as Symbols and Fixnums) won't be edited inplace.
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
165
159
|
end
|
166
160
|
|
167
161
|
#########################################################
|
data/lib/combine_pdf/version.rb
CHANGED
data/test/automated
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'benchmark'
|
4
|
+
$LOAD_PATH.unshift File.expand_path(File.join('..', '..', 'lib'), __FILE__)
|
5
|
+
require 'combine_pdf'
|
6
|
+
require 'bundler/setup'
|
7
|
+
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
10
|
+
|
11
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
12
|
+
# require "pry"
|
13
|
+
# Pry.start
|
14
|
+
|
15
|
+
pdf = CombinePDF.load "./Ruby/test\ pdfs/filled_form.pdf"
|
16
|
+
pdf.save '01_check_radio_buttuns.pdf'
|
17
|
+
pdf << CombinePDF.load("./Ruby/test\ pdfs/empty_form.pdf")
|
18
|
+
pdf << CombinePDF.load("./Ruby/test\ pdfs/filled_form.pdf")
|
19
|
+
pdf.save '02_check_form_unification_middle_is_empty.pdf'
|
20
|
+
|
21
|
+
pdf = CombinePDF.load './Ruby/test pdfs/share-font-background.pdf'
|
22
|
+
pdf2 = CombinePDF.load './Ruby/test pdfs/share-font-foreground.pdf'
|
23
|
+
i = 0
|
24
|
+
pdf.pages.each { |pg| pg << pdf2.pages[i] }
|
25
|
+
pdf.save '03_check_font_conflict.pdf'
|
26
|
+
|
27
|
+
pdf = CombinePDF.load './Ruby/test pdfs/names_go_haywire_0.pdf'
|
28
|
+
pdf << CombinePDF.load('./Ruby/test pdfs/names_go_haywire_1.pdf')
|
29
|
+
pdf.save '04_check_view_and_names_reference.pdf'
|
30
|
+
|
31
|
+
str = IO.binread './Ruby/test pdfs/outlines/self_merge_err.pdf'
|
32
|
+
pdf = CombinePDF.load('./Ruby/test pdfs/outlines/self_merge_err.pdf')
|
33
|
+
pdf << CombinePDF.load('./Ruby/test pdfs/outlines/self_merge_err.pdf')
|
34
|
+
pdf.save '05_scribus_test.pdf'
|
35
|
+
# pdf = CombinePDF.load "./Ruby/test pdfs/named_dest.pdf";nil
|
36
|
+
# pdf.save '05_check_named_dest_links.pdf' # this will take a while
|
37
|
+
# pdf = CombinePDF.load "./Ruby/test pdfs/named_dest.pdf";nil
|
38
|
+
# pdf << CombinePDF.load("./Ruby/test pdfs/named_dest.pdf");nil
|
39
|
+
# pdf.save '05_1_check_named_dest_links.pdf' # never ends... :-(
|
40
|
+
|
41
|
+
pdf = CombinePDF.load './Ruby/test pdfs/outline_small.pdf'
|
42
|
+
pdf << CombinePDF.load('./Ruby/test pdfs/outline_small.pdf')
|
43
|
+
pdf.save '06_check_links_to_second_copy.pdf'
|
44
|
+
|
45
|
+
lists = %w(./Ruby/test\ pdfs/outlines/self_merge_err.pdf ./Ruby/test\ pdfs/outlines/big_toc.pdf ./Ruby/test\ pdfs/outlines/bigger_toc.pdf ./Ruby/test\ pdfs/outlines/named_dest_no_toc.pdf ./Ruby/test\ pdfs/outlines/named_dest_no_toc2.pdf ./Ruby/test\ pdfs/outlines/named_dest.pdf ./Ruby/test\ pdfs/outlines/named_dest2.pdf)
|
46
|
+
|
47
|
+
i = 0
|
48
|
+
lists.each { |n| CombinePDF.load(n).save("07_#{(i += 1)}_#{n.split('/')[-1]}"); (CombinePDF.load(n) << CombinePDF.load(n)).save("07_#{i}x2_#{n.split('/')[-1]}") }
|
49
|
+
pdf = CombinePDF.new
|
50
|
+
lists.each { |n| pdf << CombinePDF.load(n) }
|
51
|
+
pdf.save('07_named destinations.pdf')
|
52
|
+
|
53
|
+
CombinePDF.load("./Ruby/test\ pdfs/Scribus-unknown_err.pdf").save '08_1-unknown-err-empty-str.pdf'
|
54
|
+
CombinePDF.load("./Ruby/test\ pdfs/Scribus-unknown_err2.pdf").save '08_2-unknown-err-empty-str.pdf'
|
55
|
+
CombinePDF.load("./Ruby/test\ pdfs/Scribus-unknown_err3.pdf").save '08_3-unknown-err-empty-str.pdf'
|
56
|
+
|
57
|
+
# unify = [
|
58
|
+
# "./Ruby/test\ pdfs/AESv2\ encrypted.pdf",
|
59
|
+
# "./Ruby/test\ pdfs/data-in-comment.pdf",
|
60
|
+
# "./Ruby/test\ pdfs/file_name.pdf",
|
61
|
+
# "./Ruby/test\ pdfs/garbage_after_eof.pdf",
|
62
|
+
# "./Ruby/test\ pdfs/Many\ comments.pdf",
|
63
|
+
# "./Ruby/test\ pdfs/nested\ contents\ array.PDF",
|
64
|
+
# "./Ruby/test\ pdfs/nested_resources.pdf",
|
65
|
+
# "./Ruby/test\ pdfs/original-missing-endobje.pdf",
|
66
|
+
# "./Ruby/test\ pdfs/original-multi-issue.pdf",
|
67
|
+
# "./Ruby/test\ pdfs/page_stap_nil_secure.pdf",
|
68
|
+
# "./Ruby/test\ pdfs/referenced\ decryption.pdf",
|
69
|
+
# '',
|
70
|
+
# '',
|
71
|
+
# '',
|
72
|
+
# '',
|
73
|
+
# '',
|
74
|
+
# '',
|
75
|
+
# ''
|
76
|
+
# ]
|
77
|
+
|
78
|
+
# require 'irb'
|
79
|
+
# IRB.start
|
data/test/console
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'benchmark'
|
4
|
-
$LOAD_PATH.unshift File.expand_path(File.join('..', '..', 'lib'), __FILE__
|
5
|
-
require
|
6
|
-
require
|
4
|
+
$LOAD_PATH.unshift File.expand_path(File.join('..', '..', 'lib'), __FILE__)
|
5
|
+
require 'combine_pdf'
|
6
|
+
require 'bundler/setup'
|
7
7
|
|
8
8
|
# You can add fixtures and/or initialization code here to make experimenting
|
9
9
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -12,5 +12,5 @@ require "bundler/setup"
|
|
12
12
|
# require "pry"
|
13
13
|
# Pry.start
|
14
14
|
|
15
|
-
require
|
15
|
+
require 'irb'
|
16
16
|
IRB.start
|
data/test/named_dest
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'benchmark'
|
4
|
+
require 'prawn'
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift File.expand_path(File.join('..', '..', 'lib'), __FILE__)
|
7
|
+
require 'combine_pdf'
|
8
|
+
require 'bundler/setup'
|
9
|
+
|
10
|
+
def test_with_non_asci
|
11
|
+
b_pdf = Prawn::Document.new do
|
12
|
+
text('Hi prawn')
|
13
|
+
outline.page title: 'First pdf'
|
14
|
+
text '<link anchor="hʤä.l,l o">Click me, to go to päge 3</link>', inline_format: true
|
15
|
+
19.times do |t|
|
16
|
+
text "<link anchor=\"hʤä.l,l #{t}\">Click me, to go to päge 3 6</link>", inline_format: true
|
17
|
+
end
|
18
|
+
start_new_page
|
19
|
+
text('Heeeeelloh!')
|
20
|
+
text '<link anchor="hʤä.l,l o">Click mee, to go to päge 3</link>', inline_format: true
|
21
|
+
start_new_page
|
22
|
+
text('Blub')
|
23
|
+
add_dest('hʤä.l,l o', dest_fit(page))
|
24
|
+
19.times do |t|
|
25
|
+
add_dest("hʤä.l,l #{t}", dest_fit(page))
|
26
|
+
end
|
27
|
+
outline.page title: '1st pdf page 2'
|
28
|
+
outline.define do
|
29
|
+
2.times do |t|
|
30
|
+
section "Chapter #{t}", closed: false do
|
31
|
+
page title: 'Page 1', destination: 1
|
32
|
+
page title: 'Page 2', destination: 2
|
33
|
+
page title: 'Page 3', destination: 1
|
34
|
+
page title: 'Page 4', destination: 2
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
c_pdf = Prawn::Document.new do
|
41
|
+
text('Hi prawn')
|
42
|
+
outline.page title: 'First pdf'
|
43
|
+
27.times do |t|
|
44
|
+
text "<link anchor=\"hʢä.l,l #{t}\">Click me, to go to päge 3 6</link>", inline_format: true
|
45
|
+
end
|
46
|
+
start_new_page
|
47
|
+
text('Heeeeelloh!')
|
48
|
+
text '<link anchor="hʢä.l,l o">Click mee, to go to päge 3</link>', inline_format: true
|
49
|
+
start_new_page
|
50
|
+
text('Blub')
|
51
|
+
add_dest('hʢä.l,l o', dest_fit(page))
|
52
|
+
27.times do |t|
|
53
|
+
add_dest("hʢä.l,l #{t}", dest_fit(page))
|
54
|
+
end
|
55
|
+
outline.page title: '1st pdf page 2'
|
56
|
+
outline.define do
|
57
|
+
2.times do |t|
|
58
|
+
section "Chapter #{t}", closed: false do
|
59
|
+
page title: 'Page 1', destination: 1
|
60
|
+
page title: 'Page 2', destination: 2
|
61
|
+
page title: 'Page 3', destination: 1
|
62
|
+
page title: 'Page 4', destination: 2
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
report = CombinePDF.new
|
68
|
+
tmp = b_pdf.render
|
69
|
+
IO.binwrite('01-named-src1', tmp)
|
70
|
+
report << CombinePDF.parse(tmp)
|
71
|
+
tmp = c_pdf.render
|
72
|
+
IO.binwrite('01-named-src2', tmp)
|
73
|
+
report << CombinePDF.parse(tmp)
|
74
|
+
report.save('01-named.pdf')
|
75
|
+
|
76
|
+
report = CombinePDF.new
|
77
|
+
report << CombinePDF.parse(c_pdf.render)
|
78
|
+
report << CombinePDF.parse(b_pdf.render)
|
79
|
+
report.save('01.1-named.pdf')
|
80
|
+
end
|
81
|
+
|
82
|
+
test_with_non_asci
|
83
|
+
# require 'irb'
|
84
|
+
# IRB.start
|