hexapdf 0.11.9 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +157 -0
- data/LICENSE +1 -1
- data/examples/001-hello_world.rb +1 -1
- data/examples/002-graphics.rb +1 -1
- data/examples/003-arcs.rb +1 -1
- data/examples/004-optimizing.rb +1 -1
- data/examples/005-merging.rb +1 -1
- data/examples/006-standard_pdf_fonts.rb +1 -1
- data/examples/007-truetype.rb +1 -1
- data/examples/008-show_char_bboxes.rb +1 -1
- data/examples/009-text_layouter_alignment.rb +1 -1
- data/examples/010-text_layouter_inline_boxes.rb +1 -1
- data/examples/011-text_layouter_line_wrapping.rb +1 -1
- data/examples/012-text_layouter_styling.rb +1 -1
- data/examples/013-text_layouter_shapes.rb +1 -1
- data/examples/014-text_in_polygon.rb +1 -1
- data/examples/015-boxes.rb +1 -1
- data/examples/016-frame_automatic_box_placement.rb +1 -1
- data/examples/017-frame_text_flow.rb +1 -1
- data/examples/018-composer.rb +1 -1
- data/examples/019-acro_form.rb +51 -0
- data/lib/hexapdf.rb +1 -1
- data/lib/hexapdf/cli.rb +3 -1
- data/lib/hexapdf/cli/batch.rb +1 -1
- data/lib/hexapdf/cli/command.rb +22 -11
- data/lib/hexapdf/cli/files.rb +1 -1
- data/lib/hexapdf/cli/form.rb +240 -0
- data/lib/hexapdf/cli/image2pdf.rb +3 -2
- data/lib/hexapdf/cli/images.rb +1 -1
- data/lib/hexapdf/cli/info.rb +52 -3
- data/lib/hexapdf/cli/inspect.rb +31 -9
- data/lib/hexapdf/cli/merge.rb +2 -2
- data/lib/hexapdf/cli/modify.rb +1 -1
- data/lib/hexapdf/cli/optimize.rb +1 -1
- data/lib/hexapdf/cli/split.rb +1 -1
- data/lib/hexapdf/cli/watermark.rb +1 -1
- data/lib/hexapdf/composer.rb +2 -2
- data/lib/hexapdf/configuration.rb +81 -11
- data/lib/hexapdf/content.rb +3 -1
- data/lib/hexapdf/content/canvas.rb +5 -18
- data/lib/hexapdf/content/color_space.rb +111 -32
- data/lib/hexapdf/content/graphic_object.rb +1 -1
- data/lib/hexapdf/content/graphic_object/arc.rb +4 -4
- data/lib/hexapdf/content/graphic_object/endpoint_arc.rb +1 -1
- data/lib/hexapdf/content/graphic_object/geom2d.rb +1 -1
- data/lib/hexapdf/content/graphic_object/solid_arc.rb +1 -1
- data/lib/hexapdf/content/graphics_state.rb +1 -1
- data/lib/hexapdf/content/operator.rb +9 -9
- data/lib/hexapdf/content/parser.rb +18 -5
- data/lib/hexapdf/content/processor.rb +1 -1
- data/lib/hexapdf/content/transformation_matrix.rb +1 -1
- data/lib/hexapdf/data_dir.rb +1 -1
- data/lib/hexapdf/dictionary.rb +5 -5
- data/lib/hexapdf/dictionary_fields.rb +2 -10
- data/lib/hexapdf/document.rb +45 -17
- data/lib/hexapdf/document/files.rb +1 -2
- data/lib/hexapdf/document/fonts.rb +1 -1
- data/lib/hexapdf/document/images.rb +1 -1
- data/lib/hexapdf/document/pages.rb +3 -14
- data/lib/hexapdf/encryption.rb +1 -1
- data/lib/hexapdf/encryption/aes.rb +1 -1
- data/lib/hexapdf/encryption/arc4.rb +1 -1
- data/lib/hexapdf/encryption/fast_aes.rb +1 -1
- data/lib/hexapdf/encryption/fast_arc4.rb +2 -2
- data/lib/hexapdf/encryption/identity.rb +1 -1
- data/lib/hexapdf/encryption/ruby_aes.rb +1 -1
- data/lib/hexapdf/encryption/ruby_arc4.rb +1 -1
- data/lib/hexapdf/encryption/security_handler.rb +2 -1
- data/lib/hexapdf/encryption/standard_security_handler.rb +2 -1
- data/lib/hexapdf/error.rb +1 -1
- data/lib/hexapdf/filter.rb +3 -3
- data/lib/hexapdf/filter/ascii85_decode.rb +1 -1
- data/lib/hexapdf/filter/ascii_hex_decode.rb +1 -1
- data/lib/hexapdf/filter/encryption.rb +1 -1
- data/lib/hexapdf/filter/flate_decode.rb +1 -1
- data/lib/hexapdf/filter/lzw_decode.rb +1 -1
- data/lib/hexapdf/filter/{jpx_decode.rb → pass_through.rb} +5 -5
- data/lib/hexapdf/filter/predictor.rb +1 -1
- data/lib/hexapdf/filter/run_length_decode.rb +1 -1
- data/lib/hexapdf/font/cmap.rb +2 -5
- data/lib/hexapdf/font/cmap/parser.rb +1 -1
- data/lib/hexapdf/font/cmap/writer.rb +1 -1
- data/lib/hexapdf/font/encoding.rb +1 -1
- data/lib/hexapdf/font/encoding/base.rb +9 -1
- data/lib/hexapdf/font/encoding/difference_encoding.rb +7 -1
- data/lib/hexapdf/font/encoding/glyph_list.rb +1 -1
- data/lib/hexapdf/font/encoding/mac_expert_encoding.rb +1 -1
- data/lib/hexapdf/font/encoding/mac_roman_encoding.rb +1 -1
- data/lib/hexapdf/font/encoding/standard_encoding.rb +1 -1
- data/lib/hexapdf/font/encoding/symbol_encoding.rb +1 -1
- data/lib/hexapdf/font/encoding/win_ansi_encoding.rb +1 -1
- data/lib/hexapdf/font/encoding/zapf_dingbats_encoding.rb +1 -1
- data/lib/hexapdf/font/invalid_glyph.rb +1 -1
- data/lib/hexapdf/font/true_type.rb +1 -1
- data/lib/hexapdf/font/true_type/builder.rb +1 -1
- data/lib/hexapdf/font/true_type/font.rb +1 -1
- data/lib/hexapdf/font/true_type/optimizer.rb +1 -1
- data/lib/hexapdf/font/true_type/subsetter.rb +1 -1
- data/lib/hexapdf/font/true_type/table.rb +1 -1
- data/lib/hexapdf/font/true_type/table/cmap.rb +1 -1
- data/lib/hexapdf/font/true_type/table/cmap_subtable.rb +1 -1
- data/lib/hexapdf/font/true_type/table/directory.rb +1 -1
- data/lib/hexapdf/font/true_type/table/glyf.rb +1 -1
- data/lib/hexapdf/font/true_type/table/head.rb +2 -1
- data/lib/hexapdf/font/true_type/table/hhea.rb +1 -1
- data/lib/hexapdf/font/true_type/table/hmtx.rb +1 -1
- data/lib/hexapdf/font/true_type/table/kern.rb +1 -1
- data/lib/hexapdf/font/true_type/table/loca.rb +1 -1
- data/lib/hexapdf/font/true_type/table/maxp.rb +1 -1
- data/lib/hexapdf/font/true_type/table/name.rb +1 -1
- data/lib/hexapdf/font/true_type/table/os2.rb +3 -1
- data/lib/hexapdf/font/true_type/table/post.rb +1 -1
- data/lib/hexapdf/font/true_type_wrapper.rb +54 -51
- data/lib/hexapdf/font/type1.rb +1 -1
- data/lib/hexapdf/font/type1/afm_parser.rb +1 -1
- data/lib/hexapdf/font/type1/character_metrics.rb +1 -1
- data/lib/hexapdf/font/type1/font.rb +1 -1
- data/lib/hexapdf/font/type1/font_metrics.rb +1 -1
- data/lib/hexapdf/font/type1/pfb_parser.rb +1 -1
- data/lib/hexapdf/font/type1_wrapper.rb +68 -52
- data/lib/hexapdf/font_loader.rb +1 -1
- data/lib/hexapdf/font_loader/from_configuration.rb +1 -1
- data/lib/hexapdf/font_loader/from_file.rb +1 -1
- data/lib/hexapdf/font_loader/standard14.rb +1 -1
- data/lib/hexapdf/image_loader.rb +1 -1
- data/lib/hexapdf/image_loader/jpeg.rb +1 -1
- data/lib/hexapdf/image_loader/pdf.rb +1 -1
- data/lib/hexapdf/image_loader/png.rb +4 -3
- data/lib/hexapdf/importer.rb +2 -4
- data/lib/hexapdf/layout.rb +1 -1
- data/lib/hexapdf/layout/box.rb +1 -1
- data/lib/hexapdf/layout/frame.rb +1 -1
- data/lib/hexapdf/layout/image_box.rb +1 -1
- data/lib/hexapdf/layout/inline_box.rb +1 -1
- data/lib/hexapdf/layout/line.rb +2 -2
- data/lib/hexapdf/layout/numeric_refinements.rb +1 -1
- data/lib/hexapdf/layout/style.rb +24 -24
- data/lib/hexapdf/layout/text_box.rb +1 -1
- data/lib/hexapdf/layout/text_fragment.rb +1 -1
- data/lib/hexapdf/layout/text_layouter.rb +1 -1
- data/lib/hexapdf/layout/text_shaper.rb +4 -3
- data/lib/hexapdf/layout/width_from_polygon.rb +1 -1
- data/lib/hexapdf/name_tree_node.rb +1 -1
- data/lib/hexapdf/number_tree_node.rb +1 -1
- data/lib/hexapdf/object.rb +32 -27
- data/lib/hexapdf/parser.rb +69 -6
- data/lib/hexapdf/pdf_array.rb +10 -3
- data/lib/hexapdf/rectangle.rb +31 -1
- data/lib/hexapdf/reference.rb +1 -1
- data/lib/hexapdf/revision.rb +2 -1
- data/lib/hexapdf/revisions.rb +30 -22
- data/lib/hexapdf/serializer.rb +2 -2
- data/lib/hexapdf/stream.rb +1 -1
- data/lib/hexapdf/task.rb +1 -1
- data/lib/hexapdf/task/dereference.rb +1 -1
- data/lib/hexapdf/task/optimize.rb +7 -5
- data/lib/hexapdf/tokenizer.rb +5 -4
- data/lib/hexapdf/type.rb +1 -1
- data/lib/hexapdf/type/acro_form.rb +7 -1
- data/lib/hexapdf/type/acro_form/appearance_generator.rb +405 -0
- data/lib/hexapdf/type/acro_form/button_field.rb +305 -0
- data/lib/hexapdf/type/acro_form/choice_field.rb +220 -0
- data/lib/hexapdf/type/acro_form/field.rb +250 -17
- data/lib/hexapdf/type/acro_form/form.rb +159 -7
- data/lib/hexapdf/type/acro_form/text_field.rb +187 -0
- data/lib/hexapdf/type/acro_form/variable_text_field.rb +122 -0
- data/lib/hexapdf/type/action.rb +1 -1
- data/lib/hexapdf/type/actions.rb +1 -1
- data/lib/hexapdf/type/actions/go_to.rb +1 -1
- data/lib/hexapdf/type/actions/go_to_r.rb +1 -1
- data/lib/hexapdf/type/actions/launch.rb +1 -1
- data/lib/hexapdf/type/actions/uri.rb +4 -3
- data/lib/hexapdf/type/annotation.rb +73 -3
- data/lib/hexapdf/type/annotations.rb +1 -1
- data/lib/hexapdf/type/annotations/link.rb +2 -2
- data/lib/hexapdf/type/annotations/markup_annotation.rb +1 -1
- data/lib/hexapdf/type/annotations/text.rb +1 -1
- data/lib/hexapdf/type/annotations/widget.rb +238 -2
- data/lib/hexapdf/type/catalog.rb +23 -3
- data/lib/hexapdf/type/cid_font.rb +1 -1
- data/lib/hexapdf/type/embedded_file.rb +1 -1
- data/lib/hexapdf/type/file_specification.rb +2 -2
- data/lib/hexapdf/type/font.rb +18 -1
- data/lib/hexapdf/type/font_descriptor.rb +2 -2
- data/lib/hexapdf/type/font_simple.rb +4 -2
- data/lib/hexapdf/type/font_true_type.rb +7 -3
- data/lib/hexapdf/type/font_type0.rb +2 -2
- data/lib/hexapdf/type/font_type1.rb +16 -1
- data/lib/hexapdf/type/font_type3.rb +1 -1
- data/lib/hexapdf/type/form.rb +12 -2
- data/lib/hexapdf/type/graphics_state_parameter.rb +1 -1
- data/lib/hexapdf/type/icon_fit.rb +1 -1
- data/lib/hexapdf/type/image.rb +5 -3
- data/lib/hexapdf/type/info.rb +1 -1
- data/lib/hexapdf/type/names.rb +1 -1
- data/lib/hexapdf/type/object_stream.rb +1 -1
- data/lib/hexapdf/type/page.rb +36 -12
- data/lib/hexapdf/type/page_tree_node.rb +37 -16
- data/lib/hexapdf/type/resources.rb +17 -3
- data/lib/hexapdf/type/trailer.rb +4 -6
- data/lib/hexapdf/type/viewer_preferences.rb +1 -1
- data/lib/hexapdf/type/xref_stream.rb +1 -1
- data/lib/hexapdf/utils/bit_field.rb +38 -24
- data/lib/hexapdf/utils/bit_stream.rb +1 -1
- data/lib/hexapdf/utils/graphics_helpers.rb +1 -1
- data/lib/hexapdf/utils/lru_cache.rb +1 -1
- data/lib/hexapdf/utils/math_helpers.rb +1 -1
- data/lib/hexapdf/utils/object_hash.rb +1 -1
- data/lib/hexapdf/utils/pdf_doc_encoding.rb +1 -1
- data/lib/hexapdf/utils/sorted_tree_node.rb +19 -16
- data/lib/hexapdf/version.rb +2 -2
- data/lib/hexapdf/writer.rb +1 -1
- data/lib/hexapdf/xref_section.rb +1 -1
- data/test/hexapdf/common_tokenizer_tests.rb +6 -1
- data/test/hexapdf/content/common.rb +2 -2
- data/test/hexapdf/content/graphic_object/test_arc.rb +4 -4
- data/test/hexapdf/content/test_canvas.rb +3 -3
- data/test/hexapdf/content/test_color_space.rb +71 -8
- data/test/hexapdf/content/test_operator.rb +22 -22
- data/test/hexapdf/content/test_parser.rb +14 -0
- data/test/hexapdf/document/test_fonts.rb +1 -1
- data/test/hexapdf/document/test_pages.rb +6 -6
- data/test/hexapdf/encryption/test_aes.rb +4 -4
- data/test/hexapdf/encryption/test_standard_security_handler.rb +11 -11
- data/test/hexapdf/filter/test_ascii85_decode.rb +1 -1
- data/test/hexapdf/filter/test_ascii_hex_decode.rb +1 -1
- data/test/hexapdf/font/encoding/test_base.rb +10 -0
- data/test/hexapdf/font/encoding/test_difference_encoding.rb +8 -0
- data/test/hexapdf/font/test_true_type_wrapper.rb +10 -7
- data/test/hexapdf/font/test_type1_wrapper.rb +33 -8
- data/test/hexapdf/layout/test_style.rb +1 -1
- data/test/hexapdf/layout/test_text_layouter.rb +3 -4
- data/test/hexapdf/test_configuration.rb +2 -2
- data/test/hexapdf/test_dictionary.rb +3 -1
- data/test/hexapdf/test_dictionary_fields.rb +2 -2
- data/test/hexapdf/test_document.rb +16 -4
- data/test/hexapdf/test_object.rb +44 -26
- data/test/hexapdf/test_parser.rb +125 -55
- data/test/hexapdf/test_pdf_array.rb +7 -0
- data/test/hexapdf/test_rectangle.rb +14 -0
- data/test/hexapdf/test_revision.rb +3 -0
- data/test/hexapdf/test_revisions.rb +35 -0
- data/test/hexapdf/test_writer.rb +2 -2
- data/test/hexapdf/type/acro_form/test_appearance_generator.rb +521 -0
- data/test/hexapdf/type/acro_form/test_button_field.rb +281 -0
- data/test/hexapdf/type/acro_form/test_choice_field.rb +137 -0
- data/test/hexapdf/type/acro_form/test_field.rb +163 -6
- data/test/hexapdf/type/acro_form/test_form.rb +189 -22
- data/test/hexapdf/type/acro_form/test_text_field.rb +121 -0
- data/test/hexapdf/type/acro_form/test_variable_text_field.rb +77 -0
- data/test/hexapdf/type/annotations/test_text.rb +1 -1
- data/test/hexapdf/type/annotations/test_widget.rb +199 -0
- data/test/hexapdf/type/test_annotation.rb +45 -0
- data/test/hexapdf/type/test_catalog.rb +18 -0
- data/test/hexapdf/type/test_font.rb +5 -0
- data/test/hexapdf/type/test_font_simple.rb +2 -1
- data/test/hexapdf/type/test_font_true_type.rb +6 -0
- data/test/hexapdf/type/test_font_type1.rb +8 -0
- data/test/hexapdf/type/test_form.rb +19 -1
- data/test/hexapdf/type/test_image.rb +7 -0
- data/test/hexapdf/type/test_page.rb +45 -7
- data/test/hexapdf/type/test_page_tree_node.rb +62 -12
- data/test/hexapdf/type/test_resources.rb +20 -0
- data/test/hexapdf/type/test_trailer.rb +4 -0
- data/test/hexapdf/utils/test_bit_field.rb +15 -1
- data/test/hexapdf/utils/test_sorted_tree_node.rb +10 -9
- data/test/test_helper.rb +1 -1
- metadata +34 -21
- data/lib/hexapdf/filter/dct_decode.rb +0 -60
@@ -155,36 +155,44 @@ describe HexaPDF::Type::PageTreeNode do
|
|
155
155
|
end
|
156
156
|
|
157
157
|
it "deletes the correct page by index" do
|
158
|
-
|
158
|
+
@root.delete_page(2)
|
159
159
|
assert_equal(2, @kid12.page_count)
|
160
160
|
assert_equal(4, @kid1.page_count)
|
161
161
|
assert_equal(7, @root.page_count)
|
162
|
-
|
162
|
+
assert(@pages[2].null?)
|
163
163
|
|
164
|
-
|
164
|
+
@root.delete_page(4)
|
165
165
|
assert_equal(6, @root.page_count)
|
166
|
-
|
166
|
+
assert(@pages[5].null?)
|
167
167
|
end
|
168
168
|
|
169
169
|
it "deletes the given page" do
|
170
|
-
|
171
|
-
|
170
|
+
@root.delete_page(@pages[2])
|
171
|
+
assert(@pages[2].null?)
|
172
|
+
@root.delete_page(@pages[5])
|
173
|
+
assert(@pages[5].null?)
|
172
174
|
end
|
173
175
|
|
174
176
|
it "allows deleting a page from an intermediary node" do
|
175
|
-
|
177
|
+
@kid1.delete_page(@pages[2])
|
176
178
|
assert_equal(7, @root.page_count)
|
177
179
|
end
|
178
180
|
|
179
181
|
it "does nothing if the page index is not valid" do
|
180
|
-
|
181
|
-
|
182
|
+
@root.delete_page(20)
|
183
|
+
@root.delete_page(-20)
|
182
184
|
assert_equal(8, @root.page_count)
|
183
185
|
end
|
184
186
|
|
185
|
-
it "does nothing if the page
|
187
|
+
it "does nothing if the page has already been deleted" do
|
188
|
+
@root.delete_page(@pages[2])
|
189
|
+
@root.delete_page(@pages[2])
|
190
|
+
assert_equal(7, @root.page_count)
|
191
|
+
end
|
192
|
+
|
193
|
+
it "fails if the page is not in its parent's /Kids array" do
|
186
194
|
@kid12[:Kids].delete_at(0)
|
187
|
-
|
195
|
+
assert_raises(HexaPDF::Error) { @root.delete_page(@pages[2]) }
|
188
196
|
assert_equal(8, @root.page_count)
|
189
197
|
end
|
190
198
|
|
@@ -193,11 +201,53 @@ describe HexaPDF::Type::PageTreeNode do
|
|
193
201
|
page = @doc.add({Type: :Page, Parent: pages})
|
194
202
|
pages[:Kids] << page
|
195
203
|
|
196
|
-
|
204
|
+
@root.delete_page(page)
|
197
205
|
assert_equal(8, @root.page_count)
|
198
206
|
end
|
199
207
|
end
|
200
208
|
|
209
|
+
describe "move_page" do
|
210
|
+
before do
|
211
|
+
define_multilevel_page_tree
|
212
|
+
end
|
213
|
+
|
214
|
+
it "moves the page to the first place" do
|
215
|
+
@root.move_page(@pages[1], 0)
|
216
|
+
assert_equal([@pages[1], @pages[0], *@pages[2..-1]], @root.each_page.to_a)
|
217
|
+
assert(@root.validate)
|
218
|
+
end
|
219
|
+
|
220
|
+
it "moves the page to the correct location with a positive index" do
|
221
|
+
@root.move_page(1, 3)
|
222
|
+
assert_equal([@pages[0], @pages[2], @pages[1], *@pages[3..-1]], @root.each_page.to_a)
|
223
|
+
assert(@root.validate)
|
224
|
+
end
|
225
|
+
|
226
|
+
it "moves the page to the last place" do
|
227
|
+
@root.move_page(1, -1)
|
228
|
+
assert_equal([@pages[0], *@pages[2..-1], @pages[1]], @root.each_page.to_a)
|
229
|
+
assert(@root.validate)
|
230
|
+
end
|
231
|
+
|
232
|
+
it "fails if the index to the moving page is invalid" do
|
233
|
+
assert_raises(HexaPDF::Error) { @root.move_page(10, 0) }
|
234
|
+
end
|
235
|
+
|
236
|
+
it "fails if the moving page was deleted/is null" do
|
237
|
+
@doc.delete(@pages[0])
|
238
|
+
assert_raises(HexaPDF::Error) { @root.move_page(@pages[0], 3) }
|
239
|
+
end
|
240
|
+
|
241
|
+
it "fails if the page was not yet added to a page tree" do
|
242
|
+
page = @doc.add({Type: :Page})
|
243
|
+
assert_raises(HexaPDF::Error) { @root.move_page(page, 3) }
|
244
|
+
end
|
245
|
+
|
246
|
+
it "fails if the page is not part of the page tree" do
|
247
|
+
assert_raises(HexaPDF::Error) { @kid1.move_page(@pages[6], 3) }
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
201
251
|
describe "each_page" do
|
202
252
|
before do
|
203
253
|
define_multilevel_page_tree
|
@@ -25,6 +25,10 @@ describe HexaPDF::Type::Resources do
|
|
25
25
|
assert_kind_of(HexaPDF::Content::ColorSpace::Universal, @res.color_space(:CSName))
|
26
26
|
end
|
27
27
|
|
28
|
+
it "works for the Pattern color space" do
|
29
|
+
assert_kind_of(HexaPDF::Content::ColorSpace::Universal, @res.color_space(:Pattern))
|
30
|
+
end
|
31
|
+
|
28
32
|
it "returns the universal color space for unknown color spaces, with resolved references" do
|
29
33
|
data = @doc.add({Some: :data})
|
30
34
|
@res[:ColorSpace] = {CSName: [:SomeUnknownColorSpace,
|
@@ -168,6 +172,22 @@ describe HexaPDF::Type::Resources do
|
|
168
172
|
end
|
169
173
|
end
|
170
174
|
|
175
|
+
describe "pattern" do
|
176
|
+
it "invokes the object_getter method" do
|
177
|
+
assert_method_invoked(@res, :object_getter, [:Pattern, :test]) do
|
178
|
+
@res.pattern(:test)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe "add_pattern" do
|
184
|
+
it "invokes the object_setter method" do
|
185
|
+
assert_method_invoked(@res, :object_setter, [:Pattern, 'P', :test]) do
|
186
|
+
@res.add_pattern(:test)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
171
191
|
describe "validation" do
|
172
192
|
it "assigns the default value if ProcSet is not set" do
|
173
193
|
@res.validate
|
@@ -9,12 +9,16 @@ describe HexaPDF::Type::Trailer do
|
|
9
9
|
before do
|
10
10
|
@doc = Object.new
|
11
11
|
@doc.instance_variable_set(:@version, '1.2')
|
12
|
+
|
12
13
|
def (@doc).version=(v); @version = v; end
|
14
|
+
|
13
15
|
def (@doc).deref(obj); obj; end
|
16
|
+
|
14
17
|
def (@doc).wrap(obj, *)
|
15
18
|
(obj.kind_of?(Array) ? HexaPDF::PDFArray : HexaPDF::Dictionary).
|
16
19
|
new(obj, oid: (obj.oid rescue 0))
|
17
20
|
end
|
21
|
+
|
18
22
|
root = HexaPDF::Dictionary.new({}, oid: 3)
|
19
23
|
@obj = HexaPDF::Type::Trailer.new({Size: 10, Root: root}, document: @doc)
|
20
24
|
end
|
@@ -6,8 +6,11 @@ require 'hexapdf/utils/bit_field'
|
|
6
6
|
class TestBitField
|
7
7
|
|
8
8
|
extend HexaPDF::Utils::BitField
|
9
|
+
|
9
10
|
attr_accessor :data
|
10
|
-
|
11
|
+
|
12
|
+
bit_field(:data, {bit0: 0, bit1: 1, bit5: 5}, lister: "list", getter: "get", setter: "set",
|
13
|
+
unsetter: 'unset')
|
11
14
|
|
12
15
|
end
|
13
16
|
|
@@ -16,6 +19,10 @@ describe HexaPDF::Utils::BitField do
|
|
16
19
|
@obj = TestBitField.new
|
17
20
|
end
|
18
21
|
|
22
|
+
it "allows inspection of the defined bits" do
|
23
|
+
assert_equal({bit0: 0, bit1: 1, bit5: 5}, TestBitField::DATA_BIT_MAPPING)
|
24
|
+
end
|
25
|
+
|
19
26
|
it "returns all bit names using the lister method" do
|
20
27
|
@obj.data = 0b100011
|
21
28
|
assert_equal([:bit0, :bit1, :bit5], @obj.list)
|
@@ -40,6 +47,13 @@ describe HexaPDF::Utils::BitField do
|
|
40
47
|
assert_equal(0b100001, @obj.data)
|
41
48
|
end
|
42
49
|
|
50
|
+
it "can unset a given bit via the unsetter method" do
|
51
|
+
@obj.set(:bit0, :bit5)
|
52
|
+
assert_equal(0b100001, @obj.data)
|
53
|
+
@obj.unset(:bit5)
|
54
|
+
assert_equal(0b000001, @obj.data)
|
55
|
+
end
|
56
|
+
|
43
57
|
it "fails if an unknown bit name or bit index is used with one of the methods" do
|
44
58
|
e = assert_raises(ArgumentError) { @obj.get(10) }
|
45
59
|
assert_equal("Invalid bit field name or index '10' for TestBitField#data", e.message)
|
@@ -13,9 +13,9 @@ describe HexaPDF::Utils::SortedTreeNode do
|
|
13
13
|
|
14
14
|
def add_multilevel_entries
|
15
15
|
@kid11 = @doc.add({Limits: ['c', 'f'], Names: ['c', 1, 'f', 1]}, type: HexaPDF::NameTreeNode)
|
16
|
-
@kid12 = @doc.add({Limits: ['i', 'm'], Names: ['i', 1, 'm', 1]})
|
16
|
+
@kid12 = @doc.add({Limits: ['i', 'm'], Names: ['i', 1, 'm', 1]}, type: HexaPDF::NameTreeNode)
|
17
17
|
ref = HexaPDF::Reference.new(@kid11.oid, @kid11.gen)
|
18
|
-
@kid1 = @doc.add({Limits: ['c', 'm'], Kids: [ref, @kid12]})
|
18
|
+
@kid1 = @doc.add({Limits: ['c', 'm'], Kids: [ref, @kid12]}, type: HexaPDF::NameTreeNode)
|
19
19
|
@kid21 = @doc.add({Limits: ['o', 'q'], Names: ['o', 1, 'q', 1]}, type: HexaPDF::NameTreeNode)
|
20
20
|
@kid221 = @doc.add({Limits: ['s', 'u'], Names: ['s', 1, 'u', 1]}, type: HexaPDF::NameTreeNode)
|
21
21
|
@kid22 = @doc.add({Limits: ['s', 'u'], Kids: [@kid221]}, type: HexaPDF::NameTreeNode)
|
@@ -73,11 +73,11 @@ describe HexaPDF::Utils::SortedTreeNode do
|
|
73
73
|
@root.add_entry('p', 1)
|
74
74
|
@root.add_entry('r', 1)
|
75
75
|
@root.add_entry('v', 1)
|
76
|
-
assert_equal(['a', 'm'], @kid1[:Limits])
|
76
|
+
assert_equal(['a', 'm'], @kid1[:Limits].value)
|
77
77
|
assert_equal(['a', 'f'], @kid11[:Limits].value)
|
78
78
|
assert_equal(['a', 1, 'c', 1, 'e', 1, 'f', 1], @kid11[:Names].value)
|
79
|
-
assert_equal(['g', 'm'], @kid12[:Limits])
|
80
|
-
assert_equal(['g', 1, 'i', 1, 'j', 1, 'm', 1], @kid12[:Names])
|
79
|
+
assert_equal(['g', 'm'], @kid12[:Limits].value)
|
80
|
+
assert_equal(['g', 1, 'i', 1, 'j', 1, 'm', 1], @kid12[:Names].value)
|
81
81
|
assert_equal(['n', 'v'], @kid2[:Limits].value)
|
82
82
|
assert_equal(['n', 'q'], @kid21[:Limits].value)
|
83
83
|
assert_equal(['n', 1, 'o', 1, 'p', 1, 'q', 1], @kid21[:Names].value)
|
@@ -193,15 +193,16 @@ describe HexaPDF::Utils::SortedTreeNode do
|
|
193
193
|
end
|
194
194
|
|
195
195
|
it "checks that all kid objects are indirect objects" do
|
196
|
-
@root[:Kids][0] = HexaPDF::Reference.new(@kid1.oid, @kid1.gen)
|
196
|
+
@root[:Kids][0] = ref = HexaPDF::Reference.new(@kid1.oid, @kid1.gen)
|
197
197
|
assert(@root.validate)
|
198
198
|
|
199
|
-
@root[:Kids][0] =
|
199
|
+
@root[:Kids][0] = ref
|
200
200
|
@kid1.oid = 0
|
201
|
-
|
201
|
+
assert(@root.validate do |message, c|
|
202
202
|
assert_match(/must be indirect objects/, message)
|
203
|
-
|
203
|
+
assert(c)
|
204
204
|
end)
|
205
|
+
assert(@kid1.indirect?)
|
205
206
|
end
|
206
207
|
|
207
208
|
it "checks that leaf node containers have an even number of entries" do
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hexapdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Leitner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cmdparse
|
@@ -36,54 +36,56 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '0.
|
39
|
+
version: '0.3'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0.
|
46
|
+
version: '0.3'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: kramdown
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 1.13.0
|
53
|
+
version: '2.3'
|
57
54
|
type: :development
|
58
55
|
prerelease: false
|
59
56
|
version_requirements: !ruby/object:Gem::Requirement
|
60
57
|
requirements:
|
61
58
|
- - "~>"
|
62
59
|
- !ruby/object:Gem::Version
|
63
|
-
version: '
|
64
|
-
|
60
|
+
version: '2.3'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: reline
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
65
66
|
- !ruby/object:Gem::Version
|
66
|
-
version: 1
|
67
|
+
version: '0.1'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0.1'
|
67
75
|
- !ruby/object:Gem::Dependency
|
68
76
|
name: rubocop
|
69
77
|
requirement: !ruby/object:Gem::Requirement
|
70
78
|
requirements:
|
71
79
|
- - "~>"
|
72
80
|
- !ruby/object:Gem::Version
|
73
|
-
version: '0
|
74
|
-
- - ">="
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: 0.58.2
|
81
|
+
version: '1.0'
|
77
82
|
type: :development
|
78
83
|
prerelease: false
|
79
84
|
version_requirements: !ruby/object:Gem::Requirement
|
80
85
|
requirements:
|
81
86
|
- - "~>"
|
82
87
|
- !ruby/object:Gem::Version
|
83
|
-
version: '0
|
84
|
-
- - ">="
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version: 0.58.2
|
88
|
+
version: '1.0'
|
87
89
|
description: |
|
88
90
|
HexaPDF is a pure Ruby library with an accompanying application for working with PDF
|
89
91
|
files.
|
@@ -209,6 +211,7 @@ files:
|
|
209
211
|
- examples/016-frame_automatic_box_placement.rb
|
210
212
|
- examples/017-frame_text_flow.rb
|
211
213
|
- examples/018-composer.rb
|
214
|
+
- examples/019-acro_form.rb
|
212
215
|
- examples/emoji-smile.png
|
213
216
|
- examples/emoji-wink.png
|
214
217
|
- examples/machupicchu.jpg
|
@@ -217,6 +220,7 @@ files:
|
|
217
220
|
- lib/hexapdf/cli/batch.rb
|
218
221
|
- lib/hexapdf/cli/command.rb
|
219
222
|
- lib/hexapdf/cli/files.rb
|
223
|
+
- lib/hexapdf/cli/form.rb
|
220
224
|
- lib/hexapdf/cli/image2pdf.rb
|
221
225
|
- lib/hexapdf/cli/images.rb
|
222
226
|
- lib/hexapdf/cli/info.rb
|
@@ -263,11 +267,10 @@ files:
|
|
263
267
|
- lib/hexapdf/filter.rb
|
264
268
|
- lib/hexapdf/filter/ascii85_decode.rb
|
265
269
|
- lib/hexapdf/filter/ascii_hex_decode.rb
|
266
|
-
- lib/hexapdf/filter/dct_decode.rb
|
267
270
|
- lib/hexapdf/filter/encryption.rb
|
268
271
|
- lib/hexapdf/filter/flate_decode.rb
|
269
|
-
- lib/hexapdf/filter/jpx_decode.rb
|
270
272
|
- lib/hexapdf/filter/lzw_decode.rb
|
273
|
+
- lib/hexapdf/filter/pass_through.rb
|
271
274
|
- lib/hexapdf/filter/predictor.rb
|
272
275
|
- lib/hexapdf/filter/run_length_decode.rb
|
273
276
|
- lib/hexapdf/font/cmap.rb
|
@@ -350,8 +353,13 @@ files:
|
|
350
353
|
- lib/hexapdf/tokenizer.rb
|
351
354
|
- lib/hexapdf/type.rb
|
352
355
|
- lib/hexapdf/type/acro_form.rb
|
356
|
+
- lib/hexapdf/type/acro_form/appearance_generator.rb
|
357
|
+
- lib/hexapdf/type/acro_form/button_field.rb
|
358
|
+
- lib/hexapdf/type/acro_form/choice_field.rb
|
353
359
|
- lib/hexapdf/type/acro_form/field.rb
|
354
360
|
- lib/hexapdf/type/acro_form/form.rb
|
361
|
+
- lib/hexapdf/type/acro_form/text_field.rb
|
362
|
+
- lib/hexapdf/type/acro_form/variable_text_field.rb
|
355
363
|
- lib/hexapdf/type/action.rb
|
356
364
|
- lib/hexapdf/type/actions.rb
|
357
365
|
- lib/hexapdf/type/actions/go_to.rb
|
@@ -580,8 +588,13 @@ files:
|
|
580
588
|
- test/hexapdf/test_type.rb
|
581
589
|
- test/hexapdf/test_writer.rb
|
582
590
|
- test/hexapdf/test_xref_section.rb
|
591
|
+
- test/hexapdf/type/acro_form/test_appearance_generator.rb
|
592
|
+
- test/hexapdf/type/acro_form/test_button_field.rb
|
593
|
+
- test/hexapdf/type/acro_form/test_choice_field.rb
|
583
594
|
- test/hexapdf/type/acro_form/test_field.rb
|
584
595
|
- test/hexapdf/type/acro_form/test_form.rb
|
596
|
+
- test/hexapdf/type/acro_form/test_text_field.rb
|
597
|
+
- test/hexapdf/type/acro_form/test_variable_text_field.rb
|
585
598
|
- test/hexapdf/type/actions/test_launch.rb
|
586
599
|
- test/hexapdf/type/actions/test_uri.rb
|
587
600
|
- test/hexapdf/type/annotations/test_markup_annotation.rb
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
2
|
-
#
|
3
|
-
#--
|
4
|
-
# This file is part of HexaPDF.
|
5
|
-
#
|
6
|
-
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
7
|
-
# Copyright (C) 2014-2019 Thomas Leitner
|
8
|
-
#
|
9
|
-
# HexaPDF is free software: you can redistribute it and/or modify it
|
10
|
-
# under the terms of the GNU Affero General Public License version 3 as
|
11
|
-
# published by the Free Software Foundation with the addition of the
|
12
|
-
# following permission added to Section 15 as permitted in Section 7(a):
|
13
|
-
# FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
|
14
|
-
# THOMAS LEITNER, THOMAS LEITNER DISCLAIMS THE WARRANTY OF NON
|
15
|
-
# INFRINGEMENT OF THIRD PARTY RIGHTS.
|
16
|
-
#
|
17
|
-
# HexaPDF is distributed in the hope that it will be useful, but WITHOUT
|
18
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
20
|
-
# License for more details.
|
21
|
-
#
|
22
|
-
# You should have received a copy of the GNU Affero General Public License
|
23
|
-
# along with HexaPDF. If not, see <http://www.gnu.org/licenses/>.
|
24
|
-
#
|
25
|
-
# The interactive user interfaces in modified source and object code
|
26
|
-
# versions of HexaPDF must display Appropriate Legal Notices, as required
|
27
|
-
# under Section 5 of the GNU Affero General Public License version 3.
|
28
|
-
#
|
29
|
-
# In accordance with Section 7(b) of the GNU Affero General Public
|
30
|
-
# License, a covered work must retain the producer line in every PDF that
|
31
|
-
# is created or manipulated using HexaPDF.
|
32
|
-
#
|
33
|
-
# If the GNU Affero General Public License doesn't fit your need,
|
34
|
-
# commercial licenses are available at <https://gettalong.at/hexapdf/>.
|
35
|
-
#++
|
36
|
-
|
37
|
-
module HexaPDF
|
38
|
-
module Filter
|
39
|
-
|
40
|
-
# The DCTDecode filter is currently only implemented as a pass-through filter, ie. the source
|
41
|
-
# gets passed on unmodified. This also means that the :ColorTransform parameter is not
|
42
|
-
# evaluated!
|
43
|
-
#
|
44
|
-
# See: HexaPDF::Filter, PDF1.7 s7.4.8
|
45
|
-
module DCTDecode
|
46
|
-
|
47
|
-
# See HexaPDF::Filter
|
48
|
-
def self.decoder(source, _ = nil)
|
49
|
-
source
|
50
|
-
end
|
51
|
-
|
52
|
-
# See HexaPDF::Filter
|
53
|
-
def self.encoder(source, _ = nil)
|
54
|
-
source
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
end
|