hexapdf 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +33 -0
- data/CONTRIBUTERS +1 -1
- data/LICENSE +1 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/hexapdf +1 -1
- data/examples/text_layouter_styling.rb +1 -2
- data/lib/hexapdf.rb +2 -2
- data/lib/hexapdf/cli.rb +3 -3
- data/lib/hexapdf/cli/batch.rb +5 -5
- data/lib/hexapdf/cli/command.rb +15 -17
- data/lib/hexapdf/cli/files.rb +3 -3
- data/lib/hexapdf/cli/images.rb +3 -4
- data/lib/hexapdf/cli/info.rb +5 -5
- data/lib/hexapdf/cli/inspect.rb +6 -6
- data/lib/hexapdf/cli/merge.rb +6 -6
- data/lib/hexapdf/cli/modify.rb +4 -4
- data/lib/hexapdf/cli/optimize.rb +3 -3
- data/lib/hexapdf/configuration.rb +4 -5
- data/lib/hexapdf/content.rb +2 -2
- data/lib/hexapdf/content/canvas.rb +35 -36
- data/lib/hexapdf/content/color_space.rb +9 -14
- data/lib/hexapdf/content/graphic_object.rb +2 -2
- data/lib/hexapdf/content/graphic_object/arc.rb +3 -3
- data/lib/hexapdf/content/graphic_object/endpoint_arc.rb +2 -2
- data/lib/hexapdf/content/graphic_object/solid_arc.rb +4 -8
- data/lib/hexapdf/content/graphics_state.rb +4 -13
- data/lib/hexapdf/content/operator.rb +33 -35
- data/lib/hexapdf/content/parser.rb +28 -18
- data/lib/hexapdf/content/processor.rb +4 -5
- data/lib/hexapdf/content/transformation_matrix.rb +2 -2
- data/lib/hexapdf/data_dir.rb +2 -2
- data/lib/hexapdf/dictionary.rb +8 -9
- data/lib/hexapdf/dictionary_fields.rb +7 -10
- data/lib/hexapdf/document.rb +18 -18
- data/lib/hexapdf/document/files.rb +12 -10
- data/lib/hexapdf/document/fonts.rb +2 -2
- data/lib/hexapdf/document/images.rb +3 -3
- data/lib/hexapdf/document/pages.rb +4 -4
- data/lib/hexapdf/encryption.rb +2 -2
- data/lib/hexapdf/encryption/aes.rb +2 -2
- data/lib/hexapdf/encryption/arc4.rb +4 -4
- data/lib/hexapdf/encryption/fast_aes.rb +2 -2
- data/lib/hexapdf/encryption/fast_arc4.rb +4 -4
- data/lib/hexapdf/encryption/identity.rb +5 -4
- data/lib/hexapdf/encryption/ruby_aes.rb +147 -139
- data/lib/hexapdf/encryption/ruby_arc4.rb +4 -4
- data/lib/hexapdf/encryption/security_handler.rb +11 -12
- data/lib/hexapdf/encryption/standard_security_handler.rb +6 -9
- data/lib/hexapdf/error.rb +7 -9
- data/lib/hexapdf/filter.rb +2 -3
- data/lib/hexapdf/filter/ascii85_decode.rb +3 -3
- data/lib/hexapdf/filter/ascii_hex_decode.rb +2 -2
- data/lib/hexapdf/filter/dct_decode.rb +2 -2
- data/lib/hexapdf/filter/encryption.rb +2 -2
- data/lib/hexapdf/filter/flate_decode.rb +16 -33
- data/lib/hexapdf/filter/jpx_decode.rb +2 -2
- data/lib/hexapdf/filter/lzw_decode.rb +4 -4
- data/lib/hexapdf/filter/predictor.rb +2 -6
- data/lib/hexapdf/filter/run_length_decode.rb +2 -2
- data/lib/hexapdf/font/cmap.rb +2 -3
- data/lib/hexapdf/font/cmap/parser.rb +11 -11
- data/lib/hexapdf/font/cmap/writer.rb +25 -25
- data/lib/hexapdf/font/encoding.rb +2 -2
- data/lib/hexapdf/font/encoding/base.rb +2 -2
- data/lib/hexapdf/font/encoding/difference_encoding.rb +2 -2
- data/lib/hexapdf/font/encoding/glyph_list.rb +6 -6
- data/lib/hexapdf/font/encoding/mac_expert_encoding.rb +2 -2
- data/lib/hexapdf/font/encoding/mac_roman_encoding.rb +2 -2
- data/lib/hexapdf/font/encoding/standard_encoding.rb +2 -2
- data/lib/hexapdf/font/encoding/symbol_encoding.rb +2 -2
- data/lib/hexapdf/font/encoding/win_ansi_encoding.rb +2 -2
- data/lib/hexapdf/font/encoding/zapf_dingbats_encoding.rb +2 -2
- data/lib/hexapdf/font/invalid_glyph.rb +7 -7
- data/lib/hexapdf/font/true_type.rb +2 -2
- data/lib/hexapdf/font/true_type/builder.rb +13 -7
- data/lib/hexapdf/font/true_type/font.rb +2 -3
- data/lib/hexapdf/font/true_type/optimizer.rb +2 -2
- data/lib/hexapdf/font/true_type/subsetter.rb +4 -4
- data/lib/hexapdf/font/true_type/table.rb +3 -5
- data/lib/hexapdf/font/true_type/table/cmap.rb +2 -2
- data/lib/hexapdf/font/true_type/table/cmap_subtable.rb +9 -16
- data/lib/hexapdf/font/true_type/table/directory.rb +4 -4
- data/lib/hexapdf/font/true_type/table/glyf.rb +2 -2
- data/lib/hexapdf/font/true_type/table/head.rb +3 -2
- data/lib/hexapdf/font/true_type/table/hhea.rb +2 -2
- data/lib/hexapdf/font/true_type/table/hmtx.rb +2 -2
- data/lib/hexapdf/font/true_type/table/kern.rb +3 -3
- data/lib/hexapdf/font/true_type/table/loca.rb +3 -3
- data/lib/hexapdf/font/true_type/table/maxp.rb +2 -2
- data/lib/hexapdf/font/true_type/table/name.rb +3 -5
- data/lib/hexapdf/font/true_type/table/os2.rb +4 -3
- data/lib/hexapdf/font/true_type/table/post.rb +3 -7
- data/lib/hexapdf/font/true_type_wrapper.rb +20 -22
- data/lib/hexapdf/font/type1.rb +2 -2
- data/lib/hexapdf/font/type1/afm_parser.rb +7 -7
- data/lib/hexapdf/font/type1/character_metrics.rb +2 -2
- data/lib/hexapdf/font/type1/font.rb +3 -3
- data/lib/hexapdf/font/type1/font_metrics.rb +2 -4
- data/lib/hexapdf/font/type1/pfb_parser.rb +2 -2
- data/lib/hexapdf/font/type1_wrapper.rb +8 -9
- data/lib/hexapdf/font_loader.rb +2 -2
- data/lib/hexapdf/font_loader/from_configuration.rb +2 -2
- data/lib/hexapdf/font_loader/from_file.rb +2 -2
- data/lib/hexapdf/font_loader/standard14.rb +2 -2
- data/lib/hexapdf/image_loader.rb +2 -2
- data/lib/hexapdf/image_loader/jpeg.rb +6 -4
- data/lib/hexapdf/image_loader/pdf.rb +2 -2
- data/lib/hexapdf/image_loader/png.rb +6 -6
- data/lib/hexapdf/importer.rb +6 -4
- data/lib/hexapdf/layout.rb +2 -2
- data/lib/hexapdf/layout/box.rb +4 -4
- data/lib/hexapdf/layout/inline_box.rb +2 -2
- data/lib/hexapdf/layout/line.rb +6 -6
- data/lib/hexapdf/layout/numeric_refinements.rb +2 -2
- data/lib/hexapdf/layout/style.rb +17 -8
- data/lib/hexapdf/layout/text_fragment.rb +86 -48
- data/lib/hexapdf/layout/text_layouter.rb +40 -21
- data/lib/hexapdf/layout/text_shaper.rb +2 -2
- data/lib/hexapdf/name_tree_node.rb +2 -2
- data/lib/hexapdf/number_tree_node.rb +2 -2
- data/lib/hexapdf/object.rb +6 -8
- data/lib/hexapdf/parser.rb +10 -10
- data/lib/hexapdf/rectangle.rb +4 -4
- data/lib/hexapdf/reference.rb +2 -2
- data/lib/hexapdf/revision.rb +4 -4
- data/lib/hexapdf/revisions.rb +5 -5
- data/lib/hexapdf/serializer.rb +27 -24
- data/lib/hexapdf/stream.rb +4 -4
- data/lib/hexapdf/task.rb +2 -2
- data/lib/hexapdf/task/dereference.rb +4 -4
- data/lib/hexapdf/task/optimize.rb +5 -4
- data/lib/hexapdf/tokenizer.rb +12 -14
- data/lib/hexapdf/type.rb +2 -2
- data/lib/hexapdf/type/action.rb +3 -3
- data/lib/hexapdf/type/actions.rb +2 -2
- data/lib/hexapdf/type/actions/go_to.rb +2 -2
- data/lib/hexapdf/type/actions/go_to_r.rb +2 -2
- data/lib/hexapdf/type/actions/launch.rb +2 -2
- data/lib/hexapdf/type/actions/uri.rb +3 -3
- data/lib/hexapdf/type/annotation.rb +3 -3
- data/lib/hexapdf/type/annotations.rb +2 -2
- data/lib/hexapdf/type/annotations/link.rb +2 -2
- data/lib/hexapdf/type/annotations/markup_annotation.rb +2 -2
- data/lib/hexapdf/type/annotations/text.rb +2 -2
- data/lib/hexapdf/type/catalog.rb +4 -4
- data/lib/hexapdf/type/cid_font.rb +4 -5
- data/lib/hexapdf/type/embedded_file.rb +3 -3
- data/lib/hexapdf/type/file_specification.rb +6 -7
- data/lib/hexapdf/type/font.rb +4 -4
- data/lib/hexapdf/type/font_descriptor.rb +3 -4
- data/lib/hexapdf/type/font_simple.rb +12 -16
- data/lib/hexapdf/type/font_true_type.rb +2 -2
- data/lib/hexapdf/type/font_type0.rb +5 -5
- data/lib/hexapdf/type/font_type1.rb +4 -4
- data/lib/hexapdf/type/form.rb +3 -3
- data/lib/hexapdf/type/graphics_state_parameter.rb +3 -3
- data/lib/hexapdf/type/image.rb +13 -14
- data/lib/hexapdf/type/info.rb +2 -2
- data/lib/hexapdf/type/names.rb +2 -2
- data/lib/hexapdf/type/object_stream.rb +5 -5
- data/lib/hexapdf/type/page.rb +9 -10
- data/lib/hexapdf/type/page_tree_node.rb +5 -6
- data/lib/hexapdf/type/resources.rb +11 -11
- data/lib/hexapdf/type/trailer.rb +3 -3
- data/lib/hexapdf/type/viewer_preferences.rb +2 -2
- data/lib/hexapdf/type/xref_stream.rb +8 -4
- data/lib/hexapdf/utils/bit_field.rb +4 -4
- data/lib/hexapdf/utils/bit_stream.rb +4 -4
- data/lib/hexapdf/utils/graphics_helpers.rb +2 -2
- data/lib/hexapdf/utils/lru_cache.rb +2 -2
- data/lib/hexapdf/utils/math_helpers.rb +2 -2
- data/lib/hexapdf/utils/object_hash.rb +3 -3
- data/lib/hexapdf/utils/pdf_doc_encoding.rb +3 -3
- data/lib/hexapdf/utils/sorted_tree_node.rb +12 -11
- data/lib/hexapdf/version.rb +3 -3
- data/lib/hexapdf/writer.rb +8 -8
- data/lib/hexapdf/xref_section.rb +3 -3
- data/test/hexapdf/common_tokenizer_tests.rb +6 -7
- data/test/hexapdf/content/graphic_object/test_endpoint_arc.rb +0 -1
- data/test/hexapdf/content/test_canvas.rb +28 -36
- data/test/hexapdf/content/test_color_space.rb +4 -0
- data/test/hexapdf/content/test_graphics_state.rb +2 -0
- data/test/hexapdf/content/test_operator.rb +6 -7
- data/test/hexapdf/content/test_parser.rb +2 -2
- data/test/hexapdf/content/test_processor.rb +1 -1
- data/test/hexapdf/document/test_files.rb +1 -0
- data/test/hexapdf/document/test_images.rb +1 -1
- data/test/hexapdf/encryption/common.rb +3 -3
- data/test/hexapdf/encryption/test_aes.rb +10 -4
- data/test/hexapdf/encryption/test_identity.rb +1 -1
- data/test/hexapdf/encryption/test_security_handler.rb +13 -17
- data/test/hexapdf/encryption/test_standard_security_handler.rb +12 -12
- data/test/hexapdf/filter/test_ascii85_decode.rb +2 -3
- data/test/hexapdf/filter/test_ascii_hex_decode.rb +6 -1
- data/test/hexapdf/filter/test_flate_decode.rb +2 -2
- data/test/hexapdf/filter/test_lzw_decode.rb +10 -10
- data/test/hexapdf/filter/test_predictor.rb +10 -2
- data/test/hexapdf/filter/test_run_length_decode.rb +1 -1
- data/test/hexapdf/font/cmap/test_parser.rb +40 -40
- data/test/hexapdf/font/cmap/test_writer.rb +29 -29
- data/test/hexapdf/font/test_true_type_wrapper.rb +3 -2
- data/test/hexapdf/font/true_type/common.rb +2 -0
- data/test/hexapdf/font/true_type/table/test_cmap.rb +1 -1
- data/test/hexapdf/font/true_type/table/test_cmap_subtable.rb +5 -4
- data/test/hexapdf/font/true_type/table/test_glyf.rb +2 -2
- data/test/hexapdf/font/true_type/table/test_head.rb +2 -2
- data/test/hexapdf/font/true_type/table/test_name.rb +9 -6
- data/test/hexapdf/font/true_type/test_builder.rb +8 -3
- data/test/hexapdf/font/true_type/test_optimizer.rb +1 -2
- data/test/hexapdf/font/type1/test_afm_parser.rb +2 -2
- data/test/hexapdf/image_loader/test_jpeg.rb +1 -1
- data/test/hexapdf/image_loader/test_pdf.rb +1 -1
- data/test/hexapdf/image_loader/test_png.rb +3 -3
- data/test/hexapdf/layout/test_inline_box.rb +10 -1
- data/test/hexapdf/layout/test_line.rb +4 -4
- data/test/hexapdf/layout/test_style.rb +19 -7
- data/test/hexapdf/layout/test_text_fragment.rb +73 -27
- data/test/hexapdf/layout/test_text_layouter.rb +84 -68
- data/test/hexapdf/layout/test_text_shaper.rb +4 -6
- data/test/hexapdf/task/test_dereference.rb +2 -2
- data/test/hexapdf/task/test_optimize.rb +16 -7
- data/test/hexapdf/test_configuration.rb +1 -1
- data/test/hexapdf/test_data_dir.rb +2 -2
- data/test/hexapdf/test_dictionary.rb +6 -3
- data/test/hexapdf/test_dictionary_fields.rb +15 -14
- data/test/hexapdf/test_document.rb +47 -48
- data/test/hexapdf/test_filter.rb +30 -26
- data/test/hexapdf/test_importer.rb +14 -0
- data/test/hexapdf/test_object.rb +16 -4
- data/test/hexapdf/test_parser.rb +36 -36
- data/test/hexapdf/test_reference.rb +7 -5
- data/test/hexapdf/test_revision.rb +1 -1
- data/test/hexapdf/test_revisions.rb +90 -90
- data/test/hexapdf/test_serializer.rb +3 -2
- data/test/hexapdf/test_stream.rb +2 -4
- data/test/hexapdf/test_tokenizer.rb +2 -2
- data/test/hexapdf/test_writer.rb +80 -80
- data/test/hexapdf/test_xref_section.rb +1 -1
- data/test/hexapdf/type/annotations/test_link.rb +1 -1
- data/test/hexapdf/type/annotations/test_text.rb +3 -3
- data/test/hexapdf/type/test_font_descriptor.rb +1 -1
- data/test/hexapdf/type/test_font_simple.rb +2 -2
- data/test/hexapdf/type/test_font_type0.rb +0 -1
- data/test/hexapdf/type/test_image.rb +0 -3
- data/test/hexapdf/type/test_object_stream.rb +2 -1
- data/test/hexapdf/type/test_page.rb +5 -1
- data/test/hexapdf/type/test_page_tree_node.rb +4 -4
- data/test/hexapdf/type/test_trailer.rb +1 -1
- data/test/hexapdf/type/test_xref_stream.rb +4 -0
- data/test/hexapdf/utils/test_bit_field.rb +2 -0
- data/test/hexapdf/utils/test_bit_stream.rb +1 -1
- data/test/hexapdf/utils/test_lru_cache.rb +1 -1
- data/test/hexapdf/utils/test_sorted_tree_node.rb +10 -4
- data/test/test_helper.rb +3 -6
- metadata +3 -3
data/lib/hexapdf/cli/modify.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
#--
|
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-2018 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
|
@@ -49,7 +49,7 @@ module HexaPDF
|
|
49
49
|
def initialize #:nodoc:
|
50
50
|
super('modify', takes_commands: false)
|
51
51
|
short_desc("Modify a PDF file")
|
52
|
-
long_desc(
|
52
|
+
long_desc(<<~EOF)
|
53
53
|
This command modifies a PDF file. It can be used to select pages that should appear in
|
54
54
|
the output file and/or rotate them. The output file can also be encrypted/decrypted and
|
55
55
|
optimized in various ways.
|
@@ -79,7 +79,7 @@ module HexaPDF
|
|
79
79
|
maybe_raise_on_existing_file(out_file)
|
80
80
|
with_document(in_file, password: @password, out_file: out_file) do |doc|
|
81
81
|
arrange_pages(doc) unless @pages == '1-e'
|
82
|
-
@embed_files.each {|file| doc.files.add(file, embed: true)}
|
82
|
+
@embed_files.each {|file| doc.files.add(file, embed: true) }
|
83
83
|
apply_encryption_options(doc)
|
84
84
|
apply_optimization_options(doc)
|
85
85
|
end
|
data/lib/hexapdf/cli/optimize.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
#--
|
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-2018 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
|
@@ -42,7 +42,7 @@ module HexaPDF
|
|
42
42
|
def initialize #:nodoc:
|
43
43
|
super('optimize', takes_commands: false)
|
44
44
|
short_desc("Optimize the size of a PDF file")
|
45
|
-
long_desc(
|
45
|
+
long_desc(<<~EOF)
|
46
46
|
This command uses several optimization strategies to reduce the file size of the PDF file.
|
47
47
|
|
48
48
|
By default, all strategies except page compression are used since page compression may
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
#--
|
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-2018 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
|
@@ -58,7 +58,6 @@ module HexaPDF
|
|
58
58
|
DefaultDocumentConfiguration.merge(values)
|
59
59
|
end
|
60
60
|
|
61
|
-
|
62
61
|
# Creates a new Configuration object using the provided hash argument.
|
63
62
|
def initialize(options = {})
|
64
63
|
@options = options
|
@@ -68,7 +67,7 @@ module HexaPDF
|
|
68
67
|
def key?(name)
|
69
68
|
options.key?(name)
|
70
69
|
end
|
71
|
-
alias
|
70
|
+
alias option? key?
|
72
71
|
|
73
72
|
# Returns the value for the configuration option +name+.
|
74
73
|
def [](name)
|
@@ -122,7 +121,7 @@ module HexaPDF
|
|
122
121
|
if data.nil? && block_given?
|
123
122
|
data = yield(name)
|
124
123
|
elsif data.nil?
|
125
|
-
raise HexaPDF::Error, "Error getting constant for configuration option '#{name}'"
|
124
|
+
raise HexaPDF::Error, "Error getting constant for configuration option '#{name}'" +
|
126
125
|
(keys.empty? ? "" : " and keys '#{keys.join(', ')}'")
|
127
126
|
end
|
128
127
|
data
|
data/lib/hexapdf/content.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
#--
|
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-2018 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
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
#--
|
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-2018 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
|
@@ -463,7 +463,7 @@ module HexaPDF
|
|
463
463
|
def line_width(width = nil, &block)
|
464
464
|
gs_getter_setter(:line_width, :w, width, &block)
|
465
465
|
end
|
466
|
-
alias
|
466
|
+
alias line_width= line_width
|
467
467
|
|
468
468
|
# :call-seq:
|
469
469
|
# canvas.line_cap_style => current_line_cap_style
|
@@ -497,7 +497,7 @@ module HexaPDF
|
|
497
497
|
def line_cap_style(style = nil, &block)
|
498
498
|
gs_getter_setter(:line_cap_style, :J, style && LineCapStyle.normalize(style), &block)
|
499
499
|
end
|
500
|
-
alias
|
500
|
+
alias line_cap_style= line_cap_style
|
501
501
|
|
502
502
|
# :call-seq:
|
503
503
|
# canvas.line_join_style => current_line_join_style
|
@@ -531,7 +531,7 @@ module HexaPDF
|
|
531
531
|
def line_join_style(style = nil, &block)
|
532
532
|
gs_getter_setter(:line_join_style, :j, style && LineJoinStyle.normalize(style), &block)
|
533
533
|
end
|
534
|
-
alias
|
534
|
+
alias line_join_style= line_join_style
|
535
535
|
|
536
536
|
# :call-seq:
|
537
537
|
# canvas.miter_limit => current_miter_limit
|
@@ -564,7 +564,7 @@ module HexaPDF
|
|
564
564
|
def miter_limit(limit = nil, &block)
|
565
565
|
gs_getter_setter(:miter_limit, :M, limit, &block)
|
566
566
|
end
|
567
|
-
alias
|
567
|
+
alias miter_limit= miter_limit
|
568
568
|
|
569
569
|
# :call-seq:
|
570
570
|
# canvas.line_dash_pattern => current_line_dash_pattern
|
@@ -613,7 +613,7 @@ module HexaPDF
|
|
613
613
|
gs_getter_setter(:line_dash_pattern, :d, value && LineDashPattern.normalize(value, phase),
|
614
614
|
&block)
|
615
615
|
end
|
616
|
-
alias
|
616
|
+
alias line_dash_pattern= line_dash_pattern
|
617
617
|
|
618
618
|
# :call-seq:
|
619
619
|
# canvas.rendering_intent => current_rendering_intent
|
@@ -651,7 +651,7 @@ module HexaPDF
|
|
651
651
|
def rendering_intent(intent = nil, &bk)
|
652
652
|
gs_getter_setter(:rendering_intent, :ri, intent && RenderingIntent.normalize(intent), &bk)
|
653
653
|
end
|
654
|
-
alias
|
654
|
+
alias rendering_intent= rendering_intent
|
655
655
|
|
656
656
|
# :call-seq:
|
657
657
|
# canvas.stroke_color => current_stroke_color
|
@@ -718,7 +718,7 @@ module HexaPDF
|
|
718
718
|
def stroke_color(*color, &block)
|
719
719
|
color_getter_setter(:stroke_color, color, :RG, :G, :K, :CS, :SCN, &block)
|
720
720
|
end
|
721
|
-
alias
|
721
|
+
alias stroke_color= stroke_color
|
722
722
|
|
723
723
|
# The fill color defines the color used for non-stroking operations, i.e. for filling paths.
|
724
724
|
#
|
@@ -727,7 +727,7 @@ module HexaPDF
|
|
727
727
|
def fill_color(*color, &block)
|
728
728
|
color_getter_setter(:fill_color, color, :rg, :g, :k, :cs, :scn, &block)
|
729
729
|
end
|
730
|
-
alias
|
730
|
+
alias fill_color= fill_color
|
731
731
|
|
732
732
|
# :call-seq:
|
733
733
|
# canvas.opacity => current_values
|
@@ -956,7 +956,7 @@ module HexaPDF
|
|
956
956
|
check_poly_points(points)
|
957
957
|
move_to(*point_on_line(points[0], points[1], points[2], points[3], distance: radius))
|
958
958
|
points.concat(points[0, 4])
|
959
|
-
0.step(points.length - 6, 2) {|i| line_with_rounded_corner(*points[i, 6], radius)}
|
959
|
+
0.step(points.length - 6, 2) {|i| line_with_rounded_corner(*points[i, 6], radius) }
|
960
960
|
end
|
961
961
|
close_subpath
|
962
962
|
end
|
@@ -1085,7 +1085,7 @@ module HexaPDF
|
|
1085
1085
|
unless obj.respond_to?(:configure)
|
1086
1086
|
obj = context.document.config.constantize('graphic_object.map', obj)
|
1087
1087
|
end
|
1088
|
-
obj = obj.configure(options)
|
1088
|
+
obj = obj.configure(options) unless options.empty? && obj.respond_to?(:draw)
|
1089
1089
|
obj
|
1090
1090
|
end
|
1091
1091
|
|
@@ -1276,7 +1276,7 @@ module HexaPDF
|
|
1276
1276
|
|
1277
1277
|
obj
|
1278
1278
|
end
|
1279
|
-
alias
|
1279
|
+
alias image xobject
|
1280
1280
|
|
1281
1281
|
# :call-seq:
|
1282
1282
|
# canvas.character_spacing => current_character_spacing
|
@@ -1310,7 +1310,7 @@ module HexaPDF
|
|
1310
1310
|
def character_spacing(amount = nil, &bk)
|
1311
1311
|
gs_getter_setter(:character_spacing, :Tc, amount, &bk)
|
1312
1312
|
end
|
1313
|
-
alias
|
1313
|
+
alias character_spacing= character_spacing
|
1314
1314
|
|
1315
1315
|
# :call-seq:
|
1316
1316
|
# canvas.word_spacing => current_word_spacing
|
@@ -1347,7 +1347,7 @@ module HexaPDF
|
|
1347
1347
|
def word_spacing(amount = nil, &bk)
|
1348
1348
|
gs_getter_setter(:word_spacing, :Tw, amount, &bk)
|
1349
1349
|
end
|
1350
|
-
alias
|
1350
|
+
alias word_spacing= word_spacing
|
1351
1351
|
|
1352
1352
|
# :call-seq:
|
1353
1353
|
# canvas.horizontal_scaling => current_horizontal_scaling
|
@@ -1381,7 +1381,7 @@ module HexaPDF
|
|
1381
1381
|
def horizontal_scaling(amount = nil, &bk)
|
1382
1382
|
gs_getter_setter(:horizontal_scaling, :Tz, amount, &bk)
|
1383
1383
|
end
|
1384
|
-
alias
|
1384
|
+
alias horizontal_scaling= horizontal_scaling
|
1385
1385
|
|
1386
1386
|
# :call-seq:
|
1387
1387
|
# canvas.leading => current_leading
|
@@ -1412,7 +1412,7 @@ module HexaPDF
|
|
1412
1412
|
def leading(amount = nil, &bk)
|
1413
1413
|
gs_getter_setter(:leading, :TL, amount, &bk)
|
1414
1414
|
end
|
1415
|
-
alias
|
1415
|
+
alias leading= leading
|
1416
1416
|
|
1417
1417
|
# :call-seq:
|
1418
1418
|
# canvas.text_rendering_mode => current_text_rendering_mode
|
@@ -1448,7 +1448,7 @@ module HexaPDF
|
|
1448
1448
|
def text_rendering_mode(m = nil, &bk)
|
1449
1449
|
gs_getter_setter(:text_rendering_mode, :Tr, m && TextRenderingMode.normalize(m), &bk)
|
1450
1450
|
end
|
1451
|
-
alias
|
1451
|
+
alias text_rendering_mode= text_rendering_mode
|
1452
1452
|
|
1453
1453
|
# :call-seq:
|
1454
1454
|
# canvas.text_rise => current_text_rise
|
@@ -1480,7 +1480,7 @@ module HexaPDF
|
|
1480
1480
|
def text_rise(amount = nil, &bk)
|
1481
1481
|
gs_getter_setter(:text_rise, :Ts, amount, &bk)
|
1482
1482
|
end
|
1483
|
-
alias
|
1483
|
+
alias text_rise= text_rise
|
1484
1484
|
|
1485
1485
|
# :call-seq:
|
1486
1486
|
# canvas.begin_text(force_new: false) -> canvas
|
@@ -1620,42 +1620,37 @@ module HexaPDF
|
|
1620
1620
|
@font
|
1621
1621
|
end
|
1622
1622
|
end
|
1623
|
-
alias
|
1623
|
+
alias font= font
|
1624
1624
|
|
1625
1625
|
# :call-seq:
|
1626
|
-
# canvas.font_size
|
1627
|
-
# canvas.font_size(size
|
1626
|
+
# canvas.font_size => font_size
|
1627
|
+
# canvas.font_size(size => canvas
|
1628
1628
|
#
|
1629
1629
|
# Specifies the font size.
|
1630
1630
|
#
|
1631
1631
|
# Note that an error is raised if no font has been set before!
|
1632
1632
|
#
|
1633
|
-
# The leading can be additionally set and defaults to the font size times 1.2. If the leading
|
1634
|
-
# should not be changed, +nil+ has to be passed for +leading+.
|
1635
|
-
#
|
1636
1633
|
# Returns the current font size when no argument is given.
|
1637
1634
|
#
|
1638
1635
|
# Examples:
|
1639
1636
|
#
|
1640
1637
|
# canvas.font_size(12)
|
1641
1638
|
# canvas.font_size # => 12
|
1642
|
-
# canvas.font_size(12, leading: 20)
|
1643
1639
|
# canvas.font_size = 12
|
1644
1640
|
#
|
1645
1641
|
# See: PDF1.7 s9.2.2
|
1646
|
-
def font_size(size = nil
|
1642
|
+
def font_size(size = nil)
|
1647
1643
|
if size
|
1648
1644
|
unless @font
|
1649
1645
|
raise HexaPDF::Error, "A font needs to be set before the font size can be set"
|
1650
1646
|
end
|
1651
1647
|
invoke_font_operator(@font.dict, size)
|
1652
|
-
self.leading(leading) if leading
|
1653
1648
|
self
|
1654
1649
|
else
|
1655
1650
|
graphics_state.font_size
|
1656
1651
|
end
|
1657
1652
|
end
|
1658
|
-
alias
|
1653
|
+
alias font_size= font_size
|
1659
1654
|
|
1660
1655
|
# :call-seq:
|
1661
1656
|
# canvas.text(text) -> canvas
|
@@ -1705,6 +1700,7 @@ module HexaPDF
|
|
1705
1700
|
#
|
1706
1701
|
# This method is usually not invoked directly but by higher level methods like #text.
|
1707
1702
|
def show_glyphs(glyphs)
|
1703
|
+
return if glyphs.empty?
|
1708
1704
|
raise_unless_font_set
|
1709
1705
|
begin_text
|
1710
1706
|
|
@@ -1720,7 +1716,7 @@ module HexaPDF
|
|
1720
1716
|
|
1721
1717
|
offset += item.width * graphics_state.scaled_font_size +
|
1722
1718
|
graphics_state.scaled_character_spacing
|
1723
|
-
offset += graphics_state.scaled_word_spacing if encoded == " "
|
1719
|
+
offset += graphics_state.scaled_word_spacing if encoded == " "
|
1724
1720
|
end
|
1725
1721
|
end
|
1726
1722
|
|
@@ -1741,19 +1737,22 @@ module HexaPDF
|
|
1741
1737
|
# #text_cursor and other methods using the current text matrix are invalid until the next call
|
1742
1738
|
# to #text_matrix or #end_text.
|
1743
1739
|
def show_glyphs_only(glyphs)
|
1740
|
+
return if glyphs.empty?
|
1744
1741
|
raise_unless_font_set
|
1745
1742
|
begin_text
|
1746
1743
|
|
1747
|
-
|
1744
|
+
simple = true
|
1745
|
+
result = [last = ''.b]
|
1748
1746
|
glyphs.each do |item|
|
1749
1747
|
if item.kind_of?(Numeric)
|
1750
|
-
|
1748
|
+
simple = false
|
1749
|
+
result << item << (last = ''.b)
|
1751
1750
|
else
|
1752
|
-
|
1751
|
+
last << @font.encode(item)
|
1753
1752
|
end
|
1754
1753
|
end
|
1755
1754
|
|
1756
|
-
serialize1(:TJ, result)
|
1755
|
+
simple ? serialize1(:Tj, result[0]) : serialize1(:TJ, result)
|
1757
1756
|
self
|
1758
1757
|
end
|
1759
1758
|
|
@@ -1898,7 +1897,7 @@ module HexaPDF
|
|
1898
1897
|
|
1899
1898
|
# Invokes the font operator using the given PDF font dictionary.
|
1900
1899
|
def invoke_font_operator(font, font_size)
|
1901
|
-
|
1900
|
+
unless graphics_state.font == font && graphics_state.font_size == font_size
|
1902
1901
|
invoke(:Tf, resources.add_font(font), font_size)
|
1903
1902
|
end
|
1904
1903
|
end
|
@@ -1962,7 +1961,7 @@ module HexaPDF
|
|
1962
1961
|
# Utility method that abstracts the implementation of the stroke and fill color methods.
|
1963
1962
|
def color_getter_setter(name, color, rg, g, k, cs, scn)
|
1964
1963
|
color.flatten!
|
1965
|
-
if color.
|
1964
|
+
if !color.empty?
|
1966
1965
|
raise_unless_at_page_description_level_or_in_text
|
1967
1966
|
color = color_from_specification(color)
|
1968
1967
|
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
# -*- encoding: utf-8; frozen_string_literal: true -*-
|
2
2
|
#
|
3
3
|
#--
|
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-2018 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
|
@@ -156,23 +156,20 @@ module HexaPDF
|
|
156
156
|
# Returns the specific Universal color space used for this color.
|
157
157
|
attr_reader :color_space
|
158
158
|
|
159
|
+
# Returns the componets of the universal color, i.e. all arguments provided on
|
160
|
+
# initialization.
|
161
|
+
attr_reader :components
|
162
|
+
|
159
163
|
# Creates a new universal color with the given components.
|
160
164
|
def initialize(color_space, *components)
|
161
165
|
@color_space = color_space
|
162
166
|
@components = components
|
163
167
|
end
|
164
168
|
|
165
|
-
# Returns the componets of the universal color, i.e. all arguments provided on
|
166
|
-
# initialization.
|
167
|
-
def components
|
168
|
-
@components
|
169
|
-
end
|
170
|
-
|
171
169
|
end
|
172
170
|
|
173
171
|
end
|
174
172
|
|
175
|
-
|
176
173
|
# The DeviceRGB color space.
|
177
174
|
class DeviceRGB
|
178
175
|
|
@@ -180,7 +177,7 @@ module HexaPDF
|
|
180
177
|
DEFAULT = new
|
181
178
|
|
182
179
|
# Returns the DeviceRGB color space object.
|
183
|
-
def self.new
|
180
|
+
def self.new(_definition = nil)
|
184
181
|
DEFAULT
|
185
182
|
end
|
186
183
|
|
@@ -234,7 +231,6 @@ module HexaPDF
|
|
234
231
|
|
235
232
|
end
|
236
233
|
|
237
|
-
|
238
234
|
# The DeviceCMYK color space.
|
239
235
|
class DeviceCMYK
|
240
236
|
|
@@ -242,7 +238,7 @@ module HexaPDF
|
|
242
238
|
DEFAULT = new
|
243
239
|
|
244
240
|
# Returns the DeviceCMYK color space object.
|
245
|
-
def self.new
|
241
|
+
def self.new(_definition = nil)
|
246
242
|
DEFAULT
|
247
243
|
end
|
248
244
|
|
@@ -298,7 +294,6 @@ module HexaPDF
|
|
298
294
|
|
299
295
|
end
|
300
296
|
|
301
|
-
|
302
297
|
# The DeviceGray color space.
|
303
298
|
class DeviceGray
|
304
299
|
|
@@ -306,7 +301,7 @@ module HexaPDF
|
|
306
301
|
DEFAULT = new
|
307
302
|
|
308
303
|
# Returns the DeviceGray color space object.
|
309
|
-
def self.new
|
304
|
+
def self.new(_definition = nil)
|
310
305
|
DEFAULT
|
311
306
|
end
|
312
307
|
|