hexapdf 0.32.1 → 0.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +76 -1
- data/README.md +9 -0
- data/examples/002-graphics.rb +15 -17
- data/examples/003-arcs.rb +9 -9
- data/examples/009-text_layouter_alignment.rb +1 -1
- data/examples/010-text_layouter_inline_boxes.rb +2 -2
- data/examples/011-text_layouter_line_wrapping.rb +1 -1
- data/examples/012-text_layouter_styling.rb +7 -7
- data/examples/013-text_layouter_shapes.rb +1 -1
- data/examples/014-text_in_polygon.rb +1 -1
- data/examples/015-boxes.rb +8 -7
- data/examples/016-frame_automatic_box_placement.rb +2 -2
- data/examples/017-frame_text_flow.rb +2 -1
- data/examples/018-composer.rb +1 -1
- data/examples/020-column_box.rb +2 -1
- data/examples/025-table_box.rb +46 -0
- data/lib/hexapdf/cli/command.rb +5 -2
- data/lib/hexapdf/cli/form.rb +5 -5
- data/lib/hexapdf/cli/inspect.rb +3 -3
- data/lib/hexapdf/cli.rb +4 -0
- data/lib/hexapdf/composer.rb +104 -52
- data/lib/hexapdf/configuration.rb +44 -39
- data/lib/hexapdf/content/canvas.rb +393 -267
- data/lib/hexapdf/content/color_space.rb +72 -25
- data/lib/hexapdf/content/graphic_object/arc.rb +57 -24
- data/lib/hexapdf/content/graphic_object/endpoint_arc.rb +66 -23
- data/lib/hexapdf/content/graphic_object/geom2d.rb +47 -6
- data/lib/hexapdf/content/graphic_object/solid_arc.rb +58 -36
- data/lib/hexapdf/content/graphic_object.rb +6 -7
- data/lib/hexapdf/content/graphics_state.rb +54 -45
- data/lib/hexapdf/content/operator.rb +52 -54
- data/lib/hexapdf/content/parser.rb +2 -2
- data/lib/hexapdf/content/processor.rb +15 -15
- data/lib/hexapdf/content/transformation_matrix.rb +1 -1
- data/lib/hexapdf/content.rb +5 -0
- data/lib/hexapdf/dictionary.rb +6 -5
- data/lib/hexapdf/dictionary_fields.rb +42 -14
- data/lib/hexapdf/digital_signature/cms_handler.rb +2 -2
- data/lib/hexapdf/digital_signature/handler.rb +1 -1
- data/lib/hexapdf/digital_signature/pkcs1_handler.rb +2 -3
- data/lib/hexapdf/digital_signature/signature.rb +6 -6
- data/lib/hexapdf/digital_signature/signatures.rb +13 -12
- data/lib/hexapdf/digital_signature/signing/default_handler.rb +14 -5
- data/lib/hexapdf/digital_signature/signing/signed_data_creator.rb +2 -4
- data/lib/hexapdf/digital_signature/signing/timestamp_handler.rb +4 -4
- data/lib/hexapdf/digital_signature/signing.rb +4 -0
- data/lib/hexapdf/digital_signature/verification_result.rb +2 -2
- data/lib/hexapdf/digital_signature.rb +7 -2
- data/lib/hexapdf/document/destinations.rb +12 -11
- data/lib/hexapdf/document/files.rb +1 -1
- data/lib/hexapdf/document/fonts.rb +1 -1
- data/lib/hexapdf/document/layout.rb +167 -39
- data/lib/hexapdf/document/pages.rb +3 -2
- data/lib/hexapdf/document.rb +89 -55
- data/lib/hexapdf/encryption/aes.rb +5 -5
- data/lib/hexapdf/encryption/arc4.rb +1 -1
- data/lib/hexapdf/encryption/fast_aes.rb +2 -2
- 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 +31 -24
- data/lib/hexapdf/encryption/standard_security_handler.rb +45 -36
- data/lib/hexapdf/encryption.rb +7 -2
- data/lib/hexapdf/error.rb +18 -0
- data/lib/hexapdf/filter/ascii85_decode.rb +1 -1
- data/lib/hexapdf/filter/ascii_hex_decode.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 +55 -6
- data/lib/hexapdf/font/cmap/parser.rb +2 -2
- data/lib/hexapdf/font/cmap.rb +1 -1
- data/lib/hexapdf/font/encoding/difference_encoding.rb +1 -1
- data/lib/hexapdf/font/encoding/mac_expert_encoding.rb +1 -1
- data/lib/hexapdf/font/encoding/mac_roman_encoding.rb +2 -2
- 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 +3 -3
- data/lib/hexapdf/font/encoding/zapf_dingbats_encoding.rb +1 -1
- data/lib/hexapdf/font/invalid_glyph.rb +3 -0
- data/lib/hexapdf/font/true_type_wrapper.rb +17 -4
- data/lib/hexapdf/font/type1_wrapper.rb +19 -4
- data/lib/hexapdf/font_loader/from_configuration.rb +5 -2
- data/lib/hexapdf/font_loader/from_file.rb +5 -5
- data/lib/hexapdf/font_loader/standard14.rb +3 -3
- data/lib/hexapdf/font_loader.rb +3 -0
- data/lib/hexapdf/image_loader/jpeg.rb +2 -2
- data/lib/hexapdf/image_loader/pdf.rb +1 -1
- data/lib/hexapdf/image_loader/png.rb +2 -2
- data/lib/hexapdf/image_loader.rb +1 -1
- data/lib/hexapdf/importer.rb +13 -0
- data/lib/hexapdf/layout/box.rb +9 -2
- data/lib/hexapdf/layout/box_fitter.rb +2 -2
- data/lib/hexapdf/layout/column_box.rb +18 -4
- data/lib/hexapdf/layout/frame.rb +30 -12
- data/lib/hexapdf/layout/image_box.rb +5 -0
- data/lib/hexapdf/layout/inline_box.rb +1 -0
- data/lib/hexapdf/layout/list_box.rb +17 -1
- data/lib/hexapdf/layout/page_style.rb +4 -4
- data/lib/hexapdf/layout/style.rb +18 -3
- data/lib/hexapdf/layout/table_box.rb +682 -0
- data/lib/hexapdf/layout/text_box.rb +5 -3
- data/lib/hexapdf/layout/text_fragment.rb +1 -1
- data/lib/hexapdf/layout/text_layouter.rb +12 -4
- data/lib/hexapdf/layout.rb +1 -0
- data/lib/hexapdf/name_tree_node.rb +1 -1
- data/lib/hexapdf/number_tree_node.rb +1 -1
- data/lib/hexapdf/object.rb +18 -7
- data/lib/hexapdf/parser.rb +8 -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 +3 -3
- data/lib/hexapdf/serializer.rb +15 -15
- data/lib/hexapdf/stream.rb +4 -2
- data/lib/hexapdf/tokenizer.rb +14 -14
- data/lib/hexapdf/type/acro_form/appearance_generator.rb +22 -22
- 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 +2 -2
- data/lib/hexapdf/type/acro_form/form.rb +1 -1
- data/lib/hexapdf/type/acro_form/signature_field.rb +4 -4
- 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 +3 -3
- data/lib/hexapdf/type/annotations/link.rb +1 -1
- data/lib/hexapdf/type/annotations/markup_annotation.rb +1 -1
- data/lib/hexapdf/type/annotations/text.rb +1 -1
- data/lib/hexapdf/type/annotations/widget.rb +2 -2
- data/lib/hexapdf/type/annotations.rb +1 -1
- data/lib/hexapdf/type/catalog.rb +1 -1
- data/lib/hexapdf/type/cid_font.rb +3 -3
- data/lib/hexapdf/type/embedded_file.rb +1 -1
- data/lib/hexapdf/type/file_specification.rb +2 -2
- data/lib/hexapdf/type/font_descriptor.rb +1 -1
- data/lib/hexapdf/type/font_simple.rb +2 -2
- data/lib/hexapdf/type/font_type0.rb +3 -3
- 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 +2 -2
- data/lib/hexapdf/type/object_stream.rb +7 -3
- data/lib/hexapdf/type/outline.rb +1 -1
- data/lib/hexapdf/type/outline_item.rb +1 -1
- data/lib/hexapdf/type/page.rb +19 -10
- 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 +2 -2
- data/lib/hexapdf/type/viewer_preferences.rb +1 -1
- data/lib/hexapdf/type/xref_stream.rb +2 -2
- data/lib/hexapdf/utils/pdf_doc_encoding.rb +1 -1
- data/lib/hexapdf/version.rb +1 -1
- data/lib/hexapdf/writer.rb +4 -4
- data/lib/hexapdf/xref_section.rb +2 -2
- data/test/hexapdf/content/graphic_object/test_endpoint_arc.rb +11 -1
- data/test/hexapdf/content/graphic_object/test_geom2d.rb +7 -0
- data/test/hexapdf/content/test_canvas.rb +0 -1
- data/test/hexapdf/digital_signature/test_signatures.rb +22 -0
- data/test/hexapdf/document/test_files.rb +2 -2
- data/test/hexapdf/document/test_layout.rb +98 -0
- data/test/hexapdf/encryption/test_security_handler.rb +12 -11
- data/test/hexapdf/encryption/test_standard_security_handler.rb +35 -23
- data/test/hexapdf/font/test_true_type_wrapper.rb +18 -1
- data/test/hexapdf/font/test_type1_wrapper.rb +15 -1
- data/test/hexapdf/layout/test_box.rb +1 -1
- data/test/hexapdf/layout/test_column_box.rb +65 -21
- data/test/hexapdf/layout/test_frame.rb +14 -14
- data/test/hexapdf/layout/test_image_box.rb +4 -0
- data/test/hexapdf/layout/test_inline_box.rb +5 -0
- data/test/hexapdf/layout/test_list_box.rb +40 -6
- data/test/hexapdf/layout/test_page_style.rb +3 -2
- data/test/hexapdf/layout/test_style.rb +50 -0
- data/test/hexapdf/layout/test_table_box.rb +722 -0
- data/test/hexapdf/layout/test_text_box.rb +18 -0
- data/test/hexapdf/layout/test_text_layouter.rb +4 -0
- data/test/hexapdf/test_dictionary_fields.rb +4 -1
- data/test/hexapdf/test_document.rb +1 -0
- data/test/hexapdf/test_filter.rb +8 -0
- data/test/hexapdf/test_importer.rb +9 -0
- data/test/hexapdf/test_object.rb +16 -5
- data/test/hexapdf/test_parser.rb +1 -1
- data/test/hexapdf/test_stream.rb +7 -0
- data/test/hexapdf/test_writer.rb +3 -3
- data/test/hexapdf/type/acro_form/test_appearance_generator.rb +13 -5
- data/test/hexapdf/type/acro_form/test_form.rb +4 -3
- data/test/hexapdf/type/test_object_stream.rb +9 -3
- data/test/hexapdf/type/test_page.rb +18 -4
- metadata +17 -8
@@ -50,10 +50,9 @@ module HexaPDF
|
|
50
50
|
# color to the specified gray value.
|
51
51
|
#
|
52
52
|
# Since HexaPDF doesn't have a content stream rendering facility, it is only interested in the
|
53
|
-
# effects an operator has on the graphics state. By calling the #invoke method with a
|
54
|
-
#
|
55
|
-
#
|
56
|
-
# correct operation.
|
53
|
+
# effects an operator has on the graphics state. By calling the #invoke method with a Processor
|
54
|
+
# as first argument and the operands as the rest of the arguments, the operator can modify the
|
55
|
+
# graphics state as needed. This ensures internal consistency and correct operation.
|
57
56
|
#
|
58
57
|
# Operator objects are designed to be state-less. This means that the operands have to be
|
59
58
|
# passed as arguments to the methods that need them.
|
@@ -62,8 +61,7 @@ module HexaPDF
|
|
62
61
|
# == Operator Implementations
|
63
62
|
#
|
64
63
|
# HexaPDF comes with operator implementations for all PDF operations. These operator
|
65
|
-
# implementations are derived from the
|
66
|
-
# methods.
|
64
|
+
# implementations are derived from the BaseOperator class which provides all needed methods.
|
67
65
|
#
|
68
66
|
# In general, an operator implementation is an object that responds to the following methods:
|
69
67
|
#
|
@@ -76,10 +74,10 @@ module HexaPDF
|
|
76
74
|
# #name::
|
77
75
|
# Returns the name of the operator as String.
|
78
76
|
#
|
79
|
-
# See:
|
77
|
+
# See: PDF2.0 s8, s9
|
80
78
|
module Operator
|
81
79
|
|
82
|
-
#
|
80
|
+
# Base class for operator implementations.
|
83
81
|
#
|
84
82
|
# A default implementation for the #serialize method is provided. However, for performance
|
85
83
|
# reasons each operator should provide a custom #serialize method.
|
@@ -148,7 +146,7 @@ module HexaPDF
|
|
148
146
|
|
149
147
|
# Implementation of the 'q' operator.
|
150
148
|
#
|
151
|
-
# See:
|
149
|
+
# See: PDF2.0 s8.4.4
|
152
150
|
class SaveGraphicsState < NoArgumentOperator
|
153
151
|
|
154
152
|
# Creates the operator.
|
@@ -164,7 +162,7 @@ module HexaPDF
|
|
164
162
|
|
165
163
|
# Implementation of the 'Q' operator.
|
166
164
|
#
|
167
|
-
# See:
|
165
|
+
# See: PDF2.0 s8.4.4
|
168
166
|
class RestoreGraphicsState < NoArgumentOperator
|
169
167
|
|
170
168
|
# Creates the operator.
|
@@ -180,7 +178,7 @@ module HexaPDF
|
|
180
178
|
|
181
179
|
# Implementation of the 'cm' operator.
|
182
180
|
#
|
183
|
-
# See:
|
181
|
+
# See: PDF2.0 s8.4.4
|
184
182
|
class ConcatenateMatrix < BaseOperator
|
185
183
|
|
186
184
|
# Creates the operator.
|
@@ -202,7 +200,7 @@ module HexaPDF
|
|
202
200
|
|
203
201
|
# Implementation of the 'w' operator.
|
204
202
|
#
|
205
|
-
# See:
|
203
|
+
# See: PDF2.0 s8.4.4
|
206
204
|
class SetLineWidth < SingleNumericArgumentOperator
|
207
205
|
|
208
206
|
# Creates the operator.
|
@@ -218,7 +216,7 @@ module HexaPDF
|
|
218
216
|
|
219
217
|
# Implementation of the 'J' operator.
|
220
218
|
#
|
221
|
-
# See:
|
219
|
+
# See: PDF2.0 s8.4.4
|
222
220
|
class SetLineCapStyle < SingleNumericArgumentOperator
|
223
221
|
|
224
222
|
# Creates the operator.
|
@@ -234,7 +232,7 @@ module HexaPDF
|
|
234
232
|
|
235
233
|
# Implementation of the 'j' operator.
|
236
234
|
#
|
237
|
-
# See:
|
235
|
+
# See: PDF2.0 s8.4.4
|
238
236
|
class SetLineJoinStyle < SingleNumericArgumentOperator
|
239
237
|
|
240
238
|
# Creates the operator.
|
@@ -250,7 +248,7 @@ module HexaPDF
|
|
250
248
|
|
251
249
|
# Implementation of the 'M' operator.
|
252
250
|
#
|
253
|
-
# See:
|
251
|
+
# See: PDF2.0 s8.4.4
|
254
252
|
class SetMiterLimit < SingleNumericArgumentOperator
|
255
253
|
|
256
254
|
# Creates the operator.
|
@@ -266,7 +264,7 @@ module HexaPDF
|
|
266
264
|
|
267
265
|
# Implementation of the 'd' operator.
|
268
266
|
#
|
269
|
-
# See:
|
267
|
+
# See: PDF2.0 s8.4.4
|
270
268
|
class SetLineDashPattern < BaseOperator
|
271
269
|
|
272
270
|
# Creates the operator.
|
@@ -287,7 +285,7 @@ module HexaPDF
|
|
287
285
|
|
288
286
|
# Implementation of the 'ri' operator.
|
289
287
|
#
|
290
|
-
# See:
|
288
|
+
# See: PDF2.0 s8.4.4
|
291
289
|
class SetRenderingIntent < BaseOperator
|
292
290
|
|
293
291
|
# Creates the operator.
|
@@ -310,7 +308,7 @@ module HexaPDF
|
|
310
308
|
# Note: Only parameters supported by the GraphicsState/TextState classes are assigned, the
|
311
309
|
# rest are ignored!
|
312
310
|
#
|
313
|
-
# See:
|
311
|
+
# See: PDF2.0 s8.4.4
|
314
312
|
class SetGraphicsStateParameters < BaseOperator
|
315
313
|
|
316
314
|
# Creates the operator.
|
@@ -352,7 +350,7 @@ module HexaPDF
|
|
352
350
|
|
353
351
|
# Implementation of the 'CS' operator.
|
354
352
|
#
|
355
|
-
# See:
|
353
|
+
# See: PDF2.0 s8.6.8
|
356
354
|
class SetStrokingColorSpace < BaseOperator
|
357
355
|
|
358
356
|
# Creates the operator.
|
@@ -372,7 +370,7 @@ module HexaPDF
|
|
372
370
|
|
373
371
|
# Implementation of the 'cs' operator.
|
374
372
|
#
|
375
|
-
# See:
|
373
|
+
# See: PDF2.0 s8.6.8
|
376
374
|
class SetNonStrokingColorSpace < BaseOperator
|
377
375
|
|
378
376
|
# Creates the operator.
|
@@ -392,7 +390,7 @@ module HexaPDF
|
|
392
390
|
|
393
391
|
# Implementation of the 'SC' and 'SCN' operator.
|
394
392
|
#
|
395
|
-
# See:
|
393
|
+
# See: PDF2.0 s8.6.8
|
396
394
|
class SetStrokingColor < BaseOperator
|
397
395
|
|
398
396
|
def invoke(processor, *operands) #:nodoc:
|
@@ -404,7 +402,7 @@ module HexaPDF
|
|
404
402
|
|
405
403
|
# Implementation of the 'sc' and 'scn' operator.
|
406
404
|
#
|
407
|
-
# See:
|
405
|
+
# See: PDF2.0 s8.6.8
|
408
406
|
class SetNonStrokingColor < BaseOperator
|
409
407
|
|
410
408
|
def invoke(processor, *operands) #:nodoc:
|
@@ -416,7 +414,7 @@ module HexaPDF
|
|
416
414
|
|
417
415
|
# Implementation of the 'G' operator.
|
418
416
|
#
|
419
|
-
# See:
|
417
|
+
# See: PDF2.0 s8.6.8
|
420
418
|
class SetDeviceGrayStrokingColor < SingleNumericArgumentOperator
|
421
419
|
|
422
420
|
def initialize #:nodoc:
|
@@ -432,7 +430,7 @@ module HexaPDF
|
|
432
430
|
|
433
431
|
# Implementation of the 'g' operator.
|
434
432
|
#
|
435
|
-
# See:
|
433
|
+
# See: PDF2.0 s8.6.8
|
436
434
|
class SetDeviceGrayNonStrokingColor < SingleNumericArgumentOperator
|
437
435
|
|
438
436
|
# Creates the operator.
|
@@ -449,7 +447,7 @@ module HexaPDF
|
|
449
447
|
|
450
448
|
# Implementation of the 'RG' operator.
|
451
449
|
#
|
452
|
-
# See:
|
450
|
+
# See: PDF2.0 s8.6.8
|
453
451
|
class SetDeviceRGBStrokingColor < BaseOperator
|
454
452
|
|
455
453
|
# Creates the operator.
|
@@ -471,7 +469,7 @@ module HexaPDF
|
|
471
469
|
|
472
470
|
# Implementation of the 'rg' operator.
|
473
471
|
#
|
474
|
-
# See:
|
472
|
+
# See: PDF2.0 s8.6.8
|
475
473
|
class SetDeviceRGBNonStrokingColor < BaseOperator
|
476
474
|
|
477
475
|
# Creates the operator.
|
@@ -493,7 +491,7 @@ module HexaPDF
|
|
493
491
|
|
494
492
|
# Implementation of the 'K' operator.
|
495
493
|
#
|
496
|
-
# See:
|
494
|
+
# See: PDF2.0 s8.6.8
|
497
495
|
class SetDeviceCMYKStrokingColor < BaseOperator
|
498
496
|
|
499
497
|
# Creates the operator.
|
@@ -515,7 +513,7 @@ module HexaPDF
|
|
515
513
|
|
516
514
|
# Implementation of the 'k' operator.
|
517
515
|
#
|
518
|
-
# See:
|
516
|
+
# See: PDF2.0 s8.6.8
|
519
517
|
class SetDeviceCMYKNonStrokingColor < BaseOperator
|
520
518
|
|
521
519
|
# Creates the operator.
|
@@ -537,7 +535,7 @@ module HexaPDF
|
|
537
535
|
|
538
536
|
# Implementation of the 'm' operator.
|
539
537
|
#
|
540
|
-
# See:
|
538
|
+
# See: PDF2.0 s8.5.2.1
|
541
539
|
class MoveTo < BaseOperator
|
542
540
|
|
543
541
|
# Creates the operator.
|
@@ -557,7 +555,7 @@ module HexaPDF
|
|
557
555
|
|
558
556
|
# Implementation of the 're' operator.
|
559
557
|
#
|
560
|
-
# See:
|
558
|
+
# See: PDF2.0 s8.5.2.1
|
561
559
|
class AppendRectangle < BaseOperator
|
562
560
|
|
563
561
|
# Creates the operator.
|
@@ -578,7 +576,7 @@ module HexaPDF
|
|
578
576
|
|
579
577
|
# Implementation of the 'l' operator.
|
580
578
|
#
|
581
|
-
# See:
|
579
|
+
# See: PDF2.0 s8.5.2.1
|
582
580
|
class LineTo < BaseOperator
|
583
581
|
|
584
582
|
# Creates the operator.
|
@@ -597,7 +595,7 @@ module HexaPDF
|
|
597
595
|
|
598
596
|
# Implementation of the 'c' operators.
|
599
597
|
#
|
600
|
-
# See:
|
598
|
+
# See: PDF2.0 s8.5.2.1
|
601
599
|
class CurveTo < BaseOperator
|
602
600
|
|
603
601
|
# Creates the operator.
|
@@ -615,7 +613,7 @@ module HexaPDF
|
|
615
613
|
|
616
614
|
# Implementation of the 'v' operators.
|
617
615
|
#
|
618
|
-
# See:
|
616
|
+
# See: PDF2.0 s8.5.2.1
|
619
617
|
class CurveToNoFirstControlPoint < BaseOperator
|
620
618
|
|
621
619
|
# Creates the operator.
|
@@ -632,7 +630,7 @@ module HexaPDF
|
|
632
630
|
|
633
631
|
# Implementation of the 'y' operators.
|
634
632
|
#
|
635
|
-
# See:
|
633
|
+
# See: PDF2.0 s8.5.2.1
|
636
634
|
class CurveToNoSecondControlPoint < BaseOperator
|
637
635
|
|
638
636
|
# Creates the operator.
|
@@ -649,7 +647,7 @@ module HexaPDF
|
|
649
647
|
|
650
648
|
# Implementation of the 'S', 's', 'f', 'F', 'f*', 'B', 'B*', 'b', 'b*' and 'n' operators.
|
651
649
|
#
|
652
|
-
# See:
|
650
|
+
# See: PDF2.0 s8.5.3.1
|
653
651
|
class EndPath < NoArgumentOperator
|
654
652
|
|
655
653
|
def invoke(processor) #:nodoc:
|
@@ -660,7 +658,7 @@ module HexaPDF
|
|
660
658
|
|
661
659
|
# Implementation of the 'W' and 'W*' operators.
|
662
660
|
#
|
663
|
-
# See:
|
661
|
+
# See: PDF2.0 s8.5.4
|
664
662
|
class ClipPath < NoArgumentOperator
|
665
663
|
|
666
664
|
def invoke(processor) #:nodoc:
|
@@ -672,7 +670,7 @@ module HexaPDF
|
|
672
670
|
# Implementation of the 'BI' operator which handles the *complete* inline image, i.e. the
|
673
671
|
# 'ID' and 'EI' operators are never encountered.
|
674
672
|
#
|
675
|
-
# See:
|
673
|
+
# See: PDF2.0 s8.9.7
|
676
674
|
class InlineImage < BaseOperator
|
677
675
|
|
678
676
|
# Creates the operator.
|
@@ -693,7 +691,7 @@ module HexaPDF
|
|
693
691
|
|
694
692
|
# Implementation of the 'Tc' operator.
|
695
693
|
#
|
696
|
-
# See:
|
694
|
+
# See: PDF2.0 s9.3.1
|
697
695
|
class SetCharacterSpacing < SingleNumericArgumentOperator
|
698
696
|
|
699
697
|
# Creates the operator.
|
@@ -709,7 +707,7 @@ module HexaPDF
|
|
709
707
|
|
710
708
|
# Implementation of the 'Tw' operator.
|
711
709
|
#
|
712
|
-
# See:
|
710
|
+
# See: PDF2.0 s9.3.1
|
713
711
|
class SetWordSpacing < SingleNumericArgumentOperator
|
714
712
|
|
715
713
|
# Creates the operator.
|
@@ -725,7 +723,7 @@ module HexaPDF
|
|
725
723
|
|
726
724
|
# Implementation of the 'Tz' operator.
|
727
725
|
#
|
728
|
-
# See:
|
726
|
+
# See: PDF2.0 s9.3.1
|
729
727
|
class SetHorizontalScaling < SingleNumericArgumentOperator
|
730
728
|
|
731
729
|
# Creates the operator.
|
@@ -741,7 +739,7 @@ module HexaPDF
|
|
741
739
|
|
742
740
|
# Implementation of the 'TL' operator.
|
743
741
|
#
|
744
|
-
# See:
|
742
|
+
# See: PDF2.0 s9.3.1
|
745
743
|
class SetLeading < SingleNumericArgumentOperator
|
746
744
|
|
747
745
|
# Creates the operator.
|
@@ -757,7 +755,7 @@ module HexaPDF
|
|
757
755
|
|
758
756
|
# Implementation of the 'Tf' operator.
|
759
757
|
#
|
760
|
-
# See:
|
758
|
+
# See: PDF2.0 s9.3.1
|
761
759
|
class SetFontAndSize < BaseOperator
|
762
760
|
|
763
761
|
# Creates the operator.
|
@@ -778,7 +776,7 @@ module HexaPDF
|
|
778
776
|
|
779
777
|
# Implementation of the 'Tr' operator.
|
780
778
|
#
|
781
|
-
# See:
|
779
|
+
# See: PDF2.0 s9.3.1
|
782
780
|
class SetTextRenderingMode < SingleNumericArgumentOperator
|
783
781
|
|
784
782
|
# Creates the operator.
|
@@ -794,7 +792,7 @@ module HexaPDF
|
|
794
792
|
|
795
793
|
# Implementation of the 'Ts' operator.
|
796
794
|
#
|
797
|
-
# See:
|
795
|
+
# See: PDF2.0 s9.3.1
|
798
796
|
class SetTextRise < SingleNumericArgumentOperator
|
799
797
|
|
800
798
|
# Creates the operator.
|
@@ -810,7 +808,7 @@ module HexaPDF
|
|
810
808
|
|
811
809
|
# Implementation of the 'BT' operator.
|
812
810
|
#
|
813
|
-
# See:
|
811
|
+
# See: PDF2.0 s9.4.1
|
814
812
|
class BeginText < NoArgumentOperator
|
815
813
|
|
816
814
|
def initialize #:nodoc:
|
@@ -827,7 +825,7 @@ module HexaPDF
|
|
827
825
|
|
828
826
|
# Implementation of the 'ET' operator.
|
829
827
|
#
|
830
|
-
# See:
|
828
|
+
# See: PDF2.0 s9.4.1
|
831
829
|
class EndText < NoArgumentOperator
|
832
830
|
|
833
831
|
# Creates the operator.
|
@@ -845,7 +843,7 @@ module HexaPDF
|
|
845
843
|
|
846
844
|
# Implementation of the 'Td' operator.
|
847
845
|
#
|
848
|
-
# See:
|
846
|
+
# See: PDF2.0 s9.4.2
|
849
847
|
class MoveText < BaseOperator
|
850
848
|
|
851
849
|
# Creates the operator.
|
@@ -866,7 +864,7 @@ module HexaPDF
|
|
866
864
|
|
867
865
|
# Implementation of the 'TD' operator.
|
868
866
|
#
|
869
|
-
# See:
|
867
|
+
# See: PDF2.0 s9.4.2
|
870
868
|
class MoveTextAndSetLeading < BaseOperator
|
871
869
|
|
872
870
|
# Creates the operator.
|
@@ -887,7 +885,7 @@ module HexaPDF
|
|
887
885
|
|
888
886
|
# Implementation of the 'Tm' operator.
|
889
887
|
#
|
890
|
-
# See:
|
888
|
+
# See: PDF2.0 s9.4.2
|
891
889
|
class SetTextMatrix < BaseOperator
|
892
890
|
|
893
891
|
# Creates the operator.
|
@@ -910,7 +908,7 @@ module HexaPDF
|
|
910
908
|
|
911
909
|
# Implementation of the 'T*' operator.
|
912
910
|
#
|
913
|
-
# See:
|
911
|
+
# See: PDF2.0 s9.4.2
|
914
912
|
class MoveTextNextLine < NoArgumentOperator
|
915
913
|
|
916
914
|
# Creates the operator.
|
@@ -927,7 +925,7 @@ module HexaPDF
|
|
927
925
|
|
928
926
|
# Implementation of the 'Tj' operator.
|
929
927
|
#
|
930
|
-
# See:
|
928
|
+
# See: PDF2.0 s9.4.3
|
931
929
|
class ShowText < BaseOperator
|
932
930
|
|
933
931
|
# Creates the operator.
|
@@ -943,7 +941,7 @@ module HexaPDF
|
|
943
941
|
|
944
942
|
# Implementation of the ' operator.
|
945
943
|
#
|
946
|
-
# See:
|
944
|
+
# See: PDF2.0 s9.4.3
|
947
945
|
class MoveTextNextLineAndShowText < BaseOperator
|
948
946
|
|
949
947
|
def initialize #:nodoc:
|
@@ -963,7 +961,7 @@ module HexaPDF
|
|
963
961
|
|
964
962
|
# Implementation of the " operator.
|
965
963
|
#
|
966
|
-
# See:
|
964
|
+
# See: PDF2.0 s9.4.3
|
967
965
|
class SetSpacingMoveTextNextLineAndShowText < BaseOperator
|
968
966
|
|
969
967
|
# Creates the operator.
|
@@ -987,7 +985,7 @@ module HexaPDF
|
|
987
985
|
|
988
986
|
# Implementation of the 'TJ' operator.
|
989
987
|
#
|
990
|
-
# See:
|
988
|
+
# See: PDF2.0 s9.4.3
|
991
989
|
class ShowTextWithPositioning < BaseOperator
|
992
990
|
|
993
991
|
# Creates the operator.
|
@@ -46,14 +46,14 @@ module HexaPDF
|
|
46
46
|
#
|
47
47
|
# Changes:
|
48
48
|
#
|
49
|
-
# * Since a content stream is
|
49
|
+
# * Since a content stream is usually parsed front to back, a StopIteration error can be raised
|
50
50
|
# instead of returning +NO_MORE_TOKENS+ once the end of the string is reached to avoid costly
|
51
51
|
# checks in each iteration. If this behaviour is wanted, pass "raise_on_eos: true" in the
|
52
52
|
# constructor.
|
53
53
|
#
|
54
54
|
# * Indirect object references are *not* supported by this tokenizer!
|
55
55
|
#
|
56
|
-
# See:
|
56
|
+
# See: PDF2.0 s7.2
|
57
57
|
class Tokenizer < HexaPDF::Tokenizer #:nodoc:
|
58
58
|
|
59
59
|
# The string that is tokenized.
|
@@ -45,7 +45,7 @@ module HexaPDF
|
|
45
45
|
# == General Information
|
46
46
|
#
|
47
47
|
# When a content stream is read, operators and their operands are extracted. After extracting
|
48
|
-
# these operators are
|
48
|
+
# these operators are usually processed with a Processor instance that ensures that the needed
|
49
49
|
# setup (like modifying the graphics state) is done before further processing.
|
50
50
|
#
|
51
51
|
# == How Processing Works
|
@@ -79,7 +79,7 @@ module HexaPDF
|
|
79
79
|
|
80
80
|
# Represents an (immutable) glyph box with positioning information.
|
81
81
|
#
|
82
|
-
# Since the glyph may have been transformed by an affine matrix, the bounding may not be a
|
82
|
+
# Since the glyph may have been transformed by an affine matrix, the bounding box may not be a
|
83
83
|
# rectangle in all cases but it is always a parallelogram.
|
84
84
|
class GlyphBox
|
85
85
|
|
@@ -105,7 +105,7 @@ module HexaPDF
|
|
105
105
|
end
|
106
106
|
|
107
107
|
# :call-seq:
|
108
|
-
#
|
108
|
+
# glyph_box.lower_left -> [llx, lly]
|
109
109
|
#
|
110
110
|
# Returns the lower left coordinate
|
111
111
|
def lower_left
|
@@ -113,7 +113,7 @@ module HexaPDF
|
|
113
113
|
end
|
114
114
|
|
115
115
|
# :call-seq:
|
116
|
-
#
|
116
|
+
# glyph_box.lower_right -> [lrx, lry]
|
117
117
|
#
|
118
118
|
# Returns the lower right coordinate
|
119
119
|
def lower_right
|
@@ -121,7 +121,7 @@ module HexaPDF
|
|
121
121
|
end
|
122
122
|
|
123
123
|
# :call-seq:
|
124
|
-
#
|
124
|
+
# glyph_box.upper_left -> [ulx, uly]
|
125
125
|
#
|
126
126
|
# Returns the upper left coordinate
|
127
127
|
def upper_left
|
@@ -129,7 +129,7 @@ module HexaPDF
|
|
129
129
|
end
|
130
130
|
|
131
131
|
# :call-seq:
|
132
|
-
#
|
132
|
+
# glyph_box.upper_right -> [urx, ury]
|
133
133
|
#
|
134
134
|
# Returns the upper right coordinate which is computed by using the other three points of
|
135
135
|
# the parallelogram.
|
@@ -138,7 +138,7 @@ module HexaPDF
|
|
138
138
|
end
|
139
139
|
|
140
140
|
# :call-seq:
|
141
|
-
#
|
141
|
+
# glyph_box.points -> [llx, lly, lrx, lry, urx, ury, ulx, uly]
|
142
142
|
#
|
143
143
|
# Returns the four corners of the box as an array of coordinates, starting with the lower
|
144
144
|
# left corner and going counterclockwise.
|
@@ -155,7 +155,7 @@ module HexaPDF
|
|
155
155
|
# in a straight line.
|
156
156
|
class CompositeBox
|
157
157
|
|
158
|
-
# The
|
158
|
+
# The glyph boxes contained in this composite box object.
|
159
159
|
attr_reader :boxes
|
160
160
|
|
161
161
|
# Creates an empty object.
|
@@ -185,7 +185,7 @@ module HexaPDF
|
|
185
185
|
self
|
186
186
|
end
|
187
187
|
|
188
|
-
# Returns the concatenated text of the boxes.
|
188
|
+
# Returns the concatenated text of all the glyph boxes.
|
189
189
|
def string
|
190
190
|
@boxes.map(&:string).join
|
191
191
|
end
|
@@ -311,14 +311,14 @@ module HexaPDF
|
|
311
311
|
|
312
312
|
# The GraphicsState object containing the current graphics state.
|
313
313
|
#
|
314
|
-
# It is not advised
|
315
|
-
#
|
314
|
+
# It is not advised to change this attribute manually, it is automatically adjusted according
|
315
|
+
# to the processed operators!
|
316
316
|
attr_reader :graphics_state
|
317
317
|
|
318
318
|
# The current graphics object.
|
319
319
|
#
|
320
|
-
# It is not advised
|
321
|
-
#
|
320
|
+
# It is not advised to change this attribute manually, it is automatically adjusted according
|
321
|
+
# to the processed operators!
|
322
322
|
#
|
323
323
|
# This attribute can have the following values:
|
324
324
|
#
|
@@ -327,7 +327,7 @@ module HexaPDF
|
|
327
327
|
# :clipping_path:: The current graphics object is a clipping path.
|
328
328
|
# :text:: The current graphics object is text.
|
329
329
|
#
|
330
|
-
# See:
|
330
|
+
# See: PDF2.0 s8.2
|
331
331
|
attr_accessor :graphics_object
|
332
332
|
|
333
333
|
# Initializes a new processor that uses the resources PDF dictionary for resolving resources
|
@@ -417,7 +417,7 @@ module HexaPDF
|
|
417
417
|
# Decodes the given array containing text and positioning information while assuming that the
|
418
418
|
# writing direction is horizontal.
|
419
419
|
#
|
420
|
-
# See:
|
420
|
+
# See: PDF2.0 s9.4.4
|
421
421
|
def decode_horizontal_text(array)
|
422
422
|
font = graphics_state.font
|
423
423
|
scaled_char_space = graphics_state.scaled_character_spacing
|
data/lib/hexapdf/content.rb
CHANGED
@@ -39,6 +39,11 @@ module HexaPDF
|
|
39
39
|
# == Overview
|
40
40
|
#
|
41
41
|
# The Content module contains everything related to working with page content streams.
|
42
|
+
#
|
43
|
+
# The most important classes are:
|
44
|
+
#
|
45
|
+
# * The Canvas class which provides an interface for drawing graphics and text.
|
46
|
+
# * The Parser and Processor classes for processing an existing content stream.
|
42
47
|
module Content
|
43
48
|
|
44
49
|
autoload(:Canvas, 'hexapdf/content/canvas')
|
data/lib/hexapdf/dictionary.rb
CHANGED
@@ -47,10 +47,11 @@ module HexaPDF
|
|
47
47
|
# the PDF specification. This allows, among other things, automatic type checking and
|
48
48
|
# basic validation.
|
49
49
|
#
|
50
|
-
# Fields defined in superclasses are inherited by their subclasses. This avoids duplicating
|
51
|
-
#
|
50
|
+
# Fields defined in superclasses are inherited by their subclasses. This avoids duplicating basic
|
51
|
+
# field information. If fields differ from their superclass definition, they can be defined again
|
52
|
+
# in the subclass.
|
52
53
|
#
|
53
|
-
# See:
|
54
|
+
# See: PDF2.0 s7.3.7
|
54
55
|
class Dictionary < HexaPDF::Object
|
55
56
|
|
56
57
|
include DictionaryFields
|
@@ -85,7 +86,7 @@ module HexaPDF
|
|
85
86
|
# a Symbol), it has to be the first in the list. Otherwise automatic type conversion
|
86
87
|
# functions won't work correctly.
|
87
88
|
#
|
88
|
-
# required:: Specifies whether this field is required
|
89
|
+
# required:: Specifies whether this field is required, either +true+ or +false+.
|
89
90
|
#
|
90
91
|
# default:: Specifies the default value for the field, if any.
|
91
92
|
#
|
@@ -174,7 +175,7 @@ module HexaPDF
|
|
174
175
|
data
|
175
176
|
end
|
176
177
|
|
177
|
-
# Stores the data under name in the dictionary. Name has to be a Symbol
|
178
|
+
# Stores the data under name in the dictionary. Name has to be a Symbol.
|
178
179
|
#
|
179
180
|
# If the current value for this name has the class HexaPDF::Object (and only this, no
|
180
181
|
# subclasses) and the given value has not (including subclasses), the value is stored inside the
|