hexapdf 0.30.0 → 0.32.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 +54 -1
- data/LICENSE +1 -1
- data/examples/020-column_box.rb +10 -11
- data/examples/021-list_box.rb +5 -5
- data/lib/hexapdf/cli/batch.rb +1 -1
- data/lib/hexapdf/cli/command.rb +17 -2
- data/lib/hexapdf/cli/files.rb +1 -1
- data/lib/hexapdf/cli/fonts.rb +1 -1
- data/lib/hexapdf/cli/form.rb +1 -1
- data/lib/hexapdf/cli/image2pdf.rb +1 -1
- data/lib/hexapdf/cli/images.rb +1 -1
- data/lib/hexapdf/cli/info.rb +10 -2
- data/lib/hexapdf/cli/inspect.rb +3 -3
- 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 +1 -1
- data/lib/hexapdf/composer.rb +97 -29
- data/lib/hexapdf/configuration.rb +18 -5
- data/lib/hexapdf/content/canvas.rb +1 -1
- data/lib/hexapdf/content/color_space.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/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 +1 -1
- data/lib/hexapdf/digital_signature/cms_handler.rb +1 -1
- data/lib/hexapdf/digital_signature/handler.rb +1 -1
- data/lib/hexapdf/digital_signature/pkcs1_handler.rb +1 -1
- data/lib/hexapdf/digital_signature/signature.rb +1 -1
- data/lib/hexapdf/digital_signature/signatures.rb +1 -1
- data/lib/hexapdf/digital_signature/signing/default_handler.rb +1 -1
- data/lib/hexapdf/digital_signature/signing/signed_data_creator.rb +1 -1
- data/lib/hexapdf/digital_signature/signing/timestamp_handler.rb +1 -1
- data/lib/hexapdf/digital_signature/signing.rb +1 -1
- data/lib/hexapdf/digital_signature/verification_result.rb +1 -1
- data/lib/hexapdf/digital_signature.rb +1 -1
- data/lib/hexapdf/document/destinations.rb +1 -1
- 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/layout.rb +122 -39
- data/lib/hexapdf/document/pages.rb +2 -6
- data/lib/hexapdf/document.rb +9 -2
- data/lib/hexapdf/encryption/aes.rb +3 -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 +4 -1
- data/lib/hexapdf/encryption/standard_security_handler.rb +1 -1
- data/lib/hexapdf/encryption.rb +1 -1
- data/lib/hexapdf/error.rb +12 -2
- 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 +21 -9
- 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 +1 -1
- data/lib/hexapdf/layout/box_fitter.rb +1 -1
- data/lib/hexapdf/layout/column_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 +17 -3
- data/lib/hexapdf/layout/line.rb +1 -1
- data/lib/hexapdf/layout/list_box.rb +1 -1
- data/lib/hexapdf/layout/numeric_refinements.rb +1 -1
- data/lib/hexapdf/layout/page_style.rb +144 -0
- 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 +4 -7
- data/lib/hexapdf/layout/text_shaper.rb +1 -1
- data/lib/hexapdf/layout/width_from_polygon.rb +1 -1
- data/lib/hexapdf/layout.rb +2 -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 +1 -1
- 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 +9 -7
- data/lib/hexapdf/task.rb +1 -1
- data/lib/hexapdf/test_utils.rb +1 -1
- data/lib/hexapdf/tokenizer.rb +2 -1
- data/lib/hexapdf/type/acro_form/appearance_generator.rb +1 -1
- data/lib/hexapdf/type/acro_form/button_field.rb +1 -1
- data/lib/hexapdf/type/acro_form/choice_field.rb +1 -1
- data/lib/hexapdf/type/acro_form/field.rb +1 -1
- data/lib/hexapdf/type/acro_form/form.rb +1 -1
- data/lib/hexapdf/type/acro_form/signature_field.rb +1 -1
- data/lib/hexapdf/type/acro_form/text_field.rb +1 -1
- data/lib/hexapdf/type/acro_form/variable_text_field.rb +1 -1
- 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 +1 -1
- 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/mark_information.rb +1 -1
- data/lib/hexapdf/type/names.rb +1 -1
- data/lib/hexapdf/type/object_stream.rb +8 -3
- data/lib/hexapdf/type/outline.rb +2 -2
- data/lib/hexapdf/type/outline_item.rb +11 -2
- data/lib/hexapdf/type/page.rb +36 -9
- data/lib/hexapdf/type/page_label.rb +1 -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 +12 -5
- 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 +2 -2
- data/lib/hexapdf/xref_section.rb +1 -1
- data/lib/hexapdf.rb +1 -1
- data/test/hexapdf/document/test_layout.rb +80 -17
- data/test/hexapdf/encryption/common.rb +4 -0
- data/test/hexapdf/encryption/test_aes.rb +8 -0
- data/test/hexapdf/encryption/test_security_handler.rb +6 -0
- data/test/hexapdf/filter/test_flate_decode.rb +19 -5
- data/test/hexapdf/layout/test_inline_box.rb +35 -15
- data/test/hexapdf/layout/test_page_style.rb +70 -0
- data/test/hexapdf/layout/test_text_box.rb +5 -2
- data/test/hexapdf/layout/test_text_layouter.rb +6 -11
- data/test/hexapdf/task/test_optimize.rb +11 -9
- data/test/hexapdf/test_composer.rb +49 -11
- data/test/hexapdf/test_tokenizer.rb +5 -0
- data/test/hexapdf/test_writer.rb +5 -5
- data/test/hexapdf/type/test_object_stream.rb +16 -7
- data/test/hexapdf/type/test_outline.rb +3 -1
- data/test/hexapdf/type/test_outline_item.rb +21 -1
- data/test/hexapdf/type/test_page.rb +58 -11
- data/test/hexapdf/type/test_xref_stream.rb +6 -1
- metadata +4 -2
|
@@ -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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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/content.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-2023 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/data_dir.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-2023 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/dictionary.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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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
|
|
@@ -44,7 +44,7 @@ module HexaPDF
|
|
|
44
44
|
# Often times the layout related classes are used through HexaPDF::Composer which makes it easy
|
|
45
45
|
# to create documents. However, sometimes one wants to have a bit more control or do something
|
|
46
46
|
# special and use the HexaPDF::Layout classes directly. This is possible but it is better to use
|
|
47
|
-
# those classes through an instance of this
|
|
47
|
+
# those classes through an instance of this class because it makes it more convenient and ties
|
|
48
48
|
# everything together. Incidentally, HexaPDF::Composer relies on this class for a good part of
|
|
49
49
|
# its work.
|
|
50
50
|
#
|
|
@@ -52,11 +52,21 @@ module HexaPDF
|
|
|
52
52
|
# == Boxes
|
|
53
53
|
#
|
|
54
54
|
# The main focus of the class is on providing convenience methods for creating box objects. The
|
|
55
|
-
# most often used box classes like HexaPDF::Layout::TextBox or HexaPDF::Layout::
|
|
56
|
-
# created through dedicated methods
|
|
55
|
+
# most often used box classes like HexaPDF::Layout::TextBox or HexaPDF::Layout::ImageBox can be
|
|
56
|
+
# created through dedicated methods:
|
|
57
|
+
#
|
|
58
|
+
# * #text_box
|
|
59
|
+
# * #formatted_text_box
|
|
60
|
+
# * #image_box
|
|
61
|
+
# * #lorem_ipsum_box
|
|
57
62
|
#
|
|
58
63
|
# Other, more general boxes don't have their own method but can be created through the general
|
|
59
|
-
# #box method.
|
|
64
|
+
# #box method. This method uses the 'layout.boxes.map' configuration option.
|
|
65
|
+
#
|
|
66
|
+
# Additionally, the +_box+ suffix can be omitted, so calling #text, #formatted_text and #image
|
|
67
|
+
# also works. Furthermore, all box names defined in the 'layout.boxes.map' configuration option
|
|
68
|
+
# can be used as method names (with or without a +_box+ suffix) and will invoke #box, i.e.
|
|
69
|
+
# #column and #column_box will also work.
|
|
60
70
|
#
|
|
61
71
|
#
|
|
62
72
|
# == Box Styles
|
|
@@ -126,18 +136,13 @@ module HexaPDF
|
|
|
126
136
|
# instance.
|
|
127
137
|
def initialize(layout)
|
|
128
138
|
@layout = layout
|
|
129
|
-
@layout_boxes_map = layout.instance_variable_get(:@document).config['layout.boxes.map']
|
|
130
139
|
@children = []
|
|
131
140
|
end
|
|
132
141
|
|
|
133
142
|
# :nodoc:
|
|
134
143
|
def method_missing(name, *args, **kwargs, &block)
|
|
135
|
-
if @layout.
|
|
144
|
+
if @layout.box_creation_method?(name)
|
|
136
145
|
@children << @layout.send(name, *args, **kwargs, &block)
|
|
137
|
-
elsif @layout.respond_to?("#{name}_box")
|
|
138
|
-
@children << @layout.send("#{name}_box", *args, **kwargs, &block)
|
|
139
|
-
elsif @layout_boxes_map.key?(name)
|
|
140
|
-
@children << @layout.box(name, *args, **kwargs, &block)
|
|
141
146
|
else
|
|
142
147
|
super
|
|
143
148
|
end
|
|
@@ -145,10 +150,7 @@ module HexaPDF
|
|
|
145
150
|
|
|
146
151
|
# :nodoc:
|
|
147
152
|
def respond_to_missing?(name, _private)
|
|
148
|
-
@layout.
|
|
149
|
-
@layout.respond_to?("#{name}_box") ||
|
|
150
|
-
@layout_boxes_map.key?(name) ||
|
|
151
|
-
super
|
|
153
|
+
@layout.box_creation_method?(name) || super
|
|
152
154
|
end
|
|
153
155
|
|
|
154
156
|
# Appends the given box to the list of collected children.
|
|
@@ -208,6 +210,28 @@ module HexaPDF
|
|
|
208
210
|
style
|
|
209
211
|
end
|
|
210
212
|
|
|
213
|
+
# Creates an inline box for use together with text fragments.
|
|
214
|
+
#
|
|
215
|
+
# The +valign+ argument ist used to specify the vertical alignment of the box within the text
|
|
216
|
+
# line. See HexaPDF::Layout::Line for details.
|
|
217
|
+
#
|
|
218
|
+
# If a box instance is provided as first argument, it is used. Otherwise the first argument
|
|
219
|
+
# has to be the name of a box creation method and +args+, +kwargs+ and +block+ are passed to
|
|
220
|
+
# it.
|
|
221
|
+
#
|
|
222
|
+
# Example:
|
|
223
|
+
#
|
|
224
|
+
# layout.inline_box(:text, "Hallo")
|
|
225
|
+
# layout.inline_box(:list) {|list| list.text("Hallo") }
|
|
226
|
+
def inline_box(box_or_name, *args, valign: :baseline, **kwargs, &block)
|
|
227
|
+
box = if box_or_name.kind_of?(HexaPDF::Layout::Box)
|
|
228
|
+
box_or_name
|
|
229
|
+
else
|
|
230
|
+
send(box_or_name, *args, **kwargs, &block)
|
|
231
|
+
end
|
|
232
|
+
HexaPDF::Layout::InlineBox.new(box, valign: valign)
|
|
233
|
+
end
|
|
234
|
+
|
|
211
235
|
# Creates the named box and returns it.
|
|
212
236
|
#
|
|
213
237
|
# The +name+ argument refers to the registered name of the box class that is looked up in the
|
|
@@ -222,8 +246,8 @@ module HexaPDF
|
|
|
222
246
|
#
|
|
223
247
|
# Example:
|
|
224
248
|
#
|
|
225
|
-
#
|
|
226
|
-
#
|
|
249
|
+
# layout.box(:column, columns: 2, gap: 15) # => column_box_instance
|
|
250
|
+
# layout.box(:column) do |column| # column box with one child
|
|
227
251
|
# column.lorem_ipsum
|
|
228
252
|
# end
|
|
229
253
|
def box(name, width: 0, height: 0, style: nil, **box_options, &block)
|
|
@@ -262,10 +286,10 @@ module HexaPDF
|
|
|
262
286
|
#
|
|
263
287
|
# Examples:
|
|
264
288
|
#
|
|
265
|
-
# layout.
|
|
266
|
-
# layout.
|
|
267
|
-
# layout.
|
|
268
|
-
# layout.
|
|
289
|
+
# layout.text_box("Test " * 15)
|
|
290
|
+
# layout.text_box("Now " * 7, width: 100)
|
|
291
|
+
# layout.text_box("Another test", font_size: 15, fill_color: "green")
|
|
292
|
+
# layout.text_box("Different box style", fill_color: 'white', box_style: {
|
|
269
293
|
# underlays: [->(c, b) { c.rectangle(0, 0, b.content_width, b.content_height).fill }]
|
|
270
294
|
# })
|
|
271
295
|
#
|
|
@@ -282,23 +306,37 @@ module HexaPDF
|
|
|
282
306
|
# Creates a HexaPDF::Layout::TextBox like #text_box but allows parts of the text to be
|
|
283
307
|
# formatted differently.
|
|
284
308
|
#
|
|
285
|
-
# The argument +data+ needs to be an array of String and/or Hash
|
|
309
|
+
# The argument +data+ needs to be an array of String, HexaPDF::Layout::InlineBox and/or Hash
|
|
310
|
+
# objects and is transformed so that it is suitable as argument for the text box:
|
|
286
311
|
#
|
|
287
312
|
# * A String object is treated like {text: data}.
|
|
288
313
|
#
|
|
314
|
+
# * A HexaPDF::Layout::InlineBox is used without modification.
|
|
315
|
+
#
|
|
289
316
|
# * Hashes can contain any style properties and the following special keys:
|
|
290
317
|
#
|
|
291
|
-
# text:: The text to be formatted.
|
|
318
|
+
# text:: The text to be formatted. If this is set and :box is not, the hash will be
|
|
319
|
+
# transformed into a text fragment.
|
|
292
320
|
#
|
|
293
321
|
# link:: A URL that should be linked to. If no text is provided but a link, the link is used
|
|
294
|
-
#
|
|
322
|
+
# for the text. If this is set and :box is not, the hash will be transformed into a
|
|
323
|
+
# text fragment with an appropriate link overlay.
|
|
295
324
|
#
|
|
296
325
|
# style:: The style to be use as base style instead of the style created from the +style+
|
|
297
326
|
# and +style_properties+ arguments. See HexaPDF::Layout::Style::create for allowed
|
|
298
327
|
# values.
|
|
299
328
|
#
|
|
300
|
-
#
|
|
301
|
-
#
|
|
329
|
+
# If any style properties are set, the used style is duplicated and the additional
|
|
330
|
+
# properties applied.
|
|
331
|
+
#
|
|
332
|
+
# The final style is used for a created text fragment.
|
|
333
|
+
#
|
|
334
|
+
# box:: An inline box to be used. If this is set, the hash will be transformed into an
|
|
335
|
+
# inline box.
|
|
336
|
+
#
|
|
337
|
+
# The value must be one or more (as an array) positional arguments to be used with the
|
|
338
|
+
# #inline_box method. The rest of the hash keys are passed as keyword arguments to
|
|
339
|
+
# #inline_box except for :block that value of which would be passed as the block.
|
|
302
340
|
#
|
|
303
341
|
# See #text_box for details on +width+, +height+, +style+, +style_properties+, +properties+
|
|
304
342
|
# and +box_style+.
|
|
@@ -310,24 +348,37 @@ module HexaPDF
|
|
|
310
348
|
# layout.formatted_text_box(["Some ", {link: "https://example.com",
|
|
311
349
|
# fill_color: 'blue', text: "Example"}])
|
|
312
350
|
# layout.formatted_text_box(["Some ", {text: "string", style: {font_size: 20}}])
|
|
351
|
+
# layout.formatted_text_box(["Some ", {box: [:text, "string"], valign: :top}])
|
|
352
|
+
# block = lambda {|list| list.text("First item"); list.text("Second item") }
|
|
353
|
+
# layout.formatted_text_box(["Some ", {box: :list, item_spacing: 10, block: block}])
|
|
313
354
|
#
|
|
314
355
|
# See: #text_box, HexaPDF::Layout::TextBox, HexaPDF::Layout::TextFragment
|
|
315
356
|
def formatted_text_box(data, width: 0, height: 0, style: nil, properties: nil, box_style: nil,
|
|
316
357
|
**style_properties)
|
|
317
358
|
style = retrieve_style(style, style_properties)
|
|
318
359
|
box_style = (box_style ? retrieve_style(box_style) : style)
|
|
319
|
-
data.map! do |
|
|
320
|
-
|
|
321
|
-
|
|
360
|
+
data.map! do |item|
|
|
361
|
+
case item
|
|
362
|
+
when String
|
|
363
|
+
HexaPDF::Layout::TextFragment.create(item, style)
|
|
364
|
+
when Hash
|
|
365
|
+
if (args = item.delete(:box))
|
|
366
|
+
block = item.delete(:block)
|
|
367
|
+
inline_box(*args, **item, &block)
|
|
368
|
+
else
|
|
369
|
+
link = item.delete(:link)
|
|
370
|
+
(item[:overlays] ||= []) << [:link, {uri: link}] if link
|
|
371
|
+
text = item.delete(:text) || link || ""
|
|
372
|
+
properties = item.delete(:properties)
|
|
373
|
+
frag_style = retrieve_style(item.delete(:style) || style, item)
|
|
374
|
+
fragment = HexaPDF::Layout::TextFragment.create(text, frag_style)
|
|
375
|
+
fragment.properties.update(properties) if properties
|
|
376
|
+
fragment
|
|
377
|
+
end
|
|
378
|
+
when HexaPDF::Layout::InlineBox
|
|
379
|
+
item
|
|
322
380
|
else
|
|
323
|
-
|
|
324
|
-
(hash[:overlays] ||= []) << [:link, {uri: link}] if link
|
|
325
|
-
text = hash.delete(:text) || link || ""
|
|
326
|
-
properties = hash.delete(:properties)
|
|
327
|
-
frag_style = retrieve_style(hash.delete(:style) || style, hash)
|
|
328
|
-
fragment = HexaPDF::Layout::TextFragment.create(text, frag_style)
|
|
329
|
-
fragment.properties.update(properties) if properties
|
|
330
|
-
fragment
|
|
381
|
+
raise ArgumentError, "Invalid item of class #{item.class} in data array"
|
|
331
382
|
end
|
|
332
383
|
end
|
|
333
384
|
box_class_for_name(:text).new(items: data, width: width, height: height,
|
|
@@ -355,8 +406,7 @@ module HexaPDF
|
|
|
355
406
|
properties: properties, style: style)
|
|
356
407
|
end
|
|
357
408
|
|
|
358
|
-
# :nodoc:
|
|
359
|
-
LOREM_IPSUM = [
|
|
409
|
+
LOREM_IPSUM = [ # :nodoc:
|
|
360
410
|
"Lorem ipsum dolor sit amet, con\u{00AD}sectetur adipis\u{00AD}cing elit, sed " \
|
|
361
411
|
"do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
|
|
362
412
|
"Ut enim ad minim veniam, quis nostrud exer\u{00AD}citation ullamco laboris nisi ut " \
|
|
@@ -374,6 +424,39 @@ module HexaPDF
|
|
|
374
424
|
text_box(([LOREM_IPSUM[0, sentences].join(" ")] * count).join("\n\n"), **text_box_properties)
|
|
375
425
|
end
|
|
376
426
|
|
|
427
|
+
BOX_METHOD_NAMES = [:text, :formatted_text, :image, :lorem_ipsum] #:nodoc:
|
|
428
|
+
|
|
429
|
+
# Allows creating boxes using more convenient method names:
|
|
430
|
+
#
|
|
431
|
+
# * #text for #text_box
|
|
432
|
+
# * #formatted_text for #formatted_text_box
|
|
433
|
+
# * #image for #image_box
|
|
434
|
+
# * #lorem_ipsum for #lorem_ipsum_box
|
|
435
|
+
# * The name of a pre-defined box class like #column will invoke #box appropriately. Same if
|
|
436
|
+
# used with a '_box' suffix.
|
|
437
|
+
def method_missing(name, *args, **kwargs, &block)
|
|
438
|
+
name_without_box = name.to_s.sub(/_box$/, '').intern
|
|
439
|
+
if BOX_METHOD_NAMES.include?(name)
|
|
440
|
+
send("#{name}_box", *args, **kwargs, &block)
|
|
441
|
+
elsif @document.config['layout.boxes.map'].key?(name_without_box)
|
|
442
|
+
box(name_without_box, *args, **kwargs, &block)
|
|
443
|
+
else
|
|
444
|
+
super
|
|
445
|
+
end
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
# :nodoc:
|
|
449
|
+
def respond_to_missing?(name, _private)
|
|
450
|
+
box_creation_method?(name) || super
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
# :nodoc:
|
|
454
|
+
def box_creation_method?(name)
|
|
455
|
+
name = name.to_s.sub(/_box$/, '').intern
|
|
456
|
+
BOX_METHOD_NAMES.include?(name) || @document.config['layout.boxes.map'].key?(name) ||
|
|
457
|
+
name == :box
|
|
458
|
+
end
|
|
459
|
+
|
|
377
460
|
private
|
|
378
461
|
|
|
379
462
|
# Returns the configured box class for the given +name+.
|
|
@@ -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-2023 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
|
|
@@ -94,11 +94,7 @@ module HexaPDF
|
|
|
94
94
|
def create(media_box: nil, orientation: nil)
|
|
95
95
|
media_box ||= @document.config['page.default_media_box']
|
|
96
96
|
orientation ||= @document.config['page.default_media_orientation']
|
|
97
|
-
box =
|
|
98
|
-
media_box
|
|
99
|
-
else
|
|
100
|
-
Type::Page.media_box(media_box, orientation: orientation)
|
|
101
|
-
end
|
|
97
|
+
box = Type::Page.media_box(media_box, orientation: orientation)
|
|
102
98
|
@document.add({Type: :Page, MediaBox: box})
|
|
103
99
|
end
|
|
104
100
|
|
data/lib/hexapdf/document.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-2023 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
|
|
@@ -325,7 +325,14 @@ module HexaPDF
|
|
|
325
325
|
type = (klass <= HexaPDF::Dictionary ? klass.type : nil)
|
|
326
326
|
else
|
|
327
327
|
type ||= deref(data.value[:Type]) if data.value.kind_of?(Hash)
|
|
328
|
-
|
|
328
|
+
if type
|
|
329
|
+
klass = GlobalConfiguration.constantize('object.type_map', type) { nil }
|
|
330
|
+
if (type == :ObjStm || type == :XRef) &&
|
|
331
|
+
klass.each_field.any? {|name, field| field.required? && !data.value.key?(name) }
|
|
332
|
+
data.value.delete(:Type)
|
|
333
|
+
klass = nil
|
|
334
|
+
end
|
|
335
|
+
end
|
|
329
336
|
end
|
|
330
337
|
|
|
331
338
|
if data.value.kind_of?(Hash)
|
|
@@ -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-2023 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
|
|
@@ -114,6 +114,7 @@ module HexaPDF
|
|
|
114
114
|
#
|
|
115
115
|
# See: PDF1.7 s7.6.2.
|
|
116
116
|
def decrypt(key, data)
|
|
117
|
+
return data if data.empty? # Handle invalid files with empty strings
|
|
117
118
|
if data.length % BLOCK_SIZE != 0 || data.length < BLOCK_SIZE
|
|
118
119
|
raise HexaPDF::EncryptionError, "Invalid data for decryption, need 32 + 16*n bytes"
|
|
119
120
|
end
|
|
@@ -132,6 +133,7 @@ module HexaPDF
|
|
|
132
133
|
while data.length < BLOCK_SIZE && source.alive? && (new_data = source.resume)
|
|
133
134
|
data << new_data
|
|
134
135
|
end
|
|
136
|
+
next data if data.empty? # Handle invalid files with empty stream
|
|
135
137
|
|
|
136
138
|
algorithm = new(key, data.slice!(0, BLOCK_SIZE), :decrypt)
|
|
137
139
|
|
|
@@ -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-2023 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-2023 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-2023 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-2023 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-2023 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
|