hexapdf 0.11.9 → 0.12.0
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/CHANGELOG.md +82 -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 +18 -9
- data/lib/hexapdf/cli/files.rb +1 -1
- data/lib/hexapdf/cli/form.rb +240 -0
- data/lib/hexapdf/cli/image2pdf.rb +1 -1
- data/lib/hexapdf/cli/images.rb +1 -1
- 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/composer.rb +2 -2
- data/lib/hexapdf/configuration.rb +66 -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 +1 -1
- 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 +1 -1
- data/lib/hexapdf/dictionary_fields.rb +1 -1
- data/lib/hexapdf/document.rb +14 -5
- data/lib/hexapdf/document/files.rb +1 -1
- 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 +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/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 +1 -1
- 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 +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/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 +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_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 +67 -51
- 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 +1 -1
- 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 +1 -1
- data/lib/hexapdf/layout/numeric_refinements.rb +1 -1
- data/lib/hexapdf/layout/style.rb +1 -1
- 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 +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 +2 -2
- data/lib/hexapdf/parser.rb +4 -3
- data/lib/hexapdf/pdf_array.rb +1 -1
- 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 +1 -1
- data/lib/hexapdf/serializer.rb +1 -1
- 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 +1 -1
- data/lib/hexapdf/tokenizer.rb +1 -1
- 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 +401 -0
- data/lib/hexapdf/type/acro_form/button_field.rb +300 -0
- data/lib/hexapdf/type/acro_form/choice_field.rb +220 -0
- data/lib/hexapdf/type/acro_form/field.rb +220 -17
- data/lib/hexapdf/type/acro_form/form.rb +157 -7
- data/lib/hexapdf/type/acro_form/text_field.rb +186 -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 +1 -1
- 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 +239 -2
- data/lib/hexapdf/type/catalog.rb +21 -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 +18 -1
- data/lib/hexapdf/type/font_descriptor.rb +2 -2
- 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 +16 -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 +3 -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 +1 -1
- data/lib/hexapdf/type/page_tree_node.rb +8 -11
- data/lib/hexapdf/type/resources.rb +16 -3
- data/lib/hexapdf/type/trailer.rb +2 -3
- 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 +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/test/hexapdf/content/common.rb +2 -2
- 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/font/test_true_type_wrapper.rb +10 -7
- data/test/hexapdf/font/test_type1_wrapper.rb +32 -8
- data/test/hexapdf/test_document.rb +12 -0
- data/test/hexapdf/test_parser.rb +10 -0
- data/test/hexapdf/test_rectangle.rb +14 -0
- data/test/hexapdf/test_revision.rb +3 -0
- data/test/hexapdf/test_writer.rb +2 -2
- data/test/hexapdf/type/acro_form/test_appearance_generator.rb +515 -0
- data/test/hexapdf/type/acro_form/test_button_field.rb +276 -0
- data/test/hexapdf/type/acro_form/test_choice_field.rb +137 -0
- data/test/hexapdf/type/acro_form/test_field.rb +124 -6
- data/test/hexapdf/type/acro_form/test_form.rb +189 -22
- data/test/hexapdf/type/acro_form/test_text_field.rb +119 -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_type1.rb +8 -0
- data/test/hexapdf/type/test_image.rb +7 -0
- data/test/hexapdf/type/test_page_tree_node.rb +20 -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 +13 -1
- data/test/test_helper.rb +1 -1
- metadata +37 -18
- data/lib/hexapdf/filter/dct_decode.rb +0 -60
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2020 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2020 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2020 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2020 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2020 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2020 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2020 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
data/lib/hexapdf/version.rb
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2020 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
module HexaPDF
|
|
38
38
|
|
|
39
39
|
# The version of HexaPDF.
|
|
40
|
-
VERSION = '0.
|
|
40
|
+
VERSION = '0.12.0'
|
|
41
41
|
|
|
42
42
|
end
|
data/lib/hexapdf/writer.rb
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2020 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
data/lib/hexapdf/xref_section.rb
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# This file is part of HexaPDF.
|
|
5
5
|
#
|
|
6
6
|
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
7
|
-
# Copyright (C) 2014-
|
|
7
|
+
# Copyright (C) 2014-2020 Thomas Leitner
|
|
8
8
|
#
|
|
9
9
|
# HexaPDF is free software: you can redistribute it and/or modify it
|
|
10
10
|
# under the terms of the GNU Affero General Public License version 3 as
|
|
@@ -29,10 +29,10 @@ module TestHelper
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
# Asserts that the content string contains the operators.
|
|
32
|
-
def assert_operators(content, operators, only_names: false)
|
|
32
|
+
def assert_operators(content, operators, only_names: false, range: 0..-1)
|
|
33
33
|
processor = TestHelper::OperatorRecorder.new
|
|
34
34
|
HexaPDF::Content::Parser.new.parse(content, processor)
|
|
35
|
-
result = processor.recorded_ops
|
|
35
|
+
result = processor.recorded_ops[range]
|
|
36
36
|
result.map!(&:first) if only_names
|
|
37
37
|
assert_equal(operators, result)
|
|
38
38
|
end
|
|
@@ -27,6 +27,10 @@ module CommonColorSpaceTests
|
|
|
27
27
|
assert_equal(@color_space_family, @color_space.family)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
it "the color space returns the correct color space definition" do
|
|
31
|
+
assert_equal(@color_space_definition, @color_space.definition)
|
|
32
|
+
end
|
|
33
|
+
|
|
30
34
|
it "the color responds to :components" do
|
|
31
35
|
assert(@color.respond_to?(:components))
|
|
32
36
|
end
|
|
@@ -43,14 +47,70 @@ module CommonColorSpaceTests
|
|
|
43
47
|
assert_equal(@components, @color_space.color(*@components).components)
|
|
44
48
|
end
|
|
45
49
|
|
|
50
|
+
it "normalizes the colors when using the #color method" do
|
|
51
|
+
return unless defined?(@colors)
|
|
52
|
+
assert_equal(@components, @color_space.color(*@colors).components)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "doesn't normalize the colors when using the #prenormalized_color method" do
|
|
56
|
+
return unless defined?(@colors)
|
|
57
|
+
assert_equal(@colors, @color_space.prenormalized_color(*@colors).components)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe HexaPDF::Content::ColorSpace do
|
|
63
|
+
before do
|
|
64
|
+
@class = HexaPDF::Content::ColorSpace
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe "self.device_color_from_specification" do
|
|
68
|
+
it "works for gray values" do
|
|
69
|
+
assert_equal([0.2], @class.device_color_from_specification(51).components)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "works for RGB values" do
|
|
73
|
+
assert_equal([0.2, 1, 0], @class.device_color_from_specification(51, 255, 0).components)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "works for RGB values given as string" do
|
|
77
|
+
assert_equal([0.2, 1, 0], @class.device_color_from_specification("33FF00").components)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "works for CMYK values" do
|
|
81
|
+
assert_equal([0.51, 0.9, 1, 0.5],
|
|
82
|
+
@class.device_color_from_specification(51, 90, 100, 50).components)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "works when an array is given" do
|
|
86
|
+
assert_equal([0.2], @class.device_color_from_specification([51]).components)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "returns a device color object for prenormalized color values" do
|
|
91
|
+
assert_equal([5, 6, 7], @class.prenormalized_device_color([5, 6, 7]).components)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
describe "self.for_components" do
|
|
95
|
+
it "returns the correct device color space name" do
|
|
96
|
+
assert_equal(:DeviceGray, @class.for_components([1]))
|
|
97
|
+
assert_equal(:DeviceRGB, @class.for_components([1, 2, 3]))
|
|
98
|
+
assert_equal(:DeviceCMYK, @class.for_components([1, 2, 3, 4]))
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "fails if an array with an invalid length is passed" do
|
|
102
|
+
assert_raises(ArgumentError) { @class.for_components([]) }
|
|
103
|
+
end
|
|
104
|
+
end
|
|
46
105
|
end
|
|
47
106
|
|
|
48
107
|
describe HexaPDF::Content::ColorSpace::Universal do
|
|
49
108
|
include CommonColorSpaceTests
|
|
50
109
|
|
|
51
110
|
before do
|
|
52
|
-
@color_space = HexaPDF::Content::ColorSpace::Universal.new([:test])
|
|
111
|
+
@color_space = HexaPDF::Content::ColorSpace::Universal.new([:test, :value])
|
|
53
112
|
@color_space_family = :test
|
|
113
|
+
@color_space_definition = [:test, :value]
|
|
54
114
|
@color = @color_space.default_color
|
|
55
115
|
@other_color = @color_space.color(128, 5, 6, 7, 8)
|
|
56
116
|
@components = [5, 6, 7, 8]
|
|
@@ -58,7 +118,7 @@ describe HexaPDF::Content::ColorSpace::Universal do
|
|
|
58
118
|
|
|
59
119
|
it "can be compared to another universal color space" do
|
|
60
120
|
other = HexaPDF::Content::ColorSpace::Universal.new([:other])
|
|
61
|
-
same = HexaPDF::Content::ColorSpace::Universal.new([:test])
|
|
121
|
+
same = HexaPDF::Content::ColorSpace::Universal.new([:test, :value])
|
|
62
122
|
assert_equal(same, @color_space)
|
|
63
123
|
refute_equal(other, @color_space)
|
|
64
124
|
end
|
|
@@ -69,10 +129,11 @@ describe HexaPDF::Content::ColorSpace::DeviceRGB do
|
|
|
69
129
|
|
|
70
130
|
before do
|
|
71
131
|
@color_space = HexaPDF::Content::ColorSpace::DeviceRGB.new
|
|
72
|
-
@color_space_family = :DeviceRGB
|
|
132
|
+
@color_space_family = @color_space_definition = :DeviceRGB
|
|
73
133
|
@color = @color_space.default_color
|
|
74
134
|
@other_color = @color_space.color(128, 0, 0)
|
|
75
|
-
@
|
|
135
|
+
@colors = [128, 0, 255]
|
|
136
|
+
@components = @colors.map {|c| c.to_f / 255 }
|
|
76
137
|
end
|
|
77
138
|
end
|
|
78
139
|
|
|
@@ -81,10 +142,11 @@ describe HexaPDF::Content::ColorSpace::DeviceCMYK do
|
|
|
81
142
|
|
|
82
143
|
before do
|
|
83
144
|
@color_space = HexaPDF::Content::ColorSpace::DeviceCMYK.new
|
|
84
|
-
@color_space_family = :DeviceCMYK
|
|
145
|
+
@color_space_family = @color_space_definition = :DeviceCMYK
|
|
85
146
|
@color = @color_space.default_color
|
|
86
147
|
@other_color = @color_space.color(128, 0, 0, 128)
|
|
87
|
-
@
|
|
148
|
+
@colors = [0, 20, 40, 80]
|
|
149
|
+
@components = [0.0, 0.2, 0.4, 0.8]
|
|
88
150
|
end
|
|
89
151
|
end
|
|
90
152
|
|
|
@@ -93,9 +155,10 @@ describe HexaPDF::Content::ColorSpace::DeviceGray do
|
|
|
93
155
|
|
|
94
156
|
before do
|
|
95
157
|
@color_space = HexaPDF::Content::ColorSpace::DeviceGray.new
|
|
96
|
-
@color_space_family = :DeviceGray
|
|
158
|
+
@color_space_family = @color_space_definition = :DeviceGray
|
|
97
159
|
@color = @color_space.default_color
|
|
98
160
|
@other_color = @color_space.color(128)
|
|
99
|
-
@
|
|
161
|
+
@colors = [128]
|
|
162
|
+
@components = [128.0 / 255]
|
|
100
163
|
end
|
|
101
164
|
end
|
|
@@ -254,89 +254,89 @@ end
|
|
|
254
254
|
|
|
255
255
|
describe_operator :SetStrokingColor, :SC do
|
|
256
256
|
it "sets the stroking color" do
|
|
257
|
-
invoke(
|
|
258
|
-
assert_equal(@processor.resources.color_space(:DeviceGray).color(
|
|
257
|
+
invoke(0.2)
|
|
258
|
+
assert_equal(@processor.resources.color_space(:DeviceGray).color(51),
|
|
259
259
|
@processor.graphics_state.stroke_color)
|
|
260
260
|
end
|
|
261
261
|
|
|
262
262
|
it "serializes correctly" do
|
|
263
|
-
assert_serialized(
|
|
263
|
+
assert_serialized(0.2, 0.5, 0.8)
|
|
264
264
|
end
|
|
265
265
|
end
|
|
266
266
|
|
|
267
267
|
describe_operator :SetNonStrokingColor, :sc do
|
|
268
268
|
it "sets the non stroking color" do
|
|
269
|
-
invoke(
|
|
270
|
-
assert_equal(@processor.resources.color_space(:DeviceGray).color(
|
|
269
|
+
invoke(0.2)
|
|
270
|
+
assert_equal(@processor.resources.color_space(:DeviceGray).color(51),
|
|
271
271
|
@processor.graphics_state.fill_color)
|
|
272
272
|
end
|
|
273
273
|
|
|
274
274
|
it "serializes correctly" do
|
|
275
|
-
assert_serialized(
|
|
275
|
+
assert_serialized(0.2, 0.5, 0.8)
|
|
276
276
|
end
|
|
277
277
|
end
|
|
278
278
|
|
|
279
279
|
describe_operator :SetDeviceGrayStrokingColor, :G do
|
|
280
280
|
it "sets the DeviceGray stroking color" do
|
|
281
|
-
invoke(
|
|
282
|
-
assert_equal(@processor.resources.color_space(:DeviceGray).color(
|
|
281
|
+
invoke(0.2)
|
|
282
|
+
assert_equal(@processor.resources.color_space(:DeviceGray).color(51),
|
|
283
283
|
@processor.graphics_state.stroke_color)
|
|
284
284
|
end
|
|
285
285
|
end
|
|
286
286
|
|
|
287
287
|
describe_operator :SetDeviceGrayNonStrokingColor, :g do
|
|
288
288
|
it "sets the DeviceGray non stroking color" do
|
|
289
|
-
invoke(
|
|
290
|
-
assert_equal(@processor.resources.color_space(:DeviceGray).color(
|
|
289
|
+
invoke(0.2)
|
|
290
|
+
assert_equal(@processor.resources.color_space(:DeviceGray).color(51),
|
|
291
291
|
@processor.graphics_state.fill_color)
|
|
292
292
|
end
|
|
293
293
|
end
|
|
294
294
|
|
|
295
295
|
describe_operator :SetDeviceRGBStrokingColor, :RG do
|
|
296
296
|
it "sets the DeviceRGB stroking color" do
|
|
297
|
-
invoke(
|
|
298
|
-
assert_equal(@processor.resources.color_space(:DeviceRGB).color(
|
|
297
|
+
invoke(0.2, 0, 0.2)
|
|
298
|
+
assert_equal(@processor.resources.color_space(:DeviceRGB).color(51, 0, 51),
|
|
299
299
|
@processor.graphics_state.stroke_color)
|
|
300
300
|
end
|
|
301
301
|
|
|
302
302
|
it "serializes correctly" do
|
|
303
|
-
assert_serialized(
|
|
303
|
+
assert_serialized(0.2, 0.3, 0.4)
|
|
304
304
|
end
|
|
305
305
|
end
|
|
306
306
|
|
|
307
307
|
describe_operator :SetDeviceRGBNonStrokingColor, :rg do
|
|
308
308
|
it "sets the DeviceRGB non stroking color" do
|
|
309
|
-
invoke(
|
|
310
|
-
assert_equal(@processor.resources.color_space(:DeviceRGB).color(
|
|
309
|
+
invoke(0.2, 0, 0.2)
|
|
310
|
+
assert_equal(@processor.resources.color_space(:DeviceRGB).color(51, 0, 51),
|
|
311
311
|
@processor.graphics_state.fill_color)
|
|
312
312
|
end
|
|
313
313
|
|
|
314
314
|
it "serializes correctly" do
|
|
315
|
-
assert_serialized(
|
|
315
|
+
assert_serialized(0.2, 0.3, 0.4)
|
|
316
316
|
end
|
|
317
317
|
end
|
|
318
318
|
|
|
319
319
|
describe_operator :SetDeviceCMYKStrokingColor, :K do
|
|
320
320
|
it "sets the DeviceCMYK stroking color" do
|
|
321
|
-
invoke(
|
|
322
|
-
assert_equal(@processor.resources.color_space(:DeviceCMYK).color(
|
|
321
|
+
invoke(0.51, 0, 0.51, 0.51)
|
|
322
|
+
assert_equal(@processor.resources.color_space(:DeviceCMYK).color(51, 0, 51, 51),
|
|
323
323
|
@processor.graphics_state.stroke_color)
|
|
324
324
|
end
|
|
325
325
|
|
|
326
326
|
it "serializes correctly" do
|
|
327
|
-
assert_serialized(
|
|
327
|
+
assert_serialized(0.2, 0.3, 0.4, 0.5)
|
|
328
328
|
end
|
|
329
329
|
end
|
|
330
330
|
|
|
331
331
|
describe_operator :SetDeviceCMYKNonStrokingColor, :k do
|
|
332
332
|
it "sets the DeviceCMYK non stroking color" do
|
|
333
|
-
invoke(
|
|
334
|
-
assert_equal(@processor.resources.color_space(:DeviceCMYK).color(
|
|
333
|
+
invoke(0.51, 0, 0.51, 0.51)
|
|
334
|
+
assert_equal(@processor.resources.color_space(:DeviceCMYK).color(51, 0, 51, 51),
|
|
335
335
|
@processor.graphics_state.fill_color)
|
|
336
336
|
end
|
|
337
337
|
|
|
338
338
|
it "serializes correctly" do
|
|
339
|
-
assert_serialized(
|
|
339
|
+
assert_serialized(0.2, 0.3, 0.4, 0.5)
|
|
340
340
|
end
|
|
341
341
|
end
|
|
342
342
|
|
|
@@ -81,5 +81,19 @@ describe HexaPDF::Content::Parser do
|
|
|
81
81
|
end
|
|
82
82
|
assert_match(/EI not found/, exp.message)
|
|
83
83
|
end
|
|
84
|
+
|
|
85
|
+
it "can use a block instead of the processor object" do
|
|
86
|
+
called = 0
|
|
87
|
+
@parser.parse("/F1 5 Tf") do |obj, params|
|
|
88
|
+
called += 1
|
|
89
|
+
assert_equal(:Tf, obj)
|
|
90
|
+
assert_equal([:F1, 5], params)
|
|
91
|
+
end
|
|
92
|
+
assert_equal(1, called)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "fails if neither a processor object or a block is provided" do
|
|
96
|
+
assert_raises(ArgumentError) { @parser.parse("test") }
|
|
97
|
+
end
|
|
84
98
|
end
|
|
85
99
|
end
|
|
@@ -36,7 +36,7 @@ describe HexaPDF::Document::Fonts do
|
|
|
36
36
|
assert_same(font, @doc.fonts.add(:TestFont, variant: :none))
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
it "fails if the requested font is not found"
|
|
39
|
+
it "fails if the requested font is not found" do
|
|
40
40
|
@doc.config['font_loader'] << 'HexaPDF::FontLoader::Standard14'
|
|
41
41
|
error = assert_raises(HexaPDF::Error) { @doc.fonts.add("Unknown") }
|
|
42
42
|
assert_match(/Times \(none/, error.message)
|
|
@@ -74,20 +74,20 @@ describe HexaPDF::Document::Pages do
|
|
|
74
74
|
|
|
75
75
|
describe "delete" do
|
|
76
76
|
it "deletes a given page" do
|
|
77
|
-
|
|
78
|
-
@doc.pages.add
|
|
77
|
+
page1 = @doc.pages.add
|
|
78
|
+
page2 = @doc.pages.add
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
@doc.pages.delete(page1)
|
|
81
|
+
assert_equal([page2], @doc.pages.root[:Kids].value)
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
describe "delete_at" do
|
|
86
86
|
it "deletes a page at a given index" do
|
|
87
87
|
page1 = @doc.pages.add
|
|
88
|
-
|
|
88
|
+
@doc.pages.add
|
|
89
89
|
page3 = @doc.pages.add
|
|
90
|
-
|
|
90
|
+
@doc.pages.delete_at(1)
|
|
91
91
|
assert_equal([page1, page3], @doc.pages.root[:Kids].value)
|
|
92
92
|
end
|
|
93
93
|
end
|
|
@@ -94,7 +94,10 @@ describe HexaPDF::Font::TrueTypeWrapper do
|
|
|
94
94
|
@font_wrapper.encode(glyph)
|
|
95
95
|
@doc.dispatch_message(:complete_objects)
|
|
96
96
|
|
|
97
|
-
dict = @font_wrapper.
|
|
97
|
+
dict = @font_wrapper.pdf_object
|
|
98
|
+
|
|
99
|
+
# Checking the circular reference
|
|
100
|
+
assert_same(@font_wrapper, dict.font_wrapper)
|
|
98
101
|
|
|
99
102
|
# Checking Type 0 font dictionary
|
|
100
103
|
assert_equal(:Font, dict[:Type])
|
|
@@ -129,7 +132,7 @@ describe HexaPDF::Font::TrueTypeWrapper do
|
|
|
129
132
|
@font[:'OS/2'].typo_ascender = 1000
|
|
130
133
|
font_wrapper = HexaPDF::Font::TrueTypeWrapper.new(@doc, @font)
|
|
131
134
|
font_wrapper.encode(glyph)
|
|
132
|
-
fd = font_wrapper.
|
|
135
|
+
fd = font_wrapper.pdf_object[:DescendantFonts][0][:FontDescriptor]
|
|
133
136
|
assert_equal(800, fd[:CapHeight])
|
|
134
137
|
assert_equal(500, fd[:XHeight])
|
|
135
138
|
end
|
|
@@ -139,7 +142,7 @@ describe HexaPDF::Font::TrueTypeWrapper do
|
|
|
139
142
|
@font[:'OS/2'].cap_height = 1000 * @font[:head].units_per_em / 1000
|
|
140
143
|
font_wrapper = HexaPDF::Font::TrueTypeWrapper.new(@doc, @font)
|
|
141
144
|
font_wrapper.encode(glyph)
|
|
142
|
-
fd = font_wrapper.
|
|
145
|
+
fd = font_wrapper.pdf_object[:DescendantFonts][0][:FontDescriptor]
|
|
143
146
|
assert_equal(1000, fd[:CapHeight])
|
|
144
147
|
assert_equal(500, fd[:XHeight])
|
|
145
148
|
end
|
|
@@ -151,7 +154,7 @@ describe HexaPDF::Font::TrueTypeWrapper do
|
|
|
151
154
|
@font_wrapper.encode(glyph)
|
|
152
155
|
@doc.dispatch_message(:complete_objects)
|
|
153
156
|
|
|
154
|
-
dict = @font_wrapper.
|
|
157
|
+
dict = @font_wrapper.pdf_object
|
|
155
158
|
|
|
156
159
|
assert_equal(HexaPDF::Font::CMap.create_to_unicode_cmap([[3, ' '.ord], [glyph.id, 'H'.ord]]),
|
|
157
160
|
dict[:ToUnicode].stream)
|
|
@@ -164,7 +167,7 @@ describe HexaPDF::Font::TrueTypeWrapper do
|
|
|
164
167
|
@font_wrapper.encode(@font_wrapper.glyph(10))
|
|
165
168
|
@doc.dispatch_message(:complete_objects)
|
|
166
169
|
|
|
167
|
-
font_data = @font_wrapper.
|
|
170
|
+
font_data = @font_wrapper.pdf_object[:DescendantFonts][0][:FontDescriptor][:FontFile2].stream
|
|
168
171
|
font = HexaPDF::Font::TrueType::Font.new(StringIO.new(font_data))
|
|
169
172
|
assert_equal(@font[:glyf][0].raw_data, font[:glyf][0].raw_data)
|
|
170
173
|
assert_equal(@font[:glyf][10].raw_data, font[:glyf][1].raw_data)
|
|
@@ -175,9 +178,9 @@ describe HexaPDF::Font::TrueTypeWrapper do
|
|
|
175
178
|
@doc.dispatch_message(:complete_objects)
|
|
176
179
|
|
|
177
180
|
assert_equal(File.size(@font_file),
|
|
178
|
-
@font_wrapper.
|
|
181
|
+
@font_wrapper.pdf_object[:DescendantFonts][0][:FontDescriptor][:FontFile2][:Length1])
|
|
179
182
|
assert_equal(File.binread(@font_file),
|
|
180
|
-
@font_wrapper.
|
|
183
|
+
@font_wrapper.pdf_object[:DescendantFonts][0][:FontDescriptor][:FontFile2].stream)
|
|
181
184
|
end
|
|
182
185
|
end
|
|
183
186
|
end
|