hexapdf 0.23.0 → 0.24.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 +66 -0
- data/LICENSE +1 -1
- data/Rakefile +1 -1
- data/examples/016-frame_automatic_box_placement.rb +7 -2
- data/examples/017-frame_text_flow.rb +10 -18
- data/examples/020-column_box.rb +40 -0
- data/examples/021-list_box.rb +26 -0
- data/lib/hexapdf/cli/batch.rb +1 -1
- data/lib/hexapdf/cli/command.rb +1 -1
- data/lib/hexapdf/cli/files.rb +1 -1
- data/lib/hexapdf/cli/fonts.rb +1 -1
- data/lib/hexapdf/cli/form.rb +2 -2
- data/lib/hexapdf/cli/image2pdf.rb +1 -1
- data/lib/hexapdf/cli/images.rb +1 -1
- data/lib/hexapdf/cli/info.rb +2 -2
- data/lib/hexapdf/cli/inspect.rb +2 -2
- 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 +45 -126
- data/lib/hexapdf/configuration.rb +17 -1
- 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 +2 -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/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 +397 -0
- data/lib/hexapdf/document/pages.rb +17 -1
- data/lib/hexapdf/document/signatures.rb +5 -4
- data/lib/hexapdf/document.rb +8 -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 +30 -21
- data/lib/hexapdf/encryption/identity.rb +1 -1
- data/lib/hexapdf/encryption/ruby_aes.rb +1 -1
- data/lib/hexapdf/encryption/ruby_arc4.rb +1 -1
- data/lib/hexapdf/encryption/security_handler.rb +1 -1
- data/lib/hexapdf/encryption/standard_security_handler.rb +1 -1
- data/lib/hexapdf/encryption.rb +1 -1
- data/lib/hexapdf/error.rb +1 -1
- data/lib/hexapdf/filter/ascii85_decode.rb +1 -1
- data/lib/hexapdf/filter/ascii_hex_decode.rb +1 -1
- data/lib/hexapdf/filter/crypt.rb +1 -1
- data/lib/hexapdf/filter/encryption.rb +1 -1
- data/lib/hexapdf/filter/flate_decode.rb +1 -1
- data/lib/hexapdf/filter/lzw_decode.rb +1 -1
- data/lib/hexapdf/filter/pass_through.rb +1 -1
- data/lib/hexapdf/filter/predictor.rb +1 -1
- data/lib/hexapdf/filter/run_length_decode.rb +1 -1
- data/lib/hexapdf/filter.rb +1 -1
- data/lib/hexapdf/font/cmap/parser.rb +1 -1
- data/lib/hexapdf/font/cmap/writer.rb +1 -1
- data/lib/hexapdf/font/cmap.rb +1 -1
- data/lib/hexapdf/font/encoding/base.rb +1 -1
- data/lib/hexapdf/font/encoding/difference_encoding.rb +1 -1
- data/lib/hexapdf/font/encoding/glyph_list.rb +2 -2
- 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 +121 -22
- data/lib/hexapdf/layout/box_fitter.rb +136 -0
- data/lib/hexapdf/layout/column_box.rb +247 -0
- data/lib/hexapdf/layout/frame.rb +155 -139
- data/lib/hexapdf/layout/image_box.rb +19 -4
- data/lib/hexapdf/layout/inline_box.rb +1 -1
- data/lib/hexapdf/layout/line.rb +1 -1
- data/lib/hexapdf/layout/list_box.rb +355 -0
- data/lib/hexapdf/layout/numeric_refinements.rb +1 -1
- data/lib/hexapdf/layout/style.rb +5 -1
- data/lib/hexapdf/layout/text_box.rb +20 -9
- data/lib/hexapdf/layout/text_fragment.rb +3 -2
- data/lib/hexapdf/layout/text_layouter.rb +17 -2
- data/lib/hexapdf/layout/text_shaper.rb +1 -1
- data/lib/hexapdf/layout/width_from_polygon.rb +12 -7
- data/lib/hexapdf/layout.rb +4 -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 -8
- data/lib/hexapdf/pdf_array.rb +1 -1
- data/lib/hexapdf/rectangle.rb +1 -1
- data/lib/hexapdf/reference.rb +1 -1
- data/lib/hexapdf/revision.rb +1 -1
- data/lib/hexapdf/revisions.rb +1 -1
- data/lib/hexapdf/serializer.rb +1 -1
- data/lib/hexapdf/stream.rb +1 -1
- data/lib/hexapdf/task/dereference.rb +1 -1
- data/lib/hexapdf/task/optimize.rb +1 -1
- data/lib/hexapdf/task.rb +1 -1
- data/lib/hexapdf/tokenizer.rb +1 -1
- data/lib/hexapdf/type/acro_form/appearance_generator.rb +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/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 +19 -2
- data/lib/hexapdf/type/resources.rb +1 -1
- data/lib/hexapdf/type/signature/adbe_pkcs7_detached.rb +1 -1
- data/lib/hexapdf/type/signature/adbe_x509_rsa_sha1.rb +1 -1
- data/lib/hexapdf/type/signature/handler.rb +1 -1
- data/lib/hexapdf/type/signature/verification_result.rb +1 -1
- data/lib/hexapdf/type/signature.rb +1 -1
- data/lib/hexapdf/type/trailer.rb +2 -2
- data/lib/hexapdf/type/viewer_preferences.rb +1 -1
- data/lib/hexapdf/type/xref_stream.rb +1 -1
- data/lib/hexapdf/type.rb +1 -1
- data/lib/hexapdf/utils/bit_field.rb +1 -1
- data/lib/hexapdf/utils/bit_stream.rb +1 -1
- data/lib/hexapdf/utils/graphics_helpers.rb +1 -1
- data/lib/hexapdf/utils/lru_cache.rb +1 -1
- data/lib/hexapdf/utils/math_helpers.rb +1 -1
- data/lib/hexapdf/utils/object_hash.rb +1 -1
- data/lib/hexapdf/utils/pdf_doc_encoding.rb +1 -1
- data/lib/hexapdf/utils/sorted_tree_node.rb +1 -1
- data/lib/hexapdf/version.rb +2 -2
- data/lib/hexapdf/writer.rb +9 -7
- data/lib/hexapdf/xref_section.rb +1 -1
- data/lib/hexapdf.rb +1 -1
- data/test/hexapdf/content/graphic_object/test_geom2d.rb +1 -1
- data/test/hexapdf/document/test_destinations.rb +1 -1
- data/test/hexapdf/document/test_images.rb +1 -1
- data/test/hexapdf/document/test_layout.rb +264 -0
- data/test/hexapdf/document/test_pages.rb +9 -0
- data/test/hexapdf/document/test_signatures.rb +10 -3
- data/test/hexapdf/encryption/test_security_handler.rb +1 -1
- data/test/hexapdf/font/encoding/test_glyph_list.rb +4 -0
- data/test/hexapdf/layout/test_box.rb +53 -3
- data/test/hexapdf/layout/test_box_fitter.rb +62 -0
- data/test/hexapdf/layout/test_column_box.rb +159 -0
- data/test/hexapdf/layout/test_frame.rb +99 -38
- data/test/hexapdf/layout/test_image_box.rb +1 -1
- data/test/hexapdf/layout/test_list_box.rb +249 -0
- data/test/hexapdf/layout/test_text_box.rb +17 -2
- data/test/hexapdf/layout/test_text_fragment.rb +1 -1
- data/test/hexapdf/layout/test_text_layouter.rb +42 -17
- data/test/hexapdf/layout/test_width_from_polygon.rb +13 -0
- data/test/hexapdf/test_composer.rb +11 -0
- data/test/hexapdf/test_dictionary_fields.rb +9 -9
- data/test/hexapdf/test_document.rb +4 -4
- data/test/hexapdf/test_filter.rb +1 -1
- data/test/hexapdf/test_parser.rb +0 -2
- data/test/hexapdf/test_revisions.rb +2 -2
- data/test/hexapdf/test_serializer.rb +1 -5
- data/test/hexapdf/test_writer.rb +58 -3
- data/test/hexapdf/type/test_page_tree_node.rb +21 -1
- data/test/hexapdf/type/test_trailer.rb +3 -3
- data/test/test_helper.rb +5 -1
- metadata +28 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9be9871c8033a23eb240dc0b6300bcb33ba8ccef107f35189cb8af3faf308a61
|
|
4
|
+
data.tar.gz: 875797999dc46cefdb39dd31f1649525a11716915af5a83a6c38c0dc100cca2e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8700678297a316b14a604045ab7da8c371d7cbcebb771d8c878fff4306e36ff7e72b898fb4c63e98599493a7b93480a34bd099dc102ef0e431d825fe1e11ae41
|
|
7
|
+
data.tar.gz: 4892bb8868475b4bfe65c5938097589f9544bb4b7b9bef568b1ac60a7932eced09f2eee53edc38212654e522c4cc4e5edd8fde7cb6b6078e27ccf18e131e96aa
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,69 @@
|
|
|
1
|
+
## 0.24.0 - 2022-08-01
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
* [HexaPDF::Layout::ListBox] for rendering ordered and unordered lists
|
|
6
|
+
* [HexaPDF::Layout::ColumnBox] for rendering content inside columns
|
|
7
|
+
* [HexaPDF::Layout::BoxFitter] for placing boxes into multiple frames
|
|
8
|
+
* New configuration option 'debug' for enabling debug output
|
|
9
|
+
* [HexaPDF::Document::Pages#move] for moving pages around the same document
|
|
10
|
+
* [HexaPDF::Composer#box] for drawing arbitrary, registered boxes
|
|
11
|
+
* [HexaPDF::Layout::Box#split_box?] for determining whether a box is a split
|
|
12
|
+
box, i.e. the continuation of another box
|
|
13
|
+
* [HexaPDF::Document::Layout::ChildrenCollector] to provide an easy method for
|
|
14
|
+
defining children boxes of a container box
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
* **Breaking change**: Refactored [HexaPDF::Layout::Frame] and associated data
|
|
19
|
+
structures so that the complete result of fitting a box is returned
|
|
20
|
+
* [HexaPDF::Layout::Frame] to use a better algorithm for trimming the shape
|
|
21
|
+
* [HexaPDF::Layout::Frame::new] to allow setting the initial shape
|
|
22
|
+
* **Breaking change**: Removed contour line from [HexaPDF::Layout::Frame]
|
|
23
|
+
* **Breaking change**: Changed positional arguments of
|
|
24
|
+
[HexaPDF::Layout::TextBox::new] and [HexaPDF::Layout::ImageBox::new] to
|
|
25
|
+
keyword arguments for a consistent box initialization interface
|
|
26
|
+
* [HexaPDF::Layout::Box#split] to provide a default implementation that is
|
|
27
|
+
useful for most subclasses
|
|
28
|
+
* Layout box implementations to provide a `#supports_position_flow?` method that
|
|
29
|
+
indicates whether the box supports flowing its content around other content.
|
|
30
|
+
* `hexapdf info --check` to only check the current version of each object
|
|
31
|
+
* [HexaPDF::Writer] to make sure the producer information is written when
|
|
32
|
+
writing the file incrementally
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
* [HexaPDF::Layout::TextLayouter] to freeze the new items when a text fragment
|
|
37
|
+
needs to be split
|
|
38
|
+
* [HexaPDF::Layout::TextLayouter] to avoid the possible splitting of a text
|
|
39
|
+
fragment if there would not be enough height left anyway
|
|
40
|
+
* [HexaPDF::Layout::WidthFromPolygon] to work correctly in case of very small
|
|
41
|
+
floating point errors
|
|
42
|
+
* HexaPDF::Layout::TextFragment#inspect to work in case of interspersed
|
|
43
|
+
numbers
|
|
44
|
+
* [HexaPDF::Layout::TextBox#split] to work for position :flow when box is wider
|
|
45
|
+
than the initial available width
|
|
46
|
+
* [HexaPDF::Layout::Frame#fit] to create minimally sized mask rectangles
|
|
47
|
+
* [HexaPDF::Content::GraphicObject::Geom2D] to close the path when drawing
|
|
48
|
+
polygons
|
|
49
|
+
* [HexaPDF::Layout::WidthFromPolygon] to work for all counterclockwise polygons
|
|
50
|
+
* [HexaPDF::Type::PageTreeNode#move_page] to work in case the parent node of the
|
|
51
|
+
moved node doesn't change
|
|
52
|
+
* [HexaPDF::Type::PageTreeNode#move_page] to use the correct target position
|
|
53
|
+
when the moved node is before the target position
|
|
54
|
+
* [HexaPDF::Document::Signatures#add] to work in case the signature object is
|
|
55
|
+
the last object written
|
|
56
|
+
* CLI command `hexapdf inspect` to show correct byte range of the last revision
|
|
57
|
+
* [HexaPDF::Writer#write_incremental] to only use a cross-reference stream if a
|
|
58
|
+
revision directly used one and not through an `/XRefStm` entry
|
|
59
|
+
* [HexaPDF::Encryption::FastARC4] to use RubyARC4 as fallback if OpenSSL has RC4
|
|
60
|
+
disabled
|
|
61
|
+
* [HexaPDF::Font::Encoding::GlyphList] to use binary reading to avoid problems
|
|
62
|
+
on Windows
|
|
63
|
+
* [HexaPDF::Document::Signatures#add] to use binary writing to avoid problems on
|
|
64
|
+
Windows
|
|
65
|
+
|
|
66
|
+
|
|
1
67
|
## 0.23.0 - 2022-05-26
|
|
2
68
|
|
|
3
69
|
### Added
|
data/LICENSE
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|
|
2
|
-
Copyright (C) 2014-
|
|
2
|
+
Copyright (C) 2014-2022 Thomas Leitner
|
|
3
3
|
|
|
4
4
|
HexaPDF is free software: you can redistribute it and/or modify it
|
|
5
5
|
under the terms of the GNU Affero General Public License version 3 as
|
data/Rakefile
CHANGED
|
@@ -47,7 +47,7 @@ namespace :dev do
|
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
task :test_all do
|
|
50
|
-
versions = `rbenv versions --bare | grep -i 2.[
|
|
50
|
+
versions = `rbenv versions --bare | grep -i 2.[67]\\\\\\|3.`.split("\n")
|
|
51
51
|
versions.each do |version|
|
|
52
52
|
sh "eval \"$(rbenv init -)\"; rbenv shell #{version} && ruby -v && rake test"
|
|
53
53
|
end
|
|
@@ -43,8 +43,13 @@ draw_box = lambda do |**args|
|
|
|
43
43
|
|
|
44
44
|
drawn = false
|
|
45
45
|
until drawn
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
result = frame.fit(b)
|
|
47
|
+
if result.success?
|
|
48
|
+
frame.draw(canvas, result)
|
|
49
|
+
drawn = true
|
|
50
|
+
else
|
|
51
|
+
frame.find_next_region
|
|
52
|
+
end
|
|
48
53
|
end
|
|
49
54
|
|
|
50
55
|
canvas.line_width(3).draw(:geom2d, object: frame.shape)
|
|
@@ -19,31 +19,18 @@ include HexaPDF::Utils::GraphicsHelpers
|
|
|
19
19
|
|
|
20
20
|
doc = HexaPDF::Document.new
|
|
21
21
|
|
|
22
|
-
sample_text = "Lorem ipsum dolor sit amet, con\u{00AD}sectetur
|
|
23
|
-
adipis\u{00AD}cing elit, sed do eiusmod tempor incididunt ut labore et
|
|
24
|
-
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
|
|
25
|
-
ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
26
|
-
".tr("\n", ' ') * 10
|
|
27
|
-
items = [TextFragment.create(sample_text, font: doc.fonts.add("Times"))]
|
|
28
|
-
|
|
29
22
|
page = doc.pages.add
|
|
30
23
|
media_box = page.box(:media)
|
|
31
|
-
canvas = page.canvas
|
|
32
24
|
frame = Frame.new(media_box.left + 20, media_box.bottom + 20,
|
|
33
25
|
media_box.width - 40, media_box.height - 40)
|
|
34
26
|
|
|
35
|
-
image = doc.images.add(File.join(__dir__, 'machupicchu.jpg'))
|
|
36
|
-
iw, ih = calculate_dimensions(image.width, image.height, rwidth: 100)
|
|
37
|
-
|
|
38
27
|
boxes = []
|
|
39
|
-
boxes <<
|
|
40
|
-
|
|
41
|
-
canv.image(image, at: [0, 0], width: 100)
|
|
42
|
-
end
|
|
28
|
+
boxes << doc.layout.image_box(File.join(__dir__, 'machupicchu.jpg'),
|
|
29
|
+
width: 100, margin: [10, 30], position: :float)
|
|
43
30
|
boxes << Box.create(width: 50, height: 50, margin: 20,
|
|
44
31
|
position: :float, position_hint: :right,
|
|
45
32
|
border: {width: 1, color: [[255, 0, 0]]})
|
|
46
|
-
boxes <<
|
|
33
|
+
boxes << doc.layout.lorem_ipsum_box(count: 3, position: :flow, align: :justify)
|
|
47
34
|
|
|
48
35
|
i = 0
|
|
49
36
|
frame_filled = false
|
|
@@ -51,8 +38,13 @@ until frame_filled
|
|
|
51
38
|
box = boxes[i]
|
|
52
39
|
drawn = false
|
|
53
40
|
until drawn || frame_filled
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
result = frame.fit(box)
|
|
42
|
+
if result.success?
|
|
43
|
+
frame.draw(page.canvas, result)
|
|
44
|
+
drawn = true
|
|
45
|
+
else
|
|
46
|
+
frame_filled = !frame.find_next_region
|
|
47
|
+
end
|
|
56
48
|
end
|
|
57
49
|
i = (i + 1) % boxes.length
|
|
58
50
|
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# # Column Box
|
|
2
|
+
#
|
|
3
|
+
# This example shows how [HexaPDF::Layout::ColumnBox] can be used to place
|
|
4
|
+
# contents into columns.
|
|
5
|
+
#
|
|
6
|
+
# Three boxes are placed repeatedly onto the frame until it is filled: two
|
|
7
|
+
# floating boxes (one left, one right) and a text box. The text box is styled to
|
|
8
|
+
# flow its content around the other two boxes.
|
|
9
|
+
#
|
|
10
|
+
# Usage:
|
|
11
|
+
# : `ruby column_box.rb`
|
|
12
|
+
#
|
|
13
|
+
|
|
14
|
+
require 'hexapdf'
|
|
15
|
+
|
|
16
|
+
doc = HexaPDF::Document.new
|
|
17
|
+
page = doc.pages.add
|
|
18
|
+
media_box = page.box(:media)
|
|
19
|
+
frame = HexaPDF::Layout::Frame.new(media_box.left + 20, media_box.bottom + 20,
|
|
20
|
+
media_box.width - 40, media_box.height - 40)
|
|
21
|
+
|
|
22
|
+
boxes = []
|
|
23
|
+
5.times do
|
|
24
|
+
boxes << doc.layout.image_box(File.join(__dir__, 'machupicchu.jpg'), width: 100,
|
|
25
|
+
style: {margin: [10, 30], position: :float})
|
|
26
|
+
boxes << HexaPDF::Layout::Box.create(width: 50, height: 50, margin: 20,
|
|
27
|
+
position: :float, position_hint: :right,
|
|
28
|
+
border: {width: 1, color: [[255, 0, 0]]})
|
|
29
|
+
boxes << doc.layout.lorem_ipsum_box(count: 2, position: :flow, align: :justify)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
polygon = Geom2D::Polygon([200, 350], [400, 350], [400, 450], [200, 450])
|
|
33
|
+
frame.remove_area(polygon)
|
|
34
|
+
page.canvas.draw(:geom2d, object: polygon)
|
|
35
|
+
|
|
36
|
+
columns = doc.layout.box(:column, children: boxes, columns: 2, style: {position: :flow})
|
|
37
|
+
result = frame.fit(columns)
|
|
38
|
+
frame.draw(page.canvas, result)
|
|
39
|
+
|
|
40
|
+
doc.write("column_box.pdf", optimize: true)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# # List Box
|
|
2
|
+
#
|
|
3
|
+
# This example shows how [HexaPDF::Layout::ListBox] can be used to place
|
|
4
|
+
# contents into lists.
|
|
5
|
+
#
|
|
6
|
+
# The list box class provides several options to style the item marker
|
|
7
|
+
# and its general appearance.
|
|
8
|
+
#
|
|
9
|
+
# Usage:
|
|
10
|
+
# : `ruby list_box.rb`
|
|
11
|
+
#
|
|
12
|
+
|
|
13
|
+
require 'hexapdf'
|
|
14
|
+
|
|
15
|
+
HexaPDF::Composer.create("list_box.pdf") do |composer|
|
|
16
|
+
composer.box(:list, content_indentation: 40, item_spacing: 20) do |list|
|
|
17
|
+
list.lorem_ipsum_box
|
|
18
|
+
list.image(File.join(__dir__, 'machupicchu.jpg'), height: 100)
|
|
19
|
+
list.box(:list, item_type: :decimal) do |sub_list|
|
|
20
|
+
1.upto(10) {|i| sub_list.text("Item #{i}") }
|
|
21
|
+
end
|
|
22
|
+
list.box(:column) do |column|
|
|
23
|
+
column.lorem_ipsum_box(count: 3)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
data/lib/hexapdf/cli/batch.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-2022 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/cli/command.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-2022 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/cli/files.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-2022 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/cli/fonts.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-2022 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/cli/form.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-2022 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
|
|
@@ -270,7 +270,7 @@ module HexaPDF
|
|
|
270
270
|
else
|
|
271
271
|
raise "Field type #{field.concrete_field_type} not yet supported"
|
|
272
272
|
end
|
|
273
|
-
rescue
|
|
273
|
+
rescue StandardError
|
|
274
274
|
raise "Error while setting '#{field.full_field_name}': #{$!.message}"
|
|
275
275
|
end
|
|
276
276
|
|
|
@@ -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-2022 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/cli/images.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-2022 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/cli/info.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-2022 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
|
|
@@ -103,7 +103,7 @@ module HexaPDF
|
|
|
103
103
|
"#{correctable ? '(correctable)' : ''}"
|
|
104
104
|
end
|
|
105
105
|
doc.trailer.validate(auto_correct: true, &validation_block)
|
|
106
|
-
doc.each(only_current:
|
|
106
|
+
doc.each(only_current: true, only_loaded: false) do |obj|
|
|
107
107
|
indirect_object = obj
|
|
108
108
|
obj.validate(auto_correct: true, &validation_block)
|
|
109
109
|
end
|
data/lib/hexapdf/cli/inspect.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-2022 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
|
|
@@ -354,7 +354,7 @@ module HexaPDF
|
|
|
354
354
|
buffer = ''.b
|
|
355
355
|
while io.pos < startxrefs[index + 1]
|
|
356
356
|
buffer << io.read(1_000)
|
|
357
|
-
if (buffer_index = buffer.index(/(?:\n|\r\n?)\s*%%EOF\s*(?:\n|\r\n?)
|
|
357
|
+
if (buffer_index = buffer.index(/(?:\n|\r\n?)\s*%%EOF\s*(?:\n|\r\n?)?/))
|
|
358
358
|
end_index = io.pos - buffer.size + buffer_index + $~[0].size
|
|
359
359
|
break
|
|
360
360
|
end
|
data/lib/hexapdf/cli/merge.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-2022 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/cli/modify.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-2022 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/cli/optimize.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-2022 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/cli/split.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-2022 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-2022 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/cli.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-2022 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
|