acro_that 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +1 -1
- data/lib/acro_that/pdf_writer.rb +56 -21
- data/lib/acro_that/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e18f96c8c68c8c55a6081ebd91d6e5e45b49901f74224b1a192f0ddae567b097
|
|
4
|
+
data.tar.gz: 30b26260b600358b0be4bc2f212b175a3ec32c928d38f413a6aa92a7fe267707
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fb17fbe00e0f1ada261e12bc8025242a7a6884ff30a3aa9bbb12d86255bb3af8a1705e6e6621d2b2a2147cb432ed6b35b4228d1ffbf5795ab49e751ccb23f228
|
|
7
|
+
data.tar.gz: 1005a449cf42d39404c04667939dbba672325ee84437836a2bea5d40db02598ee8063acb9bd5a0fc902f3167cdde636a784436d98ed07c11a9aed67a08cc17e7
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/lib/acro_that/pdf_writer.rb
CHANGED
|
@@ -47,29 +47,64 @@ module AcroThat
|
|
|
47
47
|
# Sort offsets and group consecutive objects into subsections
|
|
48
48
|
sorted = @offsets.sort_by { |num, gen, _offset| [num, gen] }
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
first_num = sorted[i][0]
|
|
53
|
-
|
|
54
|
-
# Find consecutive run
|
|
55
|
-
run_length = 1
|
|
56
|
-
while (i + run_length) < sorted.length &&
|
|
57
|
-
sorted[i + run_length][0] == first_num + run_length &&
|
|
58
|
-
sorted[i + run_length][1] == sorted[i][1]
|
|
59
|
-
run_length += 1
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# Write subsection header
|
|
63
|
-
xref << "#{first_num} #{run_length}\n".b
|
|
50
|
+
# Find max object number to determine Size
|
|
51
|
+
max_obj_num = sorted.map { |num, _gen, _offset| num }.max || 0
|
|
64
52
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
53
|
+
# Build xref entries covering all objects from 0 to max_obj_num
|
|
54
|
+
# Missing objects are marked as free (type 'f')
|
|
55
|
+
i = 0
|
|
56
|
+
current_obj = 0
|
|
57
|
+
|
|
58
|
+
while current_obj <= max_obj_num
|
|
59
|
+
# Find next existing object
|
|
60
|
+
next_existing = sorted.find { |num, _gen, _offset| num >= current_obj }
|
|
61
|
+
|
|
62
|
+
if next_existing && next_existing[0] == current_obj
|
|
63
|
+
# Object exists - find consecutive run of existing objects
|
|
64
|
+
first_num = current_obj
|
|
65
|
+
run_length = 1
|
|
66
|
+
|
|
67
|
+
while (i + run_length) < sorted.length &&
|
|
68
|
+
sorted[i + run_length][0] == first_num + run_length &&
|
|
69
|
+
sorted[i + run_length][1] == sorted[i][1]
|
|
70
|
+
run_length += 1
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Write subsection header
|
|
74
|
+
xref << "#{first_num} #{run_length}\n".b
|
|
75
|
+
|
|
76
|
+
# Write entries in this subsection
|
|
77
|
+
run_length.times do |j|
|
|
78
|
+
offset = sorted[i + j][2]
|
|
79
|
+
gen = sorted[i + j][1]
|
|
80
|
+
xref << format("%010d %05d n \n", offset, gen).b
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
i += run_length
|
|
84
|
+
current_obj = first_num + run_length
|
|
85
|
+
else
|
|
86
|
+
# Object doesn't exist - find consecutive run of missing objects
|
|
87
|
+
first_missing = current_obj
|
|
88
|
+
missing_count = 1
|
|
89
|
+
|
|
90
|
+
while current_obj + missing_count <= max_obj_num
|
|
91
|
+
check_obj = current_obj + missing_count
|
|
92
|
+
if sorted.any? { |num, _gen, _offset| num == check_obj }
|
|
93
|
+
break
|
|
94
|
+
end
|
|
95
|
+
missing_count += 1
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Write subsection header for missing objects
|
|
99
|
+
xref << "#{first_missing} #{missing_count}\n".b
|
|
100
|
+
|
|
101
|
+
# Write free entries
|
|
102
|
+
missing_count.times do
|
|
103
|
+
xref << "0000000000 65535 f \n".b
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
current_obj = first_missing + missing_count
|
|
70
107
|
end
|
|
71
|
-
|
|
72
|
-
i += run_length
|
|
73
108
|
end
|
|
74
109
|
|
|
75
110
|
@buffer << xref
|
data/lib/acro_that/version.rb
CHANGED