hexapdf 0.15.8 → 0.17.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hexapdf/cli/batch.rb +1 -1
- data/lib/hexapdf/cli/command.rb +10 -1
- data/lib/hexapdf/cli/files.rb +1 -1
- data/lib/hexapdf/cli/fonts.rb +145 -0
- data/lib/hexapdf/cli/form.rb +27 -26
- data/lib/hexapdf/cli/image2pdf.rb +1 -1
- data/lib/hexapdf/cli/images.rb +1 -10
- data/lib/hexapdf/cli/info.rb +1 -1
- data/lib/hexapdf/cli/inspect.rb +1 -1
- data/lib/hexapdf/cli/merge.rb +1 -1
- 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/cli.rb +3 -1
- data/lib/hexapdf/composer.rb +1 -1
- data/lib/hexapdf/configuration.rb +11 -2
- data/lib/hexapdf/content/canvas.rb +658 -167
- data/lib/hexapdf/content/color_space.rb +185 -3
- data/lib/hexapdf/content/graphic_object/arc.rb +111 -12
- 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/graphic_object.rb +1 -1
- data/lib/hexapdf/content/graphics_state.rb +1 -1
- data/lib/hexapdf/content/operator.rb +1 -1
- data/lib/hexapdf/content/parser.rb +1 -1
- data/lib/hexapdf/content/processor.rb +1 -1
- data/lib/hexapdf/content/transformation_matrix.rb +1 -1
- data/lib/hexapdf/content.rb +1 -1
- data/lib/hexapdf/data_dir.rb +1 -1
- data/lib/hexapdf/dictionary.rb +1 -1
- data/lib/hexapdf/dictionary_fields.rb +30 -4
- data/lib/hexapdf/document/files.rb +3 -3
- data/lib/hexapdf/document/fonts.rb +1 -1
- data/lib/hexapdf/document/images.rb +1 -1
- data/lib/hexapdf/document/pages.rb +1 -1
- data/lib/hexapdf/document.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 +1 -1
- 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 +1 -1
- data/lib/hexapdf/encryption/standard_security_handler.rb +1 -1
- data/lib/hexapdf/encryption.rb +1 -1
- data/lib/hexapdf/error.rb +1 -1
- data/lib/hexapdf/filter/ascii85_decode.rb +1 -1
- data/lib/hexapdf/filter/ascii_hex_decode.rb +1 -1
- data/lib/hexapdf/filter/crypt.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/pass_through.rb +1 -1
- data/lib/hexapdf/filter/predictor.rb +1 -1
- data/lib/hexapdf/filter/run_length_decode.rb +1 -1
- data/lib/hexapdf/filter.rb +1 -1
- data/lib/hexapdf/font/cmap/parser.rb +1 -1
- data/lib/hexapdf/font/cmap/writer.rb +1 -1
- data/lib/hexapdf/font/cmap.rb +1 -1
- data/lib/hexapdf/font/encoding/base.rb +1 -1
- data/lib/hexapdf/font/encoding/difference_encoding.rb +1 -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/encoding.rb +1 -1
- data/lib/hexapdf/font/invalid_glyph.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/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 +1 -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 +1 -1
- data/lib/hexapdf/font/true_type/table/post.rb +1 -1
- data/lib/hexapdf/font/true_type/table.rb +1 -1
- data/lib/hexapdf/font/true_type.rb +1 -1
- data/lib/hexapdf/font/true_type_wrapper.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.rb +1 -1
- data/lib/hexapdf/font/type1_wrapper.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/font_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 +1 -1
- data/lib/hexapdf/image_loader.rb +1 -1
- data/lib/hexapdf/importer.rb +1 -1
- data/lib/hexapdf/layout/box.rb +4 -2
- 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 +1 -1
- data/lib/hexapdf/layout/numeric_refinements.rb +1 -1
- data/lib/hexapdf/layout/style.rb +40 -2
- 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 +1 -1
- data/lib/hexapdf/layout/width_from_polygon.rb +2 -2
- data/lib/hexapdf/layout.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 +1 -1
- data/lib/hexapdf/parser.rb +2 -2
- data/lib/hexapdf/pdf_array.rb +1 -1
- data/lib/hexapdf/rectangle.rb +1 -1
- data/lib/hexapdf/reference.rb +1 -1
- data/lib/hexapdf/revision.rb +1 -1
- data/lib/hexapdf/revisions.rb +1 -1
- data/lib/hexapdf/serializer.rb +1 -1
- data/lib/hexapdf/stream.rb +1 -1
- data/lib/hexapdf/task/dereference.rb +1 -1
- data/lib/hexapdf/task/optimize.rb +1 -1
- data/lib/hexapdf/task.rb +1 -1
- data/lib/hexapdf/tokenizer.rb +1 -1
- data/lib/hexapdf/type/acro_form/appearance_generator.rb +14 -7
- data/lib/hexapdf/type/acro_form/button_field.rb +53 -28
- data/lib/hexapdf/type/acro_form/choice_field.rb +1 -1
- data/lib/hexapdf/type/acro_form/field.rb +21 -2
- data/lib/hexapdf/type/acro_form/form.rb +48 -29
- data/lib/hexapdf/type/acro_form/text_field.rb +2 -2
- data/lib/hexapdf/type/acro_form/variable_text_field.rb +17 -9
- data/lib/hexapdf/type/acro_form.rb +1 -1
- data/lib/hexapdf/type/action.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 +1 -1
- data/lib/hexapdf/type/actions.rb +1 -1
- data/lib/hexapdf/type/annotation.rb +1 -1
- data/lib/hexapdf/type/annotations/link.rb +1 -1
- 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 +2 -2
- data/lib/hexapdf/type/annotations.rb +1 -1
- data/lib/hexapdf/type/catalog.rb +1 -1
- 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 +1 -1
- data/lib/hexapdf/type/font.rb +1 -1
- data/lib/hexapdf/type/font_descriptor.rb +1 -1
- data/lib/hexapdf/type/font_simple.rb +1 -1
- data/lib/hexapdf/type/font_true_type.rb +1 -1
- data/lib/hexapdf/type/font_type0.rb +1 -1
- data/lib/hexapdf/type/font_type1.rb +1 -1
- data/lib/hexapdf/type/font_type3.rb +1 -1
- data/lib/hexapdf/type/form.rb +1 -1
- 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 +1 -1
- 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 +15 -1
- data/lib/hexapdf/type/page_tree_node.rb +1 -1
- data/lib/hexapdf/type/resources.rb +1 -1
- data/lib/hexapdf/type/trailer.rb +1 -1
- data/lib/hexapdf/type/viewer_preferences.rb +1 -1
- data/lib/hexapdf/type/xref_stream.rb +1 -1
- data/lib/hexapdf/type.rb +1 -1
- data/lib/hexapdf/utils/bit_field.rb +1 -1
- 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 +1 -1
- data/lib/hexapdf/version.rb +2 -2
- data/lib/hexapdf/writer.rb +1 -1
- data/lib/hexapdf/xref_section.rb +1 -1
- data/lib/hexapdf.rb +1 -1
- metadata +5 -264
- data/CHANGELOG.md +0 -954
- data/LICENSE +0 -29
- data/README.md +0 -120
- data/Rakefile +0 -108
- data/agpl-3.0.txt +0 -661
- data/examples/001-hello_world.rb +0 -16
- data/examples/002-graphics.rb +0 -275
- data/examples/003-arcs.rb +0 -50
- data/examples/004-optimizing.rb +0 -23
- data/examples/005-merging.rb +0 -27
- data/examples/006-standard_pdf_fonts.rb +0 -73
- data/examples/007-truetype.rb +0 -42
- data/examples/008-show_char_bboxes.rb +0 -55
- data/examples/009-text_layouter_alignment.rb +0 -47
- data/examples/010-text_layouter_inline_boxes.rb +0 -64
- data/examples/011-text_layouter_line_wrapping.rb +0 -57
- data/examples/012-text_layouter_styling.rb +0 -122
- data/examples/013-text_layouter_shapes.rb +0 -176
- data/examples/014-text_in_polygon.rb +0 -60
- data/examples/015-boxes.rb +0 -76
- data/examples/016-frame_automatic_box_placement.rb +0 -90
- data/examples/017-frame_text_flow.rb +0 -60
- data/examples/018-composer.rb +0 -44
- data/examples/019-acro_form.rb +0 -88
- data/examples/emoji-smile.png +0 -0
- data/examples/emoji-wink.png +0 -0
- data/examples/machupicchu.jpg +0 -0
- data/test/data/aes-test-vectors/CBCGFSbox-128-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCGFSbox-128-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCGFSbox-192-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCGFSbox-192-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCGFSbox-256-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCGFSbox-256-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCKeySbox-128-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCKeySbox-128-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCKeySbox-192-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCKeySbox-192-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCKeySbox-256-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCKeySbox-256-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarKey-128-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarKey-128-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarKey-192-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarKey-192-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarKey-256-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarKey-256-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarTxt-128-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarTxt-128-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarTxt-192-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarTxt-192-encrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarTxt-256-decrypt.data.gz +0 -0
- data/test/data/aes-test-vectors/CBCVarTxt-256-encrypt.data.gz +0 -0
- data/test/data/fonts/Ubuntu-Title.ttf +0 -0
- data/test/data/images/cmyk.jpg +0 -0
- data/test/data/images/fillbytes.jpg +0 -0
- data/test/data/images/gray.jpg +0 -0
- data/test/data/images/greyscale-1bit.png +0 -0
- data/test/data/images/greyscale-2bit.png +0 -0
- data/test/data/images/greyscale-4bit.png +0 -0
- data/test/data/images/greyscale-8bit.png +0 -0
- data/test/data/images/greyscale-alpha-8bit.png +0 -0
- data/test/data/images/greyscale-trns-8bit.png +0 -0
- data/test/data/images/greyscale-with-gamma1.0.png +0 -0
- data/test/data/images/greyscale-with-gamma1.5.png +0 -0
- data/test/data/images/indexed-1bit.png +0 -0
- data/test/data/images/indexed-2bit.png +0 -0
- data/test/data/images/indexed-4bit.png +0 -0
- data/test/data/images/indexed-8bit.png +0 -0
- data/test/data/images/indexed-alpha-4bit.png +0 -0
- data/test/data/images/indexed-alpha-8bit.png +0 -0
- data/test/data/images/rgb.jpg +0 -0
- data/test/data/images/truecolour-8bit.png +0 -0
- data/test/data/images/truecolour-alpha-8bit.png +0 -0
- data/test/data/images/truecolour-gama-chrm-8bit.png +0 -0
- data/test/data/images/truecolour-srgb-8bit.png +0 -0
- data/test/data/images/ycck.jpg +0 -0
- data/test/data/minimal.pdf +0 -44
- data/test/data/standard-security-handler/README +0 -9
- data/test/data/standard-security-handler/bothpwd-aes-128bit-V4.pdf +0 -44
- data/test/data/standard-security-handler/bothpwd-aes-256bit-V5.pdf +0 -0
- data/test/data/standard-security-handler/bothpwd-arc4-128bit-V2.pdf +0 -43
- data/test/data/standard-security-handler/bothpwd-arc4-128bit-V4.pdf +0 -43
- data/test/data/standard-security-handler/bothpwd-arc4-40bit-V1.pdf +0 -0
- data/test/data/standard-security-handler/nopwd-aes-128bit-V4.pdf +0 -43
- data/test/data/standard-security-handler/nopwd-aes-256bit-V5.pdf +0 -0
- data/test/data/standard-security-handler/nopwd-arc4-128bit-V2.pdf +0 -43
- data/test/data/standard-security-handler/nopwd-arc4-128bit-V4.pdf +0 -43
- data/test/data/standard-security-handler/nopwd-arc4-40bit-V1.pdf +0 -43
- data/test/data/standard-security-handler/ownerpwd-aes-128bit-V4.pdf +0 -0
- data/test/data/standard-security-handler/ownerpwd-aes-256bit-V5.pdf +0 -43
- data/test/data/standard-security-handler/ownerpwd-arc4-128bit-V2.pdf +0 -43
- data/test/data/standard-security-handler/ownerpwd-arc4-128bit-V4.pdf +0 -43
- data/test/data/standard-security-handler/ownerpwd-arc4-40bit-V1.pdf +0 -43
- data/test/data/standard-security-handler/userpwd-aes-128bit-V4.pdf +0 -43
- data/test/data/standard-security-handler/userpwd-aes-256bit-V5.pdf +0 -43
- data/test/data/standard-security-handler/userpwd-arc4-128bit-V2.pdf +0 -0
- data/test/data/standard-security-handler/userpwd-arc4-128bit-V4.pdf +0 -0
- data/test/data/standard-security-handler/userpwd-arc4-40bit-V1.pdf +0 -43
- data/test/hexapdf/common_tokenizer_tests.rb +0 -236
- data/test/hexapdf/content/common.rb +0 -39
- data/test/hexapdf/content/graphic_object/test_arc.rb +0 -93
- data/test/hexapdf/content/graphic_object/test_endpoint_arc.rb +0 -90
- data/test/hexapdf/content/graphic_object/test_geom2d.rb +0 -79
- data/test/hexapdf/content/graphic_object/test_solid_arc.rb +0 -86
- data/test/hexapdf/content/test_canvas.rb +0 -1216
- data/test/hexapdf/content/test_color_space.rb +0 -164
- data/test/hexapdf/content/test_graphics_state.rb +0 -151
- data/test/hexapdf/content/test_operator.rb +0 -619
- data/test/hexapdf/content/test_parser.rb +0 -99
- data/test/hexapdf/content/test_processor.rb +0 -163
- data/test/hexapdf/content/test_transformation_matrix.rb +0 -64
- data/test/hexapdf/document/test_files.rb +0 -72
- data/test/hexapdf/document/test_fonts.rb +0 -60
- data/test/hexapdf/document/test_images.rb +0 -72
- data/test/hexapdf/document/test_pages.rb +0 -130
- data/test/hexapdf/encryption/common.rb +0 -87
- data/test/hexapdf/encryption/test_aes.rb +0 -129
- data/test/hexapdf/encryption/test_arc4.rb +0 -39
- data/test/hexapdf/encryption/test_fast_aes.rb +0 -17
- data/test/hexapdf/encryption/test_fast_arc4.rb +0 -12
- data/test/hexapdf/encryption/test_identity.rb +0 -21
- data/test/hexapdf/encryption/test_ruby_aes.rb +0 -23
- data/test/hexapdf/encryption/test_ruby_arc4.rb +0 -20
- data/test/hexapdf/encryption/test_security_handler.rb +0 -380
- data/test/hexapdf/encryption/test_standard_security_handler.rb +0 -322
- data/test/hexapdf/filter/common.rb +0 -53
- data/test/hexapdf/filter/test_ascii85_decode.rb +0 -59
- data/test/hexapdf/filter/test_ascii_hex_decode.rb +0 -38
- data/test/hexapdf/filter/test_crypt.rb +0 -21
- data/test/hexapdf/filter/test_encryption.rb +0 -24
- data/test/hexapdf/filter/test_flate_decode.rb +0 -44
- data/test/hexapdf/filter/test_lzw_decode.rb +0 -52
- data/test/hexapdf/filter/test_predictor.rb +0 -219
- data/test/hexapdf/filter/test_run_length_decode.rb +0 -32
- data/test/hexapdf/font/cmap/test_parser.rb +0 -102
- data/test/hexapdf/font/cmap/test_writer.rb +0 -66
- data/test/hexapdf/font/encoding/test_base.rb +0 -45
- data/test/hexapdf/font/encoding/test_difference_encoding.rb +0 -29
- data/test/hexapdf/font/encoding/test_glyph_list.rb +0 -59
- data/test/hexapdf/font/encoding/test_zapf_dingbats_encoding.rb +0 -16
- data/test/hexapdf/font/test_cmap.rb +0 -104
- data/test/hexapdf/font/test_encoding.rb +0 -27
- data/test/hexapdf/font/test_invalid_glyph.rb +0 -34
- data/test/hexapdf/font/test_true_type_wrapper.rb +0 -186
- data/test/hexapdf/font/test_type1_wrapper.rb +0 -107
- data/test/hexapdf/font/true_type/common.rb +0 -17
- data/test/hexapdf/font/true_type/table/common.rb +0 -27
- data/test/hexapdf/font/true_type/table/test_cmap.rb +0 -47
- data/test/hexapdf/font/true_type/table/test_cmap_subtable.rb +0 -141
- data/test/hexapdf/font/true_type/table/test_directory.rb +0 -30
- data/test/hexapdf/font/true_type/table/test_glyf.rb +0 -58
- data/test/hexapdf/font/true_type/table/test_head.rb +0 -56
- data/test/hexapdf/font/true_type/table/test_hhea.rb +0 -26
- data/test/hexapdf/font/true_type/table/test_hmtx.rb +0 -30
- data/test/hexapdf/font/true_type/table/test_kern.rb +0 -61
- data/test/hexapdf/font/true_type/table/test_loca.rb +0 -33
- data/test/hexapdf/font/true_type/table/test_maxp.rb +0 -50
- data/test/hexapdf/font/true_type/table/test_name.rb +0 -76
- data/test/hexapdf/font/true_type/table/test_os2.rb +0 -55
- data/test/hexapdf/font/true_type/table/test_post.rb +0 -78
- data/test/hexapdf/font/true_type/test_builder.rb +0 -42
- data/test/hexapdf/font/true_type/test_font.rb +0 -116
- data/test/hexapdf/font/true_type/test_optimizer.rb +0 -26
- data/test/hexapdf/font/true_type/test_subsetter.rb +0 -73
- data/test/hexapdf/font/true_type/test_table.rb +0 -48
- data/test/hexapdf/font/type1/common.rb +0 -6
- data/test/hexapdf/font/type1/test_afm_parser.rb +0 -65
- data/test/hexapdf/font/type1/test_font.rb +0 -104
- data/test/hexapdf/font/type1/test_font_metrics.rb +0 -22
- data/test/hexapdf/font/type1/test_pfb_parser.rb +0 -37
- data/test/hexapdf/font_loader/test_from_configuration.rb +0 -43
- data/test/hexapdf/font_loader/test_from_file.rb +0 -36
- data/test/hexapdf/font_loader/test_standard14.rb +0 -33
- data/test/hexapdf/image_loader/test_jpeg.rb +0 -93
- data/test/hexapdf/image_loader/test_pdf.rb +0 -47
- data/test/hexapdf/image_loader/test_png.rb +0 -259
- data/test/hexapdf/layout/test_box.rb +0 -152
- data/test/hexapdf/layout/test_frame.rb +0 -350
- data/test/hexapdf/layout/test_image_box.rb +0 -73
- data/test/hexapdf/layout/test_inline_box.rb +0 -71
- data/test/hexapdf/layout/test_line.rb +0 -206
- data/test/hexapdf/layout/test_style.rb +0 -779
- data/test/hexapdf/layout/test_text_box.rb +0 -140
- data/test/hexapdf/layout/test_text_fragment.rb +0 -375
- data/test/hexapdf/layout/test_text_layouter.rb +0 -758
- data/test/hexapdf/layout/test_text_shaper.rb +0 -62
- data/test/hexapdf/layout/test_width_from_polygon.rb +0 -108
- data/test/hexapdf/task/test_dereference.rb +0 -51
- data/test/hexapdf/task/test_optimize.rb +0 -162
- data/test/hexapdf/test_composer.rb +0 -258
- data/test/hexapdf/test_configuration.rb +0 -93
- data/test/hexapdf/test_data_dir.rb +0 -32
- data/test/hexapdf/test_dictionary.rb +0 -340
- data/test/hexapdf/test_dictionary_fields.rb +0 -245
- data/test/hexapdf/test_document.rb +0 -641
- data/test/hexapdf/test_filter.rb +0 -100
- data/test/hexapdf/test_importer.rb +0 -106
- data/test/hexapdf/test_object.rb +0 -258
- data/test/hexapdf/test_parser.rb +0 -637
- data/test/hexapdf/test_pdf_array.rb +0 -169
- data/test/hexapdf/test_rectangle.rb +0 -73
- data/test/hexapdf/test_reference.rb +0 -50
- data/test/hexapdf/test_revision.rb +0 -188
- data/test/hexapdf/test_revisions.rb +0 -196
- data/test/hexapdf/test_serializer.rb +0 -195
- data/test/hexapdf/test_stream.rb +0 -274
- data/test/hexapdf/test_tokenizer.rb +0 -80
- data/test/hexapdf/test_type.rb +0 -18
- data/test/hexapdf/test_writer.rb +0 -140
- data/test/hexapdf/test_xref_section.rb +0 -61
- data/test/hexapdf/type/acro_form/test_appearance_generator.rb +0 -794
- data/test/hexapdf/type/acro_form/test_button_field.rb +0 -302
- data/test/hexapdf/type/acro_form/test_choice_field.rb +0 -220
- data/test/hexapdf/type/acro_form/test_field.rb +0 -247
- data/test/hexapdf/type/acro_form/test_form.rb +0 -353
- data/test/hexapdf/type/acro_form/test_signature_field.rb +0 -38
- data/test/hexapdf/type/acro_form/test_text_field.rb +0 -195
- data/test/hexapdf/type/acro_form/test_variable_text_field.rb +0 -77
- data/test/hexapdf/type/actions/test_launch.rb +0 -24
- data/test/hexapdf/type/actions/test_uri.rb +0 -23
- data/test/hexapdf/type/annotations/test_markup_annotation.rb +0 -22
- data/test/hexapdf/type/annotations/test_text.rb +0 -34
- data/test/hexapdf/type/annotations/test_widget.rb +0 -225
- data/test/hexapdf/type/test_annotation.rb +0 -97
- data/test/hexapdf/type/test_catalog.rb +0 -48
- data/test/hexapdf/type/test_cid_font.rb +0 -61
- data/test/hexapdf/type/test_file_specification.rb +0 -141
- data/test/hexapdf/type/test_font.rb +0 -67
- data/test/hexapdf/type/test_font_descriptor.rb +0 -61
- data/test/hexapdf/type/test_font_simple.rb +0 -176
- data/test/hexapdf/type/test_font_true_type.rb +0 -31
- data/test/hexapdf/type/test_font_type0.rb +0 -120
- data/test/hexapdf/type/test_font_type1.rb +0 -142
- data/test/hexapdf/type/test_font_type3.rb +0 -26
- data/test/hexapdf/type/test_form.rb +0 -120
- data/test/hexapdf/type/test_image.rb +0 -261
- data/test/hexapdf/type/test_info.rb +0 -9
- data/test/hexapdf/type/test_object_stream.rb +0 -117
- data/test/hexapdf/type/test_page.rb +0 -587
- data/test/hexapdf/type/test_page_tree_node.rb +0 -315
- data/test/hexapdf/type/test_resources.rb +0 -209
- data/test/hexapdf/type/test_trailer.rb +0 -116
- data/test/hexapdf/type/test_xref_stream.rb +0 -143
- data/test/hexapdf/utils/test_bit_field.rb +0 -63
- data/test/hexapdf/utils/test_bit_stream.rb +0 -69
- data/test/hexapdf/utils/test_graphics_helpers.rb +0 -37
- data/test/hexapdf/utils/test_lru_cache.rb +0 -22
- data/test/hexapdf/utils/test_object_hash.rb +0 -120
- data/test/hexapdf/utils/test_pdf_doc_encoding.rb +0 -18
- data/test/hexapdf/utils/test_sorted_tree_node.rb +0 -239
- data/test/test_helper.rb +0 -58
@@ -1,247 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
require 'hexapdf/document'
|
5
|
-
require 'hexapdf/type/acro_form/field'
|
6
|
-
|
7
|
-
describe HexaPDF::Type::AcroForm::Field::HashRefinement do
|
8
|
-
using HexaPDF::Type::AcroForm::Field::HashRefinement
|
9
|
-
|
10
|
-
it "returns self when calling value" do
|
11
|
-
x = {}
|
12
|
-
assert_same(x, x.value)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe HexaPDF::Type::AcroForm::Field do
|
17
|
-
before do
|
18
|
-
@doc = HexaPDF::Document.new
|
19
|
-
@field = @doc.add({}, type: :XXAcroFormField)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "must always be an indirect object" do
|
23
|
-
assert(@field.must_be_indirect?)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "resolves inherited field values" do
|
27
|
-
assert_nil(@field[:FT])
|
28
|
-
|
29
|
-
@field[:Parent] = {FT: :Tx}
|
30
|
-
assert_equal(:Tx, @field[:FT])
|
31
|
-
|
32
|
-
@field[:FT] = :Ch
|
33
|
-
assert_equal(:Ch, @field[:FT])
|
34
|
-
end
|
35
|
-
|
36
|
-
it "has convenience methods for accessing the field flags" do
|
37
|
-
assert_equal([], @field.flags)
|
38
|
-
refute(@field.flagged?(:required))
|
39
|
-
@field.flag(:required, 2)
|
40
|
-
assert(@field.flagged?(2))
|
41
|
-
assert_equal(6, @field[:Ff])
|
42
|
-
end
|
43
|
-
|
44
|
-
it "returns the field type" do
|
45
|
-
assert_nil(@field.field_type)
|
46
|
-
|
47
|
-
@field[:FT] = :Tx
|
48
|
-
assert_equal(:Tx, @field.field_type)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "returns the concrete field type" do
|
52
|
-
assert_nil(@field.concrete_field_type)
|
53
|
-
|
54
|
-
@field[:FT] = :Tx
|
55
|
-
assert_equal(:text_field, @field.concrete_field_type)
|
56
|
-
@field[:FT] = :Btn
|
57
|
-
assert_equal(:button_field, @field.concrete_field_type)
|
58
|
-
@field[:FT] = :Ch
|
59
|
-
assert_equal(:choice_field, @field.concrete_field_type)
|
60
|
-
@field[:FT] = :Sig
|
61
|
-
assert_equal(:signature_field, @field.concrete_field_type)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "returns the field name" do
|
65
|
-
assert_nil(@field.field_name)
|
66
|
-
@field[:T] = 'test'
|
67
|
-
assert_equal('test', @field.field_name)
|
68
|
-
end
|
69
|
-
|
70
|
-
it "returns the full name of the field" do
|
71
|
-
assert_nil(@field.full_field_name)
|
72
|
-
|
73
|
-
@field[:T] = "Test"
|
74
|
-
assert_equal("Test", @field.full_field_name)
|
75
|
-
|
76
|
-
@field[:Parent] = {}
|
77
|
-
assert_equal("Test", @field.full_field_name)
|
78
|
-
|
79
|
-
@field[:Parent] = {T: 'Parent'}
|
80
|
-
assert_equal("Parent.Test", @field.full_field_name)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "allows setting and retrieving the alternate field name" do
|
84
|
-
@field.alternate_field_name = 'Alternate'
|
85
|
-
assert_equal('Alternate', @field.alternate_field_name)
|
86
|
-
assert_equal('Alternate', @field[:TU])
|
87
|
-
end
|
88
|
-
|
89
|
-
it "returns whether the field is a terminal field" do
|
90
|
-
assert(@field.terminal_field?)
|
91
|
-
|
92
|
-
@field[:Kids] = []
|
93
|
-
assert(@field.terminal_field?)
|
94
|
-
|
95
|
-
@field[:Kids] = [{Subtype: :Widget}]
|
96
|
-
assert(@field.terminal_field?)
|
97
|
-
|
98
|
-
@field[:Kids] = [{FT: :Tx, T: 'name'}]
|
99
|
-
refute(@field.terminal_field?)
|
100
|
-
end
|
101
|
-
|
102
|
-
it "can check whether a widget is embedded in the field" do
|
103
|
-
refute(@field.embedded_widget?)
|
104
|
-
@field[:Subtype] = :Wdiget
|
105
|
-
assert(@field.embedded_widget?)
|
106
|
-
end
|
107
|
-
|
108
|
-
describe "each_widget" do
|
109
|
-
it "yields a wrapped instance of self if a single widget is embedded" do
|
110
|
-
@field[:Subtype] = :Widget
|
111
|
-
@field[:Rect] = [0, 0, 0, 0]
|
112
|
-
widgets = @field.each_widget.to_a
|
113
|
-
assert_kind_of(HexaPDF::Type::Annotations::Widget, *widgets)
|
114
|
-
assert_same(@field.data, widgets.first.data)
|
115
|
-
end
|
116
|
-
|
117
|
-
it "yields all widgets in the /Kids array" do
|
118
|
-
@field[:Kids] = [{Subtype: :Widget, Rect: [0, 0, 0, 0], X: 1}]
|
119
|
-
widgets = @field.each_widget.to_a
|
120
|
-
assert_kind_of(HexaPDF::Type::Annotations::Widget, *widgets)
|
121
|
-
assert_equal(1, widgets.first[:X])
|
122
|
-
end
|
123
|
-
|
124
|
-
it "yields nothing if no widgets are defined" do
|
125
|
-
assert_equal([], @field.each_widget.to_a)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
describe "create_widget" do
|
130
|
-
before do
|
131
|
-
@page = @doc.pages.add
|
132
|
-
end
|
133
|
-
|
134
|
-
it "sets all required widget keys" do
|
135
|
-
widget = @field.create_widget(@page)
|
136
|
-
assert_equal(:Annot, widget.type)
|
137
|
-
assert_equal(:Widget, widget[:Subtype])
|
138
|
-
assert_equal([0, 0, 0, 0], widget[:Rect])
|
139
|
-
end
|
140
|
-
|
141
|
-
it "sets the additionally specified keys on the widget" do
|
142
|
-
widget = @field.create_widget(@page, X: 5)
|
143
|
-
assert_equal(5, widget[:X])
|
144
|
-
end
|
145
|
-
|
146
|
-
it "adds the new widget to the given page's annotations" do
|
147
|
-
widget = @field.create_widget(@page)
|
148
|
-
assert_equal([widget], @page[:Annots].value)
|
149
|
-
end
|
150
|
-
|
151
|
-
it "populates the field with the widget data if there is no widget" do
|
152
|
-
widget = @field.create_widget(@page)
|
153
|
-
assert_same(widget.data, @field.data)
|
154
|
-
assert_nil(@field[:Kids])
|
155
|
-
end
|
156
|
-
|
157
|
-
it "creates a standalone widget if embedding is not allowed" do
|
158
|
-
refute_same(@field.data, @field.create_widget(@page, allow_embedded: false).data)
|
159
|
-
end
|
160
|
-
|
161
|
-
it "extracts an embedded widget into a standalone object if necessary" do
|
162
|
-
widget1 = @field.create_widget(@page, Rect: [1, 2, 3, 4])
|
163
|
-
widget2 = @field.create_widget(@doc.pages.add, Rect: [2, 1, 4, 3])
|
164
|
-
kids = @field[:Kids]
|
165
|
-
|
166
|
-
assert_equal(2, kids.length)
|
167
|
-
refute_same(widget1, kids[0])
|
168
|
-
assert_same(widget2, kids[1])
|
169
|
-
assert_nil(@field[:Rect])
|
170
|
-
assert_equal({Rect: [1, 2, 3, 4], Type: :Annot, Subtype: :Widget, Parent: @field},
|
171
|
-
kids[0].value)
|
172
|
-
assert_equal([2, 1, 4, 3], kids[1][:Rect].value)
|
173
|
-
|
174
|
-
refute_equal([widget1], @page[:Annots].value)
|
175
|
-
assert_equal([kids[0]], @page[:Annots].value)
|
176
|
-
end
|
177
|
-
|
178
|
-
it "fails if called on a non-terminal field" do
|
179
|
-
@field[:Kids] = [{T: 'name'}]
|
180
|
-
assert_raises(HexaPDF::Error) { @field.create_widget(@page) }
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
describe "delete_widget" do
|
185
|
-
before do
|
186
|
-
@page = @doc.pages.add
|
187
|
-
end
|
188
|
-
|
189
|
-
it "does nothing if the provided widget doesn't belong to the field" do
|
190
|
-
wrong_widget = @doc.add({Subtype: :Widget})
|
191
|
-
|
192
|
-
@field.create_widget(@page)
|
193
|
-
@field.delete_widget(wrong_widget)
|
194
|
-
assert_equal(:Widget, @field[:Subtype])
|
195
|
-
|
196
|
-
@field.create_widget(@page)
|
197
|
-
@field.delete_widget(wrong_widget)
|
198
|
-
assert_equal(2, @field[:Kids].size)
|
199
|
-
end
|
200
|
-
|
201
|
-
it "deletes the widget if it is embedded" do
|
202
|
-
widget = @field.create_widget(@page)
|
203
|
-
@doc.revisions.current.update(widget)
|
204
|
-
assert_same(widget, @doc.object(widget))
|
205
|
-
refute_same(@field, @doc.object(@field))
|
206
|
-
|
207
|
-
@field.delete_widget(widget)
|
208
|
-
refute(@field.key?(:Subtype))
|
209
|
-
assert(@page[:Annots].empty?)
|
210
|
-
assert_same(@field, @doc.object(@field))
|
211
|
-
end
|
212
|
-
|
213
|
-
it "deletes the widget if it is not embedded" do
|
214
|
-
@field.create_widget(@page)
|
215
|
-
widget2 = @field.create_widget(@page)
|
216
|
-
@field.delete_widget(widget2)
|
217
|
-
assert_equal(1, @field[:Kids].size)
|
218
|
-
assert_equal(@field[:Kids].value, @page[:Annots].value)
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
describe "perform_validation" do
|
223
|
-
before do
|
224
|
-
@field[:FT] = :Tx
|
225
|
-
end
|
226
|
-
|
227
|
-
it "requires the /FT key to be present for terminal fields" do
|
228
|
-
assert(@field.validate)
|
229
|
-
|
230
|
-
@field.delete(:FT)
|
231
|
-
refute(@field.validate)
|
232
|
-
|
233
|
-
@field[:Kids] = [{T: 'name'}]
|
234
|
-
assert(@field.validate)
|
235
|
-
end
|
236
|
-
|
237
|
-
it "doesn't allow periods in partial field names" do
|
238
|
-
assert(@field.validate)
|
239
|
-
|
240
|
-
@field[:T] = "Test"
|
241
|
-
assert(@field.validate)
|
242
|
-
|
243
|
-
@field[:T] = "Te.st"
|
244
|
-
refute(@field.validate)
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|
@@ -1,353 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
require 'hexapdf/document'
|
5
|
-
require 'hexapdf/type/acro_form/form'
|
6
|
-
|
7
|
-
describe HexaPDF::Type::AcroForm::Form do
|
8
|
-
before do
|
9
|
-
@doc = HexaPDF::Document.new
|
10
|
-
@acro_form = @doc.add({Fields: []}, type: :XXAcroForm)
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "signature flags" do
|
14
|
-
before do
|
15
|
-
@acro_form[:SigFlags] = 3
|
16
|
-
end
|
17
|
-
|
18
|
-
it "returns all signature flags" do
|
19
|
-
assert_equal([:signatures_exist, :append_only], @acro_form.signature_flags)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "returns true if the given flag is set" do
|
23
|
-
assert(@acro_form.signature_flag?(:signatures_exist))
|
24
|
-
end
|
25
|
-
|
26
|
-
it "raises an error if an unknown flag name is provided" do
|
27
|
-
assert_raises(ArgumentError) { @acro_form.signature_flag?(:non_exist) }
|
28
|
-
end
|
29
|
-
|
30
|
-
it "sets the given flag bits" do
|
31
|
-
@acro_form[:SigFlags] = 0
|
32
|
-
@acro_form.signature_flag(:append_only)
|
33
|
-
assert_equal([:append_only], @acro_form.signature_flags)
|
34
|
-
@acro_form.signature_flag(:signatures_exist, clear_existing: true)
|
35
|
-
assert_equal([:signatures_exist], @acro_form.signature_flags)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it "returns the root fields" do
|
40
|
-
assert_equal([], @acro_form.root_fields.value)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "finds the root fields" do
|
44
|
-
@doc.pages.add[:Annots] = [{FT: :Tx}, {FT: :Tx2, Parent: {FT: :Tx3}}]
|
45
|
-
@doc.pages.add[:Annots] = [{Subtype: :Widget}]
|
46
|
-
@doc.pages.add
|
47
|
-
|
48
|
-
result = [{FT: :Tx}, {FT: :Tx3}]
|
49
|
-
root_fields = @acro_form.find_root_fields
|
50
|
-
assert_equal(result, root_fields.map(&:value))
|
51
|
-
assert_kind_of(HexaPDF::Type::AcroForm::TextField, root_fields[0])
|
52
|
-
assert_equal([], @acro_form[:Fields].value)
|
53
|
-
|
54
|
-
@acro_form.find_root_fields!
|
55
|
-
assert_equal(result, @acro_form[:Fields].value.map(&:value))
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "each_field" do
|
59
|
-
before do
|
60
|
-
@acro_form[:Fields] = [
|
61
|
-
{T: :Tx1},
|
62
|
-
{T: :Tx2, Kids: [{Subtype: :Widget}]},
|
63
|
-
{T: :Tx3, FT: :Tx, Kids: [{T: :Tx4}, {T: :Tx5, Kids: [{T: :Tx6}]}]},
|
64
|
-
]
|
65
|
-
@acro_form[:Fields][2][:Kids][0][:Parent] = @acro_form[:Fields][2]
|
66
|
-
@acro_form[:Fields][2][:Kids][1][:Parent] = @acro_form[:Fields][2]
|
67
|
-
@acro_form[:Fields][2][:Kids][1][:Kids][0][:Parent] = @acro_form[:Fields][2][:Kids][1]
|
68
|
-
end
|
69
|
-
|
70
|
-
it "iterates over all terminal fields" do
|
71
|
-
assert_equal([:Tx1, :Tx2, :Tx4, :Tx6], @acro_form.each_field.map {|h| h[:T] })
|
72
|
-
end
|
73
|
-
|
74
|
-
it "iterates over all fields" do
|
75
|
-
assert_equal([:Tx1, :Tx2, :Tx3, :Tx4, :Tx5, :Tx6],
|
76
|
-
@acro_form.each_field(terminal_only: false).map {|h| h[:T] })
|
77
|
-
end
|
78
|
-
|
79
|
-
it "converts the fields into their proper types if possible" do
|
80
|
-
assert_kind_of(HexaPDF::Type::AcroForm::TextField, @acro_form.each_field.to_a.last)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe "field_by_name" do
|
85
|
-
before do
|
86
|
-
@acro_form[:Fields] = [
|
87
|
-
{T: "root only", Kids: [{Subtype: :Widget}]},
|
88
|
-
{T: "children", Kids: [{T: "child", FT: :Btn}, {T: "sub", Kids: [{T: "child"}]}]},
|
89
|
-
]
|
90
|
-
end
|
91
|
-
|
92
|
-
it "works for root fields" do
|
93
|
-
assert(@acro_form.field_by_name("root only"))
|
94
|
-
end
|
95
|
-
|
96
|
-
it "works for 1st level children" do
|
97
|
-
assert(@acro_form.field_by_name("children.child"))
|
98
|
-
end
|
99
|
-
|
100
|
-
it "works for children on any level" do
|
101
|
-
assert(@acro_form.field_by_name("children.sub.child"))
|
102
|
-
end
|
103
|
-
|
104
|
-
it "returns nil for unknown fields" do
|
105
|
-
assert_nil(@acro_form.field_by_name("non root field"))
|
106
|
-
assert_nil(@acro_form.field_by_name("root only.no child"))
|
107
|
-
assert_nil(@acro_form.field_by_name("root only.no"))
|
108
|
-
assert_nil(@acro_form.field_by_name("children.no child"))
|
109
|
-
assert_nil(@acro_form.field_by_name("children.sub.no child"))
|
110
|
-
end
|
111
|
-
|
112
|
-
it "returns the correct field class" do
|
113
|
-
assert_kind_of(HexaPDF::Type::AcroForm::ButtonField, @acro_form.field_by_name('children.child'))
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe "create fields" do
|
118
|
-
before do
|
119
|
-
@acro_form = @doc.acro_form(create: true)
|
120
|
-
end
|
121
|
-
|
122
|
-
describe "handles the general case" do
|
123
|
-
it "works for names with a dot" do
|
124
|
-
@acro_form[:Fields] = [{T: "root"}]
|
125
|
-
field = @acro_form.create_text_field("root.field")
|
126
|
-
assert_equal('root.field', field.full_field_name)
|
127
|
-
assert_equal([field], @acro_form[:Fields][0][:Kids])
|
128
|
-
end
|
129
|
-
|
130
|
-
it "works for names without a dot" do
|
131
|
-
field = @acro_form.create_text_field("field")
|
132
|
-
assert_equal('field', field.full_field_name)
|
133
|
-
assert([field], @acro_form[:Fields])
|
134
|
-
end
|
135
|
-
|
136
|
-
it "fails if the parent field is not found" do
|
137
|
-
assert_raises(HexaPDF::Error) { @acro_form.create_text_field("root.field") }
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def applies_variable_text_properties(method, **args)
|
142
|
-
field = @acro_form.send(method, "field", **args, font: 'Times')
|
143
|
-
font_name, font_size = field.parse_default_appearance_string
|
144
|
-
assert_equal(:'Times-Roman', @acro_form.default_resources.font(font_name)[:BaseFont])
|
145
|
-
assert_equal(0, font_size)
|
146
|
-
|
147
|
-
field = @acro_form.send(method, "field", **args, font_size: 10)
|
148
|
-
font_name, font_size = field.parse_default_appearance_string
|
149
|
-
assert_equal(:Helvetica, @acro_form.default_resources.font(font_name)[:BaseFont])
|
150
|
-
assert_equal(10, font_size)
|
151
|
-
|
152
|
-
field = @acro_form.send(method, "field", **args, font: 'Courier', font_size: 10, align: :center)
|
153
|
-
font_name, font_size = field.parse_default_appearance_string
|
154
|
-
assert_equal(:Courier, @acro_form.default_resources.font(font_name)[:BaseFont])
|
155
|
-
assert_equal(10, font_size)
|
156
|
-
assert_equal(:center, field.text_alignment)
|
157
|
-
end
|
158
|
-
|
159
|
-
it "creates a text field" do
|
160
|
-
field = @acro_form.create_text_field("field")
|
161
|
-
assert_equal(:Tx, field.field_type)
|
162
|
-
applies_variable_text_properties(:create_text_field)
|
163
|
-
end
|
164
|
-
|
165
|
-
it "creates a multiline text field" do
|
166
|
-
field = @acro_form.create_multiline_text_field("field")
|
167
|
-
assert_equal(:Tx, field.field_type)
|
168
|
-
assert(field.multiline_text_field?)
|
169
|
-
applies_variable_text_properties(:create_multiline_text_field)
|
170
|
-
end
|
171
|
-
|
172
|
-
it "creates a comb text field" do
|
173
|
-
field = @acro_form.create_comb_text_field("field", max_chars: 9)
|
174
|
-
assert_equal(:Tx, field.field_type)
|
175
|
-
assert_equal(9, field[:MaxLen])
|
176
|
-
assert(field.comb_text_field?)
|
177
|
-
applies_variable_text_properties(:create_comb_text_field, max_chars: 9)
|
178
|
-
end
|
179
|
-
|
180
|
-
it "creates a password field" do
|
181
|
-
field = @acro_form.create_password_field("field")
|
182
|
-
assert_equal(:Tx, field.field_type)
|
183
|
-
assert(field.password_field?)
|
184
|
-
applies_variable_text_properties(:create_password_field)
|
185
|
-
end
|
186
|
-
|
187
|
-
it "creates a file select field" do
|
188
|
-
field = @acro_form.create_file_select_field("field")
|
189
|
-
assert_equal(:Tx, field.field_type)
|
190
|
-
assert(field.file_select_field?)
|
191
|
-
applies_variable_text_properties(:create_file_select_field)
|
192
|
-
end
|
193
|
-
|
194
|
-
it "creates a check box" do
|
195
|
-
field = @acro_form.create_check_box("field")
|
196
|
-
assert(field.check_box?)
|
197
|
-
end
|
198
|
-
|
199
|
-
it "creates a radio button" do
|
200
|
-
field = @acro_form.create_radio_button("field")
|
201
|
-
assert(field.radio_button?)
|
202
|
-
end
|
203
|
-
|
204
|
-
it "creates a combo box" do
|
205
|
-
field = @acro_form.create_combo_box("field", option_items: ['a', 'b', 'c'], editable: true)
|
206
|
-
assert(field.combo_box?)
|
207
|
-
assert_equal(['a', 'b', 'c'], field.option_items)
|
208
|
-
assert(field.flagged?(:edit))
|
209
|
-
applies_variable_text_properties(:create_combo_box)
|
210
|
-
end
|
211
|
-
|
212
|
-
it "creates a list box" do
|
213
|
-
field = @acro_form.create_list_box("field", option_items: ['a', 'b', 'c'], multi_select: true)
|
214
|
-
assert(field.list_box?)
|
215
|
-
assert_equal(['a', 'b', 'c'], field.option_items)
|
216
|
-
assert(field.flagged?(:multi_select))
|
217
|
-
applies_variable_text_properties(:create_list_box)
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
it "returns the default resources" do
|
222
|
-
assert_kind_of(HexaPDF::Type::Resources, @acro_form.default_resources)
|
223
|
-
end
|
224
|
-
|
225
|
-
describe "set_default_appearance_string" do
|
226
|
-
it "uses sane default values if no arguments are provided" do
|
227
|
-
@acro_form.set_default_appearance_string
|
228
|
-
assert_equal("0 g /F1 0 Tf", @acro_form[:DA])
|
229
|
-
font = @acro_form.default_resources.font(:F1)
|
230
|
-
assert(font)
|
231
|
-
assert_equal(:Helvetica, font[:BaseFont])
|
232
|
-
end
|
233
|
-
|
234
|
-
it "allows specifying the used font and font size" do
|
235
|
-
@acro_form.set_default_appearance_string(font: 'Times', font_size: 10)
|
236
|
-
assert_equal("0 g /F1 10 Tf", @acro_form[:DA])
|
237
|
-
assert_equal(:'Times-Roman', @acro_form.default_resources.font(:F1)[:BaseFont])
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
it "sets the /NeedAppearances key" do
|
242
|
-
@acro_form.need_appearances!
|
243
|
-
assert(@acro_form[:NeedAppearances])
|
244
|
-
end
|
245
|
-
|
246
|
-
describe "create_appearances" do
|
247
|
-
before do
|
248
|
-
@tf = @acro_form.create_text_field('test')
|
249
|
-
@tf.set_default_appearance_string
|
250
|
-
@tf.create_widget(@doc.pages.add)
|
251
|
-
@cb = @acro_form.create_check_box('test2')
|
252
|
-
@cb.create_widget(@doc.pages.add)
|
253
|
-
end
|
254
|
-
|
255
|
-
it "creates the appearances of all field widgets if necessary" do
|
256
|
-
@acro_form.create_appearances
|
257
|
-
assert(@tf.each_widget.all? {|w| w.appearance_dict.normal_appearance.kind_of?(HexaPDF::Stream) })
|
258
|
-
assert(@cb.each_widget.all? {|w| w.appearance_dict.normal_appearance[:Yes].kind_of?(HexaPDF::Stream) })
|
259
|
-
end
|
260
|
-
|
261
|
-
it "force the creation of appearances if force is true" do
|
262
|
-
@acro_form.create_appearances
|
263
|
-
text_stream = @tf[:AP][:N].raw_stream
|
264
|
-
@acro_form.create_appearances
|
265
|
-
assert_same(text_stream, @tf[:AP][:N].raw_stream)
|
266
|
-
@acro_form.create_appearances(force: true)
|
267
|
-
refute_same(text_stream, @tf[:AP][:N].raw_stream)
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
describe "flatten" do
|
272
|
-
before do
|
273
|
-
@acro_form.root_fields << @doc.wrap({T: 'test'})
|
274
|
-
@tf = @acro_form.create_text_field('textfields')
|
275
|
-
@tf.set_default_appearance_string
|
276
|
-
@tf[:V] = 'Test'
|
277
|
-
@tf.create_widget(@doc.pages.add)
|
278
|
-
@cb = @acro_form.create_check_box('test.checkbox')
|
279
|
-
@cb.create_widget(@doc.pages[0])
|
280
|
-
@cb.create_widget(@doc.pages.add)
|
281
|
-
end
|
282
|
-
|
283
|
-
it "creates the missing appearances if instructed to do so" do
|
284
|
-
assert_equal(3, @acro_form.flatten(create_appearances: false).size)
|
285
|
-
assert_equal(0, @acro_form.flatten(create_appearances: true).size)
|
286
|
-
end
|
287
|
-
|
288
|
-
it "flattens the whole interactive form" do
|
289
|
-
result = @acro_form.flatten
|
290
|
-
assert(result.empty?)
|
291
|
-
assert(@tf.null?)
|
292
|
-
assert(@cb.null?)
|
293
|
-
assert(@acro_form.null?)
|
294
|
-
refute(@doc.catalog.key?(:AcroForm))
|
295
|
-
end
|
296
|
-
|
297
|
-
it "flattens the given fields" do
|
298
|
-
result = @acro_form.flatten(fields: [@cb])
|
299
|
-
assert(result.empty?)
|
300
|
-
assert(@cb.null?)
|
301
|
-
refute(@tf.null?)
|
302
|
-
refute(@acro_form.null?)
|
303
|
-
assert(@doc.catalog.key?(:AcroForm))
|
304
|
-
end
|
305
|
-
|
306
|
-
it "doesn't delete the form object if not all fields were flattened" do
|
307
|
-
@acro_form.create_appearances
|
308
|
-
@tf.delete(:AP)
|
309
|
-
result = @acro_form.flatten(create_appearances: false)
|
310
|
-
assert_equal(1, result.size)
|
311
|
-
assert(@doc.catalog.key?(:AcroForm))
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
describe "perform_validation" do
|
316
|
-
it "checks whether the /DR field is available when /DA is set" do
|
317
|
-
@acro_form[:DA] = 'test'
|
318
|
-
refute(@acro_form.validate)
|
319
|
-
end
|
320
|
-
|
321
|
-
it "checks whether the font used in /DA is available in /DR" do
|
322
|
-
@acro_form[:DA] = '/F2 0 Tf /F1 0 Tf'
|
323
|
-
refute(@acro_form.validate {|msg| assert_match(/DR must also be present/, msg) })
|
324
|
-
@acro_form.default_resources[:Font] = {}
|
325
|
-
refute(@acro_form.validate {|msg| assert_match(/font.*is not.*resource/, msg) })
|
326
|
-
@acro_form.default_resources[:Font][:F1] = :yes
|
327
|
-
assert(@acro_form.validate)
|
328
|
-
end
|
329
|
-
|
330
|
-
it "set the default appearance string, though optional, to a valid value to avoid problems" do
|
331
|
-
assert(@acro_form.validate)
|
332
|
-
assert_equal("0 g /F1 0 Tf", @acro_form[:DA])
|
333
|
-
end
|
334
|
-
|
335
|
-
describe "automatically creates the terminal fields; appearances" do
|
336
|
-
before do
|
337
|
-
@cb = @acro_form.create_check_box('test2')
|
338
|
-
@cb.create_widget(@doc.pages.add)
|
339
|
-
end
|
340
|
-
|
341
|
-
it "does this if the configuration option is true" do
|
342
|
-
assert(@acro_form.validate)
|
343
|
-
assert_kind_of(HexaPDF::Stream, @cb[:AP][:N][:Yes])
|
344
|
-
end
|
345
|
-
|
346
|
-
it "does nothing if the configuration option is false" do
|
347
|
-
@doc.config['acro_form.create_appearances'] = false
|
348
|
-
assert(@acro_form.validate)
|
349
|
-
refute_kind_of(HexaPDF::Stream, @cb[:AP][:N][:Yes])
|
350
|
-
end
|
351
|
-
end
|
352
|
-
end
|
353
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
require 'hexapdf/document'
|
5
|
-
require 'hexapdf/type/acro_form/signature_field'
|
6
|
-
|
7
|
-
describe HexaPDF::Type::AcroForm::SignatureField::LockDictionary do
|
8
|
-
it "validates the presence of the /Fields key" do
|
9
|
-
doc = HexaPDF::Document.new
|
10
|
-
obj = HexaPDF::Type::AcroForm::SignatureField::LockDictionary.new({Action: :All}, document: doc)
|
11
|
-
assert(obj.validate)
|
12
|
-
obj[:Action] = :Include
|
13
|
-
refute(obj.validate)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe HexaPDF::Type::AcroForm::SignatureField do
|
18
|
-
before do
|
19
|
-
@doc = HexaPDF::Document.new
|
20
|
-
@field = @doc.wrap({}, type: :XXAcroFormField, subtype: :Sig)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "sets the field value" do
|
24
|
-
@field.field_value = {Empty: :True}
|
25
|
-
assert_equal({Empty: :True}, @field[:V].value)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "gets the field value" do
|
29
|
-
@field[:V] = {Empty: :True}
|
30
|
-
assert_equal({Empty: :True}, @field.field_value.value)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "validates the value of the /FT field" do
|
34
|
-
refute(@field.validate(auto_correct: false))
|
35
|
-
assert(@field.validate)
|
36
|
-
assert_equal(:Sig, @field.field_type)
|
37
|
-
end
|
38
|
-
end
|