hexapdf 0.46.0 → 1.6.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.
Files changed (355) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +342 -16
  3. data/LICENSE +1 -1
  4. data/README.md +9 -8
  5. data/examples/009-text_layouter_alignment.rb +4 -0
  6. data/examples/010-text_layouter_inline_boxes.rb +4 -0
  7. data/examples/011-text_layouter_line_wrapping.rb +4 -0
  8. data/examples/012-text_layouter_styling.rb +9 -4
  9. data/examples/013-text_layouter_shapes.rb +5 -0
  10. data/examples/015-boxes.rb +3 -0
  11. data/examples/016-frame_automatic_box_placement.rb +3 -0
  12. data/examples/017-frame_text_flow.rb +3 -0
  13. data/examples/022-outline.rb +5 -1
  14. data/examples/{028-frame_mask_mode.rb → 028-composer_mask_mode.rb} +3 -3
  15. data/lib/hexapdf/cli/batch.rb +1 -1
  16. data/lib/hexapdf/cli/command.rb +65 -65
  17. data/lib/hexapdf/cli/debug_info.rb +98 -0
  18. data/lib/hexapdf/cli/files.rb +1 -1
  19. data/lib/hexapdf/cli/fonts.rb +1 -1
  20. data/lib/hexapdf/cli/form.rb +11 -6
  21. data/lib/hexapdf/cli/image2pdf.rb +1 -1
  22. data/lib/hexapdf/cli/images.rb +19 -4
  23. data/lib/hexapdf/cli/info.rb +1 -1
  24. data/lib/hexapdf/cli/inspect.rb +24 -8
  25. data/lib/hexapdf/cli/merge.rb +1 -1
  26. data/lib/hexapdf/cli/modify.rb +1 -2
  27. data/lib/hexapdf/cli/optimize.rb +6 -6
  28. data/lib/hexapdf/cli/split.rb +1 -1
  29. data/lib/hexapdf/cli/usage.rb +1 -1
  30. data/lib/hexapdf/cli/watermark.rb +1 -1
  31. data/lib/hexapdf/cli.rb +20 -2
  32. data/lib/hexapdf/composer.rb +22 -1
  33. data/lib/hexapdf/configuration.rb +56 -1
  34. data/lib/hexapdf/content/canvas.rb +1 -1
  35. data/lib/hexapdf/content/canvas_composer.rb +1 -1
  36. data/lib/hexapdf/content/color_space.rb +1 -1
  37. data/lib/hexapdf/content/graphic_object/arc.rb +1 -1
  38. data/lib/hexapdf/content/graphic_object/endpoint_arc.rb +1 -1
  39. data/lib/hexapdf/content/graphic_object/geom2d.rb +1 -1
  40. data/lib/hexapdf/content/graphic_object/solid_arc.rb +1 -1
  41. data/lib/hexapdf/content/graphic_object.rb +1 -1
  42. data/lib/hexapdf/content/graphics_state.rb +2 -2
  43. data/lib/hexapdf/content/operator.rb +1 -1
  44. data/lib/hexapdf/content/parser.rb +22 -23
  45. data/lib/hexapdf/content/processor.rb +1 -1
  46. data/lib/hexapdf/content/transformation_matrix.rb +1 -1
  47. data/lib/hexapdf/content.rb +1 -1
  48. data/lib/hexapdf/data_dir.rb +1 -1
  49. data/lib/hexapdf/dictionary.rb +8 -2
  50. data/lib/hexapdf/dictionary_fields.rb +2 -2
  51. data/lib/hexapdf/digital_signature/cms_handler.rb +19 -2
  52. data/lib/hexapdf/digital_signature/handler.rb +1 -1
  53. data/lib/hexapdf/digital_signature/pkcs1_handler.rb +1 -1
  54. data/lib/hexapdf/digital_signature/signature.rb +2 -2
  55. data/lib/hexapdf/digital_signature/signatures.rb +1 -1
  56. data/lib/hexapdf/digital_signature/signing/default_handler.rb +3 -3
  57. data/lib/hexapdf/digital_signature/signing/signed_data_creator.rb +2 -2
  58. data/lib/hexapdf/digital_signature/signing/timestamp_handler.rb +25 -5
  59. data/lib/hexapdf/digital_signature/signing.rb +1 -1
  60. data/lib/hexapdf/digital_signature/verification_result.rb +1 -1
  61. data/lib/hexapdf/digital_signature.rb +1 -1
  62. data/lib/hexapdf/document/annotations.rb +220 -0
  63. data/lib/hexapdf/document/destinations.rb +1 -1
  64. data/lib/hexapdf/document/files.rb +1 -1
  65. data/lib/hexapdf/document/fonts.rb +1 -1
  66. data/lib/hexapdf/document/images.rb +1 -1
  67. data/lib/hexapdf/document/layout.rb +95 -16
  68. data/lib/hexapdf/document/metadata.rb +11 -4
  69. data/lib/hexapdf/document/pages.rb +1 -1
  70. data/lib/hexapdf/document.rb +52 -9
  71. data/lib/hexapdf/encryption/aes.rb +1 -1
  72. data/lib/hexapdf/encryption/arc4.rb +3 -3
  73. data/lib/hexapdf/encryption/fast_aes.rb +1 -1
  74. data/lib/hexapdf/encryption/fast_arc4.rb +1 -1
  75. data/lib/hexapdf/encryption/identity.rb +1 -1
  76. data/lib/hexapdf/encryption/ruby_aes.rb +1 -1
  77. data/lib/hexapdf/encryption/ruby_arc4.rb +1 -1
  78. data/lib/hexapdf/encryption/security_handler.rb +4 -2
  79. data/lib/hexapdf/encryption/standard_security_handler.rb +40 -29
  80. data/lib/hexapdf/encryption.rb +1 -1
  81. data/lib/hexapdf/error.rb +12 -4
  82. data/lib/hexapdf/filter/ascii85_decode.rb +1 -1
  83. data/lib/hexapdf/filter/ascii_hex_decode.rb +1 -1
  84. data/lib/hexapdf/filter/crypt.rb +1 -1
  85. data/lib/hexapdf/filter/encryption.rb +1 -1
  86. data/lib/hexapdf/filter/flate_decode.rb +1 -1
  87. data/lib/hexapdf/filter/lzw_decode.rb +1 -1
  88. data/lib/hexapdf/filter/pass_through.rb +1 -1
  89. data/lib/hexapdf/filter/predictor.rb +1 -1
  90. data/lib/hexapdf/filter/run_length_decode.rb +1 -1
  91. data/lib/hexapdf/filter.rb +1 -1
  92. data/lib/hexapdf/font/cmap/parser.rb +1 -1
  93. data/lib/hexapdf/font/cmap/writer.rb +59 -5
  94. data/lib/hexapdf/font/cmap.rb +18 -7
  95. data/lib/hexapdf/font/encoding/base.rb +28 -1
  96. data/lib/hexapdf/font/encoding/difference_encoding.rb +1 -1
  97. data/lib/hexapdf/font/encoding/glyph_list.rb +1 -1
  98. data/lib/hexapdf/font/encoding/mac_expert_encoding.rb +1 -1
  99. data/lib/hexapdf/font/encoding/mac_roman_encoding.rb +1 -1
  100. data/lib/hexapdf/font/encoding/standard_encoding.rb +1 -1
  101. data/lib/hexapdf/font/encoding/symbol_encoding.rb +1 -1
  102. data/lib/hexapdf/font/encoding/win_ansi_encoding.rb +1 -1
  103. data/lib/hexapdf/font/encoding/zapf_dingbats_encoding.rb +1 -1
  104. data/lib/hexapdf/font/encoding.rb +1 -1
  105. data/lib/hexapdf/font/invalid_glyph.rb +1 -1
  106. data/lib/hexapdf/font/true_type/builder.rb +1 -1
  107. data/lib/hexapdf/font/true_type/font.rb +1 -1
  108. data/lib/hexapdf/font/true_type/optimizer.rb +1 -1
  109. data/lib/hexapdf/font/true_type/subsetter.rb +1 -1
  110. data/lib/hexapdf/font/true_type/table/cmap.rb +1 -1
  111. data/lib/hexapdf/font/true_type/table/cmap_subtable.rb +1 -1
  112. data/lib/hexapdf/font/true_type/table/directory.rb +1 -1
  113. data/lib/hexapdf/font/true_type/table/glyf.rb +1 -1
  114. data/lib/hexapdf/font/true_type/table/head.rb +1 -1
  115. data/lib/hexapdf/font/true_type/table/hhea.rb +1 -1
  116. data/lib/hexapdf/font/true_type/table/hmtx.rb +1 -1
  117. data/lib/hexapdf/font/true_type/table/kern.rb +1 -1
  118. data/lib/hexapdf/font/true_type/table/loca.rb +1 -1
  119. data/lib/hexapdf/font/true_type/table/maxp.rb +1 -1
  120. data/lib/hexapdf/font/true_type/table/name.rb +1 -1
  121. data/lib/hexapdf/font/true_type/table/os2.rb +1 -1
  122. data/lib/hexapdf/font/true_type/table/post.rb +1 -1
  123. data/lib/hexapdf/font/true_type/table.rb +7 -2
  124. data/lib/hexapdf/font/true_type.rb +1 -1
  125. data/lib/hexapdf/font/true_type_wrapper.rb +51 -16
  126. data/lib/hexapdf/font/type1/afm_parser.rb +1 -1
  127. data/lib/hexapdf/font/type1/character_metrics.rb +1 -1
  128. data/lib/hexapdf/font/type1/font.rb +1 -1
  129. data/lib/hexapdf/font/type1/font_metrics.rb +1 -1
  130. data/lib/hexapdf/font/type1/pfb_parser.rb +1 -1
  131. data/lib/hexapdf/font/type1.rb +1 -1
  132. data/lib/hexapdf/font/type1_wrapper.rb +3 -4
  133. data/lib/hexapdf/font_loader/from_configuration.rb +1 -1
  134. data/lib/hexapdf/font_loader/from_file.rb +1 -1
  135. data/lib/hexapdf/font_loader/standard14.rb +1 -1
  136. data/lib/hexapdf/font_loader/variant_from_name.rb +1 -1
  137. data/lib/hexapdf/font_loader.rb +1 -1
  138. data/lib/hexapdf/image_loader/jpeg.rb +1 -1
  139. data/lib/hexapdf/image_loader/pdf.rb +1 -1
  140. data/lib/hexapdf/image_loader/png.rb +1 -1
  141. data/lib/hexapdf/image_loader.rb +1 -1
  142. data/lib/hexapdf/importer.rb +2 -2
  143. data/lib/hexapdf/layout/box.rb +6 -1
  144. data/lib/hexapdf/layout/box_fitter.rb +1 -1
  145. data/lib/hexapdf/layout/column_box.rb +1 -1
  146. data/lib/hexapdf/layout/container_box.rb +64 -29
  147. data/lib/hexapdf/layout/frame.rb +1 -1
  148. data/lib/hexapdf/layout/image_box.rb +1 -1
  149. data/lib/hexapdf/layout/inline_box.rb +1 -1
  150. data/lib/hexapdf/layout/line.rb +1 -1
  151. data/lib/hexapdf/layout/list_box.rb +1 -1
  152. data/lib/hexapdf/layout/numeric_refinements.rb +1 -1
  153. data/lib/hexapdf/layout/page_style.rb +1 -1
  154. data/lib/hexapdf/layout/style.rb +133 -22
  155. data/lib/hexapdf/layout/table_box.rb +86 -14
  156. data/lib/hexapdf/layout/text_box.rb +1 -1
  157. data/lib/hexapdf/layout/text_fragment.rb +13 -2
  158. data/lib/hexapdf/layout/text_layouter.rb +1 -1
  159. data/lib/hexapdf/layout/text_shaper.rb +1 -1
  160. data/lib/hexapdf/layout/width_from_polygon.rb +1 -1
  161. data/lib/hexapdf/layout.rb +1 -1
  162. data/lib/hexapdf/name_tree_node.rb +1 -1
  163. data/lib/hexapdf/number_tree_node.rb +1 -1
  164. data/lib/hexapdf/object.rb +4 -4
  165. data/lib/hexapdf/parser.rb +36 -7
  166. data/lib/hexapdf/pdf_array.rb +26 -4
  167. data/lib/hexapdf/rectangle.rb +1 -1
  168. data/lib/hexapdf/reference.rb +2 -2
  169. data/lib/hexapdf/revision.rb +7 -3
  170. data/lib/hexapdf/revisions.rb +1 -1
  171. data/lib/hexapdf/serializer.rb +8 -8
  172. data/lib/hexapdf/stream.rb +1 -1
  173. data/lib/hexapdf/task/dereference.rb +1 -1
  174. data/lib/hexapdf/task/merge_acro_form.rb +164 -0
  175. data/lib/hexapdf/task/optimize.rb +5 -5
  176. data/lib/hexapdf/task/pdfa.rb +1 -1
  177. data/lib/hexapdf/task.rb +2 -1
  178. data/lib/hexapdf/test_utils.rb +3 -2
  179. data/lib/hexapdf/tokenizer.rb +52 -44
  180. data/lib/hexapdf/type/acro_form/appearance_generator.rb +66 -13
  181. data/lib/hexapdf/type/acro_form/button_field.rb +1 -1
  182. data/lib/hexapdf/type/acro_form/choice_field.rb +1 -1
  183. data/lib/hexapdf/type/acro_form/field.rb +6 -2
  184. data/lib/hexapdf/type/acro_form/form.rb +23 -32
  185. data/lib/hexapdf/type/acro_form/java_script_actions.rb +10 -3
  186. data/lib/hexapdf/type/acro_form/signature_field.rb +19 -8
  187. data/lib/hexapdf/type/acro_form/text_field.rb +10 -3
  188. data/lib/hexapdf/type/acro_form/variable_text_field.rb +13 -5
  189. data/lib/hexapdf/type/acro_form.rb +1 -1
  190. data/lib/hexapdf/type/action.rb +1 -1
  191. data/lib/hexapdf/type/actions/go_to.rb +2 -1
  192. data/lib/hexapdf/type/actions/go_to_r.rb +2 -1
  193. data/lib/hexapdf/type/actions/launch.rb +6 -2
  194. data/lib/hexapdf/type/actions/set_ocg_state.rb +1 -1
  195. data/lib/hexapdf/type/actions/uri.rb +1 -1
  196. data/lib/hexapdf/type/actions.rb +1 -1
  197. data/lib/hexapdf/type/annotation.rb +78 -3
  198. data/lib/hexapdf/type/annotations/appearance_generator.rb +426 -0
  199. data/lib/hexapdf/type/annotations/border_effect.rb +99 -0
  200. data/lib/hexapdf/type/annotations/border_styling.rb +160 -0
  201. data/lib/hexapdf/type/annotations/circle.rb +65 -0
  202. data/lib/hexapdf/type/annotations/interior_color.rb +84 -0
  203. data/lib/hexapdf/type/annotations/line.rb +334 -0
  204. data/lib/hexapdf/type/annotations/line_ending_styling.rb +208 -0
  205. data/lib/hexapdf/type/annotations/link.rb +1 -1
  206. data/lib/hexapdf/type/annotations/markup_annotation.rb +15 -3
  207. data/lib/hexapdf/type/annotations/polygon.rb +64 -0
  208. data/lib/hexapdf/type/annotations/polygon_polyline.rb +109 -0
  209. data/lib/hexapdf/type/annotations/polyline.rb +64 -0
  210. data/lib/hexapdf/type/annotations/square.rb +65 -0
  211. data/lib/hexapdf/type/annotations/square_circle.rb +77 -0
  212. data/lib/hexapdf/type/annotations/text.rb +1 -1
  213. data/lib/hexapdf/type/annotations/widget.rb +56 -118
  214. data/lib/hexapdf/type/annotations.rb +13 -1
  215. data/lib/hexapdf/type/catalog.rb +5 -2
  216. data/lib/hexapdf/type/cid_font.rb +6 -3
  217. data/lib/hexapdf/type/cmap.rb +58 -0
  218. data/lib/hexapdf/type/embedded_file.rb +1 -1
  219. data/lib/hexapdf/type/file_specification.rb +18 -15
  220. data/lib/hexapdf/type/font.rb +1 -1
  221. data/lib/hexapdf/type/font_descriptor.rb +5 -4
  222. data/lib/hexapdf/type/font_simple.rb +4 -2
  223. data/lib/hexapdf/type/font_true_type.rb +3 -1
  224. data/lib/hexapdf/type/font_type0.rb +2 -2
  225. data/lib/hexapdf/type/font_type1.rb +19 -1
  226. data/lib/hexapdf/type/font_type3.rb +1 -2
  227. data/lib/hexapdf/type/form.rb +8 -5
  228. data/lib/hexapdf/type/graphics_state_parameter.rb +8 -5
  229. data/lib/hexapdf/type/icon_fit.rb +1 -1
  230. data/lib/hexapdf/type/image.rb +9 -5
  231. data/lib/hexapdf/type/info.rb +3 -3
  232. data/lib/hexapdf/type/mark_information.rb +3 -3
  233. data/lib/hexapdf/type/marked_content_reference.rb +59 -0
  234. data/lib/hexapdf/type/measure.rb +57 -0
  235. data/lib/hexapdf/type/metadata.rb +1 -1
  236. data/lib/hexapdf/type/names.rb +1 -1
  237. data/lib/hexapdf/type/namespace.rb +57 -0
  238. data/lib/hexapdf/type/object_reference.rb +57 -0
  239. data/lib/hexapdf/type/object_stream.rb +1 -1
  240. data/lib/hexapdf/type/optional_content_configuration.rb +2 -2
  241. data/lib/hexapdf/type/optional_content_group.rb +1 -1
  242. data/lib/hexapdf/type/optional_content_membership.rb +2 -2
  243. data/lib/hexapdf/type/optional_content_properties.rb +1 -1
  244. data/lib/hexapdf/type/outline.rb +1 -1
  245. data/lib/hexapdf/type/outline_item.rb +1 -1
  246. data/lib/hexapdf/type/output_intent.rb +1 -1
  247. data/lib/hexapdf/type/page.rb +6 -4
  248. data/lib/hexapdf/type/page_label.rb +1 -1
  249. data/lib/hexapdf/type/page_tree_node.rb +1 -1
  250. data/lib/hexapdf/type/resources.rb +13 -9
  251. data/lib/hexapdf/type/struct_elem.rb +72 -0
  252. data/lib/hexapdf/type/struct_tree_root.rb +64 -0
  253. data/lib/hexapdf/type/trailer.rb +1 -1
  254. data/lib/hexapdf/type/viewer_preferences.rb +5 -4
  255. data/lib/hexapdf/type/xref_stream.rb +1 -1
  256. data/lib/hexapdf/type.rb +8 -1
  257. data/lib/hexapdf/utils/bit_field.rb +1 -1
  258. data/lib/hexapdf/utils/bit_stream.rb +1 -1
  259. data/lib/hexapdf/utils/graphics_helpers.rb +1 -1
  260. data/lib/hexapdf/utils/lru_cache.rb +1 -1
  261. data/lib/hexapdf/utils/math_helpers.rb +1 -1
  262. data/lib/hexapdf/utils/object_hash.rb +1 -1
  263. data/lib/hexapdf/utils/pdf_doc_encoding.rb +1 -1
  264. data/lib/hexapdf/utils/sorted_tree_node.rb +17 -4
  265. data/lib/hexapdf/utils.rb +1 -1
  266. data/lib/hexapdf/version.rb +2 -2
  267. data/lib/hexapdf/writer.rb +3 -2
  268. data/lib/hexapdf/xref_section.rb +25 -6
  269. data/lib/hexapdf.rb +1 -1
  270. data/test/data/standard-security-handler/bothpwd-aes-256bit-V5-R5.pdf +43 -0
  271. data/test/data/standard-security-handler/nopwd-aes-256bit-V5-R5.pdf +44 -0
  272. data/test/data/standard-security-handler/ownerpwd-aes-256bit-V5-R5.pdf +43 -0
  273. data/test/data/standard-security-handler/userpwd-aes-256bit-V5-R5.pdf +0 -0
  274. data/test/hexapdf/common_tokenizer_tests.rb +7 -7
  275. data/test/hexapdf/content/test_graphics_state.rb +2 -3
  276. data/test/hexapdf/content/test_operator.rb +4 -5
  277. data/test/hexapdf/digital_signature/common.rb +6 -1
  278. data/test/hexapdf/digital_signature/signing/test_default_handler.rb +6 -1
  279. data/test/hexapdf/digital_signature/signing/test_timestamp_handler.rb +12 -0
  280. data/test/hexapdf/digital_signature/test_cms_handler.rb +25 -15
  281. data/test/hexapdf/digital_signature/test_handler.rb +2 -3
  282. data/test/hexapdf/digital_signature/test_pkcs1_handler.rb +1 -2
  283. data/test/hexapdf/digital_signature/test_signature.rb +7 -0
  284. data/test/hexapdf/digital_signature/test_signatures.rb +12 -7
  285. data/test/hexapdf/document/test_annotations.rb +75 -0
  286. data/test/hexapdf/document/test_layout.rb +38 -10
  287. data/test/hexapdf/document/test_metadata.rb +13 -1
  288. data/test/hexapdf/encryption/common.rb +1 -1
  289. data/test/hexapdf/encryption/test_aes.rb +1 -1
  290. data/test/hexapdf/encryption/test_arc4.rb +2 -2
  291. data/test/hexapdf/encryption/test_security_handler.rb +8 -6
  292. data/test/hexapdf/encryption/test_standard_security_handler.rb +7 -3
  293. data/test/hexapdf/filter/test_ascii85_decode.rb +1 -1
  294. data/test/hexapdf/filter/test_ascii_hex_decode.rb +1 -1
  295. data/test/hexapdf/filter/test_flate_decode.rb +2 -3
  296. data/test/hexapdf/font/cmap/test_writer.rb +73 -16
  297. data/test/hexapdf/font/encoding/test_base.rb +20 -0
  298. data/test/hexapdf/font/encoding/test_glyph_list.rb +1 -1
  299. data/test/hexapdf/font/test_true_type_wrapper.rb +31 -5
  300. data/test/hexapdf/font/test_type1_wrapper.rb +8 -1
  301. data/test/hexapdf/font/true_type/test_table.rb +12 -0
  302. data/test/hexapdf/layout/test_box.rb +8 -2
  303. data/test/hexapdf/layout/test_container_box.rb +34 -6
  304. data/test/hexapdf/layout/test_list_box.rb +7 -7
  305. data/test/hexapdf/layout/test_page_style.rb +1 -1
  306. data/test/hexapdf/layout/test_style.rb +46 -12
  307. data/test/hexapdf/layout/test_table_box.rb +66 -16
  308. data/test/hexapdf/layout/test_text_box.rb +0 -6
  309. data/test/hexapdf/layout/test_text_fragment.rb +3 -3
  310. data/test/hexapdf/layout/test_text_layouter.rb +4 -2
  311. data/test/hexapdf/task/test_merge_acro_form.rb +104 -0
  312. data/test/hexapdf/task/test_optimize.rb +3 -1
  313. data/test/hexapdf/test_composer.rb +15 -0
  314. data/test/hexapdf/test_dictionary.rb +15 -0
  315. data/test/hexapdf/test_dictionary_fields.rb +1 -0
  316. data/test/hexapdf/test_document.rb +26 -8
  317. data/test/hexapdf/test_filter.rb +1 -1
  318. data/test/hexapdf/test_importer.rb +7 -0
  319. data/test/hexapdf/test_object.rb +1 -1
  320. data/test/hexapdf/test_parser.rb +87 -18
  321. data/test/hexapdf/test_pdf_array.rb +36 -3
  322. data/test/hexapdf/test_revision.rb +27 -6
  323. data/test/hexapdf/test_revisions.rb +1 -1
  324. data/test/hexapdf/test_serializer.rb +4 -4
  325. data/test/hexapdf/test_stream.rb +1 -2
  326. data/test/hexapdf/test_tokenizer.rb +1 -1
  327. data/test/hexapdf/test_writer.rb +22 -8
  328. data/test/hexapdf/test_xref_section.rb +15 -0
  329. data/test/hexapdf/type/acro_form/test_appearance_generator.rb +118 -26
  330. data/test/hexapdf/type/acro_form/test_button_field.rb +7 -6
  331. data/test/hexapdf/type/acro_form/test_field.rb +10 -0
  332. data/test/hexapdf/type/acro_form/test_form.rb +32 -9
  333. data/test/hexapdf/type/acro_form/test_java_script_actions.rb +21 -0
  334. data/test/hexapdf/type/acro_form/test_signature_field.rb +3 -1
  335. data/test/hexapdf/type/acro_form/test_text_field.rb +7 -1
  336. data/test/hexapdf/type/acro_form/test_variable_text_field.rb +14 -1
  337. data/test/hexapdf/type/actions/test_launch.rb +6 -2
  338. data/test/hexapdf/type/annotations/test_appearance_generator.rb +608 -0
  339. data/test/hexapdf/type/annotations/test_border_effect.rb +59 -0
  340. data/test/hexapdf/type/annotations/test_border_styling.rb +114 -0
  341. data/test/hexapdf/type/annotations/test_interior_color.rb +37 -0
  342. data/test/hexapdf/type/annotations/test_line.rb +144 -0
  343. data/test/hexapdf/type/annotations/test_line_ending_styling.rb +42 -0
  344. data/test/hexapdf/type/annotations/test_polygon_polyline.rb +29 -0
  345. data/test/hexapdf/type/annotations/test_widget.rb +47 -81
  346. data/test/hexapdf/type/test_annotation.rb +58 -0
  347. data/test/hexapdf/type/test_font_type1.rb +20 -1
  348. data/test/hexapdf/type/test_form.rb +7 -1
  349. data/test/hexapdf/type/test_image.rb +1 -1
  350. data/test/hexapdf/type/test_page.rb +7 -1
  351. data/test/hexapdf/type/test_page_tree_node.rb +2 -2
  352. data/test/hexapdf/type/test_resources.rb +3 -1
  353. data/test/hexapdf/utils/test_sorted_tree_node.rb +18 -7
  354. data/test/test_helper.rb +7 -0
  355. metadata +69 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9c1a35d4ad93b48faa1f728bcddc91778da584c8d673e2f15557bd22050a438
4
- data.tar.gz: 2ef8ca70891723643080a402f0808882f66f01a816c422477cc03fad34774859
3
+ metadata.gz: 35bbb5d1780d07ecf6098cc40359ff2cc02cd89231a124b6ff1a0a13c760d116
4
+ data.tar.gz: 8664f2ac8a6651ee83e7292d005ea10d89b7ea738de47cc62dbf219f4eae0cb4
5
5
  SHA512:
6
- metadata.gz: 87c109bd8a6711b4df27a40c689a025d816075d6c68c21a1cc22924b5ae827cd44d98e45bff8f43c85403dd82d6a6e54b66c99bfe135298cba33292e9511a1fc
7
- data.tar.gz: e0529e3e244be8366e722ea29ab06a8b922f18698526c79a28d5d11f02da5ee103cba71ecbc6882fefe3de27f02d38f8ce8b505fefbb45839069c74aefaed9ae
6
+ metadata.gz: 232aefc90eb4f9f9a913d27affa95a0c9eff43a72e04eeb1adc0fbe11e865033c6fd0b7779930b15a982afdd909d6ffa98640db6db668f95ce0c26332749cfae
7
+ data.tar.gz: e1b836a23d58e92ceb70f5b892d023edcf585288583f2254d35394688204bfdbf4401edea6562a96d1583a71a302d8d50e8a175262ff5077a3b4a2200ec922a4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,329 @@
1
+ ## 1.6.0 - 2026-02-10
2
+
3
+ ### Added
4
+
5
+ * CLI command `hexapdf debug-info` for creating debugging information,
6
+ especially for malformed files
7
+
8
+ ### Changed
9
+
10
+ * Optimized decoding character codes with a CMap to drastically lower memory
11
+ usage
12
+ * CLI command `hexapdf inspect rev` to show whether the cross-reference table
13
+ was reconstructed
14
+
15
+ ### Fixed
16
+
17
+ * Path generation for image extraction in CLI command `hexapdf images`
18
+ * Handling of certain invalid PDFs where the generation number for object
19
+ identifiers don't match their cross-reference section value
20
+ * AES 256bit encryption to include unnecessary field /Length in encryption
21
+ dictionary to work around buggy PDF libraries
22
+ * Parsing of invalid /Filter and /DecodeParms stream keys in case they resolve
23
+ to a recursive structure
24
+ * [HexaPDF::Type::AcroForm::Field#each_widget] to only yield widget objects
25
+
26
+
27
+ ## 1.5.0 - 2025-12-08
28
+
29
+ ### Added
30
+
31
+ * Support for basic authentication to
32
+ [HexaPDF::DigitalSignature::Signing::TimestampHandler]
33
+
34
+ ### Changed
35
+
36
+ * Dictionary validation to delete field entries that have an invalid type
37
+ * CLI command `hexapdf images` to create directories specified in the `--prefix`
38
+ * CLI command `hexapdf images` to omit the dash in the file names if `--prefix`
39
+ points to a directory
40
+
41
+ ## Fixed
42
+
43
+ * [HexaPDF::Type::Annotation#appearance] to work in case /AP contains a value of
44
+ an invalid type
45
+ * [HexaPDF::DigitalSignature::CMSHandler] to throw an appropriate error when
46
+ encountering invalid signature contents
47
+
48
+
49
+ ## 1.4.1 - 2025-09-23
50
+
51
+ ### Added
52
+
53
+ * [HexaPDF::Font::Encoding::Base#to_compact_array] for creating a compact array
54
+ representation of the encoding
55
+
56
+ ### Changed
57
+
58
+ - CLI to handle missing file errors better
59
+
60
+ ### Fixed
61
+
62
+ * Serialization of strings that need to be UTF-16 encoded when using encryption
63
+ * [HexaPDF::Document#write_to_string] to pass on arguments to `#write`
64
+ * [HexaPDF::Type::FontType1] validation to handle PDFs with an invalid value of
65
+ /SymbolEncoding for the /Encoding key
66
+ * [HexaPDF::Type::FontType1] validation to handle PDFs with an invalid value of
67
+ /StandardEncoding for the /Encoding key
68
+ * CLI command `hexapdf form` to ignore widgets that don't belong to any field
69
+ * Validation of invalid sorted tree root nodes with odd number of direct entries
70
+
71
+
72
+ ## 1.4.0 - 2025-08-03
73
+
74
+ ### Added
75
+
76
+ * [HexaPDF::Type::Annotations::Polygon] for polygon annotations as well as
77
+ [HexaPDF::Document::Annotations#create_polygon]
78
+ * [HexaPDF::Type::Annotations::Polyline] for polyline annotations as well as
79
+ [HexaPDF::Document::Annotations#create_polyline]
80
+ * [HexaPDF::Layout::ContainerBox#splitable] for specifying whether the container
81
+ box may be split
82
+ * [HexaPDF::Layout::Style::Layers#layers] for retrieving the list of defined
83
+ layers
84
+ * [HexaPDF::Document::Layout#resolve_font] for resolving the font style property
85
+ * [HexaPDF::Type::Measure] for representing the measure dictionary
86
+ * [HexaPDF::Layout::Box::FitResult#failure!] for setting the result status to
87
+ failure
88
+
89
+ ### Changed
90
+
91
+ * **Breaking change**: Extracted `#line_ending_style` and associated data class
92
+ from [HexaPDF::Type::Annotations::Line] into
93
+ [HexaPDF::Type::Annotations::LineEndingStyling]
94
+ * [HexaPDF::Layout::TableBox] implementation to allow setting the minimum height
95
+ of a table cell
96
+ * [HexaPDF::Layout::Style::Quad#set] to allow setting a subset of values using a
97
+ hash
98
+ * CLI command `hexapdf form` to show the names of radio button widgets
99
+ * CLI command `hexapdf form` to show position and size of widgets in easier to
100
+ understand form
101
+ * Default signing handler to not set /DigestMethod entry on signature reference
102
+ dictionary anymore
103
+
104
+ ### Fixed
105
+
106
+ * Parsing and writing the /ModDate and /CreationDate trailer info fields in case
107
+ of string values when using the XMP metadata handler
108
+ * [HexaPDF::Layout::Style] to not accidentally set subscript or superscript
109
+ values
110
+ * [HexaPDF::DictionaryFields::DateConverter] to handle invalid dates with two
111
+ trailing apostrophes
112
+ * [HexaPDF::Document::Layout::CellArgumentCollector#retrieve_arguments_for] to
113
+ not change the stored data
114
+ * Encryption when using AES with 256bits and an owner password
115
+
116
+
117
+ ## 1.3.0 - 2025-04-23
118
+
119
+ ### Added
120
+
121
+ * [HexaPDF::Type::Annotations::Square] for rectangle annotations as well as
122
+ [HexaPDF::Document::Annotations#create_rectangle]
123
+ * [HexaPDF::Type::Annotations::Circle] for ellipse annotations as well as
124
+ [HexaPDF::Document::Annotations#create_ellipse]
125
+ * Basic appearance generation for push button fields
126
+ * [HexaPDF::Type::Annotation::BorderEffect] type class
127
+ * [HexaPDF::Type::Annotations::BorderEffect] module that provides convenience
128
+ access to the border effect dictionary
129
+ * [HexaPDF::Document::Layout#style?] and [HexaPDF::Composer#style?] for checking
130
+ whether a given style (name) exists
131
+ * [HexaPDF::Layout::Style#each_property] for iterating over all set properties
132
+ * [HexaPDF::Layout::Style#merge] for merging another style instance
133
+ * [HexaPDF::Layout::Style#box_options] for specifying box initialization options
134
+ * [HexaPDF::Layout::Style#font_bold] and [HexaPDF::Layout::Style#font_italic]
135
+ for setting bold and/or italic variants independently of the font name
136
+ * [HexaPDF::PDFArray#map!] for mapping elements in-place
137
+ * [HexaPDF::PDFArray#compact!] for removing `nil` elements
138
+
139
+ ### Changed
140
+
141
+ * **Breaking change**: [HexaPDF::Type::Annotations::Widget::MarkerStyle::new]
142
+ got a new positional argument
143
+ * [HexaPDF::Type::Annotations::Widget#marker_style] to allow setting and
144
+ retrieving the font for push buttons
145
+ * Extracted `#interior_color` from [HexaPDF::Type::Annotations::Line] into
146
+ [HexaPDF::Type::Annotations::InteriorColor]
147
+ * CLI command `hexapdf inspect` to support decoding Form XObject streams
148
+ * [HexaPDF::Layout::Style#line_spacing] to accept a `LineSpacing` object when
149
+ setting the value
150
+
151
+ ### Fixed
152
+
153
+ * Text extraction with macOS Preview due a bug in Preview
154
+ * [HexaPDF::PDFArray#reject!] to work according to documented method signature
155
+ * [HexaPDF::Type::AcroForm::Field#create_widget] to ensure the proper type
156
+ class is stored in the document in case an embedded widget is extracted
157
+ * [HexaPDF::Type::AcroForm::Form] validation to ensure that all field objects in
158
+ the field hierarchy are using a field type class
159
+ * [HexaPDF::Type::AcroForm::Form] validation to delete merged fields
160
+
161
+
162
+ ## 1.2.0 - 2025-02-10
163
+
164
+ ### Added
165
+
166
+ * **Breaking change**: Argument `compact` to [HexaPDF::Document#write] to
167
+ automatically run the 'compact' optimization task
168
+ * [HexaPDF::Document::Annotations], accessible via
169
+ [HexaPDF::Document#annotations], as convenience interface for working with
170
+ annotations
171
+ * [HexaPDF::Type::Annotations::AppearanceGenerator] as central class for
172
+ generating appearance streams
173
+ * [HexaPDF::Type::Annotations::Line] for line annotations
174
+ * [HexaPDF::Type::Annotation#opacity] for setting the opacity values when
175
+ regenerating the appearance stream
176
+ * [HexaPDF::Type::Annotation#contents] for setting the text of the annotation
177
+ * Configuration option 'acro_form.text_field.on_max_len_exceeded' to allow
178
+ custom handling of too long values
179
+
180
+ ### Changed
181
+
182
+ * **Breaking change**: Extracted `#border_style` and associated data class from
183
+ [HexaPDF::Type::Annotations::Widget] into
184
+ [HexaPDF::Type::Annotations::BorderStyling]
185
+ * [HexaPDF::Type::Form#canvas] to allow getting the canvas without the initial
186
+ translation
187
+
188
+ ### Fixed
189
+
190
+ * AcroForm Javascript actions to gracefully handle the special values infinity
191
+ and NaN
192
+ * Type1 and TrueType font wrappers to handle the case where fonts are first
193
+ added and later deleted
194
+
195
+
196
+ ## 1.1.1 - 2025-01-08
197
+
198
+ ### Fixed
199
+
200
+ * Missing require statements leading to problems loading type classes
201
+
202
+
203
+ ## 1.1.0 - 2025-01-08
204
+
205
+ ### Added
206
+
207
+ * Basic type classes for logical structure support
208
+
209
+ ### Changed
210
+
211
+ * Optimized output of simple borders to avoid unnecessary drawing operations
212
+
213
+ ### Fixed
214
+
215
+ * Type of field /DW for CIDFont which used to be Integer in PDF 1.7 but now is
216
+ Numeric inf 2.0
217
+ * Validation of /ProcSet entry in resources dictionary to correctly handle the
218
+ case of /ProcSet having a Symbol value
219
+
220
+
221
+ ## 1.0.3 - 2024-12-04
222
+
223
+ ### Fixed
224
+
225
+ * Offsets and lengths of revisions shown using the `inspect rev` CLI command for
226
+ linearized PDF files
227
+ * [HexaPDF::Type::AcroForm::Form#recalculate_fields] to only consider real
228
+ fields
229
+
230
+
231
+ ## 1.0.2 - 2024-11-05
232
+
233
+ ### Added
234
+
235
+ * [HexaPDF::Type::CMap] for representing CMap streams
236
+
237
+ ### Fixed
238
+
239
+ * Checksum calculation for TrueType tables
240
+ * Automatic wrapping of dictionary entry /CIDToGIDMap for CID fonts
241
+ * Performance regression when encoding char codes for TrueType fonts
242
+ * PDF/A validation regression for PDFs using TrueType fonts
243
+
244
+
245
+ ## 1.0.1 - 2024-11-04
246
+
247
+ ### Changed
248
+
249
+ * Informational output on errors when running CLI commands to provide more
250
+ details
251
+
252
+ ### Fixed
253
+
254
+ * Parsing of indirect objects the value of which is an indirect reference
255
+ * Writing of the initial cross-reference section to ensure a single subsection
256
+ * [HexaPDF::Utils::SortedTreeNode] to wrap all /Kids entries with the correct
257
+ type class
258
+
259
+
260
+ ## 1.0.0 - 2024-10-26
261
+
262
+ ### Added
263
+
264
+ * [HexaPDF::Task::MergeAcroForm] for merging AcroForm information for imported
265
+ pages
266
+ * [HexaPDF::Document#write_to_string] and [HexaPDF::Composer#write_to_string]
267
+ for easily writing a document to a String
268
+ * [HexaPDF::Font::CMap::Writer#create_cid_cmap] for creating a character code to
269
+ CID CMap file
270
+
271
+ ### Changed
272
+
273
+ * [HexaPDF::Type::AcroForm::Form] text-like field creation methods to always set
274
+ a default appearance string and the quadding
275
+ * Convenience methods for accessing resources to not add the deprecated /ProcSet
276
+ entry by default
277
+ * [HexaPDF::DigitalSignature::CMSHandler] to add informational output regarding
278
+ the certificate chain on verification
279
+ * Validation of [HexaPDF::Type::FontType1] to ensure correct /Encoding value
280
+
281
+ ### Fixed
282
+
283
+ * [HexaPDF::DigitalSignature::Signature#signed_data] to work for invalid offsets
284
+ * [HexaPDF::DigitalSignature::Signing::DefaultHandler] to update the document's
285
+ version to 2.0 when using PAdES
286
+ * Parsing of invalid `)` character in PDF objects and content streams
287
+ * Handling of files that contain stream length values that are indirect objects
288
+ that do not exist
289
+ * [HexaPDF::Font::TrueTypeWrapper] to correctly handle the situation when
290
+ multiple codepoints refer to the same glyph ID
291
+ * [HexaPDF::Type::Page#contents] to handle null values in /Contents array
292
+
293
+
294
+ ## 0.47.0 - 2024-09-07
295
+
296
+ ### Added
297
+
298
+ * Configuration option 'acro_form.fallback_default_appearance' to allow setting
299
+ a standard default appearance string for a variable text field if none is
300
+ found
301
+ * Support for decrypting files with the proprietary algorithm /R 5
302
+
303
+ ### Changed
304
+
305
+ * [HexaPDF::Task::Optimize] to not remove optional /Type entries containing
306
+ default values
307
+ * Validation of [HexaPDF::Type::AcroForm::Form] to not add a /DA entry
308
+
309
+ ### Fixed
310
+
311
+ * [HexaPDF::Layout::TableBox] to correctly calculcate and distribute row
312
+ heights when row spans are involved
313
+ * [HexaPDF::Type::AcroForm::AppearanceGenerator] to work for files where check
314
+ boxes don't define the name of the on state
315
+ * [HexaPDF::Importer#import] to handle null values in all cases
316
+ * [HexaPDF::Type::AcroForm::VariableTextField] to handle parsing of invalid PDFs
317
+ with symbolic appearance strings
318
+ * [HexaPDF::Type::Annotations::Widget#marker_style] to handle invalid /DA values
319
+ with missing font size or color information
320
+ * [HexaPDF::Type::AcroForm::SignatureField#field_value] to always return a
321
+ correctly wrapped object
322
+ * [HexaPDF::Writer] to remove /Type entry from trailer
323
+ * [HexaPDF::Type::AcroForm::AppearanceGenerator#create_text_appearances] to
324
+ handle invalid appearance streams that are not correct Form XObjects
325
+
326
+
1
327
  ## 0.46.0 - 2024-08-11
2
328
 
3
329
  ### Added
@@ -20,7 +346,7 @@
20
346
  signatures
21
347
  * [HexaPDF::DigitalSignature::CMSHandler#signing_time] to use time from an
22
348
  embedded timestamp authority signature if possible
23
- * [HexaPDF::Layout::Box#fit] to return success for boxes with content
349
+ * HexaPDF::Layout::Box#fit to return success for boxes with content
24
350
  width/height of zero
25
351
  * [HexaPDF::Importer::copy] to optionally allow copying the catalog and page
26
352
  tree nodes
@@ -28,7 +354,7 @@
28
354
  ### Fixed
29
355
 
30
356
  * Setting of correct x-position in fit result for boxes with flow positioning
31
- * [HexaPDF::Layout::ListBox#fit] to respect the set height
357
+ * HexaPDF::Layout::ListBox#fit to respect the set height
32
358
  * CLI command `hexapdf inspect` to work in case of missing Unicde mappings
33
359
  * [HexaPDF::Type::AcroForm::Form#delete_field] to correctly work for fields with
34
360
  an embedded widget
@@ -47,7 +373,7 @@
47
373
 
48
374
  ### Changed
49
375
 
50
- * [HexaPDF::Layout::Box#fit] to set width/height correctly for boxes with
376
+ * HexaPDF::Layout::Box#fit to set width/height correctly for boxes with
51
377
  position `:flow`
52
378
 
53
379
  ### Fixed
@@ -93,9 +419,9 @@
93
419
 
94
420
  ### Fixed
95
421
 
96
- * [HexaPDF::Layout::TextBox#fit] to correctly calculate width in case of flowing
422
+ * HexaPDF::Layout::TextBox#fit to correctly calculate width in case of flowing
97
423
  text around other boxes
98
- * [HexaPDF::Layout::TextBox#draw] to correctly draw border, background... on
424
+ * HexaPDF::Layout::TextBox#draw to correctly draw border, background... on
99
425
  boxes using position 'flow'
100
426
  * Comparison of Hash with [HexaPDF::Dictionary] objects by implementing
101
427
  `#to_hash`
@@ -149,7 +475,7 @@
149
475
  JavaScript action that formats the field's value
150
476
  * [HexaPDF::Type::AcroForm::TextField#set_calculate_action] for setting a
151
477
  JavaScript action that calculates the field's value
152
- * [HexaPDF::Type::AcroForm#recalculate_fields] for recalculating fields
478
+ * [HexaPDF::Type::AcroForm::Form#recalculate_fields] for recalculating fields
153
479
 
154
480
  ### Changed
155
481
 
@@ -206,7 +532,7 @@
206
532
 
207
533
  ### Changed
208
534
 
209
- * [HexaPDF::Layout::Frame::FitResult#draw] to provide better optional content
535
+ * HexaPDF::Layout::Frame::FitResult#draw to provide better optional content
210
536
  group names
211
537
 
212
538
  ### Fixed
@@ -285,8 +611,8 @@
285
611
 
286
612
  ### Changed
287
613
 
288
- * [HexaPDF::Layout::Frame::FitResult#draw] to allow drawing at an offset
289
- * [HexaPDF::Layout::Box#fit] to delegate the actual content fitting to the
614
+ * HexaPDF::Layout::Frame::FitResult#draw to allow drawing at an offset
615
+ * HexaPDF::Layout::Box#fit to delegate the actual content fitting to the
290
616
  `#fit_content` method
291
617
  * [HexaPDF::Document::Layout#box] to allow using the block as drawing block for
292
618
  the base box class
@@ -363,8 +689,8 @@
363
689
 
364
690
  ### Fixed
365
691
 
366
- * [HexaPDF::Layout::ColumnBox#fit] to correctly take initial height into account
367
- * [HexaPDF::Layout::ColumnBox#fit] to ensure correct results in case the
692
+ * HexaPDF::Layout::ColumnBox#fit to correctly take initial height into account
693
+ * HexaPDF::Layout::ColumnBox#fit to ensure correct results in case the
368
694
  requested dimensions are larger than the current region
369
695
  * [HexaPDF::Document::Layout#formatted_text_box] to correctly handle properties
370
696
  * [HexaPDF::Layout::Frame#fit] to raise an error if an invalid value for the
@@ -410,7 +736,7 @@
410
736
  context argument (a page or Form XObject instance)
411
737
  * [HexaPDF::Layout::ListBox] to use its 'fill_color' style property for the item
412
738
  marker color
413
- * [HexaPDF::Layout::Frame::FitResult#draw] to use optional content groups for
739
+ * HexaPDF::Layout::Frame::FitResult#draw to use optional content groups for
414
740
  debug output
415
741
 
416
742
  ### Fixed
@@ -419,7 +745,7 @@
419
745
  default range starting at page 1
420
746
  * [HexaPDF::Type::Page#flatten_annotations] to correctly handle scaled
421
747
  appearances
422
- * Using an unknown style name in [HexaPDF:Document::Layout] method by providing
748
+ * Using an unknown style name in [HexaPDF::Document::Layout] method by providing
423
749
  a useful error message
424
750
  * [HexaPDF::Layout::Box::new] to ensure that the properties attribute is always
425
751
  a hash
@@ -480,7 +806,7 @@
480
806
  final box positions into account
481
807
  * [HexaPDF::Content::Canvas#text] to set the leading only when multiple lines
482
808
  are drawn
483
- * [HexaPDF::Layout::TextBox#split] to use float comparison
809
+ * HexaPDF::Layout::TextBox#split to use float comparison
484
810
  * Validation of standard encryption dictionary to auto-correct invalid /U and /O
485
811
  fields in case they are padded with zeros
486
812
  * [HexaPDF::Document#wrap] handling of sub-type mapping in case of missing type
@@ -897,7 +1223,7 @@
897
1223
  * [HexaPDF::Layout::WidthFromPolygon] to work correctly in case of very small
898
1224
  floating point errors
899
1225
  * HexaPDF::Layout::TextFragment#inspect to work in case of interspersed numbers
900
- * [HexaPDF::Layout::TextBox#split] to work for position :flow when box is wider
1226
+ * HexaPDF::Layout::TextBox#split to work for position :flow when box is wider
901
1227
  than the initial available width
902
1228
  * [HexaPDF::Layout::Frame#fit] to create minimally sized mask rectangles
903
1229
  * [HexaPDF::Content::GraphicObject::Geom2D] to close the path when drawing
@@ -1833,7 +2159,7 @@
1833
2159
  objects
1834
2160
  * [HexaPDF::Revision#each_modified_object] for iterating over all modified
1835
2161
  objects of a revision
1836
- * [HexaPDF::Layout::Box#split] and [HexaPDF::Layout::TextBox#split] for
2162
+ * [HexaPDF::Layout::Box#split] and HexaPDF::Layout::TextBox#split for
1837
2163
  splitting a box into two parts
1838
2164
  * [HexaPDF::Layout::Frame#full?] for testing whether the frame has any space
1839
2165
  left
data/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
2
- Copyright (C) 2014-2024 Thomas Leitner
2
+ Copyright (C) 2014-2025 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/README.md CHANGED
@@ -13,7 +13,7 @@ In short, it allows
13
13
  * **securing** PDF files by encrypting or signing them and
14
14
  * **optimizing** PDF files for smaller file size or other criteria.
15
15
 
16
- HexaPDF is available under two license, the AGPL and a commercial license, see the [License
16
+ HexaPDF is available under two licenses, the AGPL and a commercial license, see the [License
17
17
  section](#License) for details.
18
18
 
19
19
 
@@ -82,7 +82,7 @@ canvas.text("Hello World!", at: [20, 400])
82
82
  doc.write("hello-world.pdf")
83
83
  ~~~
84
84
 
85
- For detailed information have a look at the [HexaPDF website][website] where you will the API
85
+ For detailed information have a look at the [HexaPDF website][website] where you will find the API
86
86
  documentation, example code and more.
87
87
 
88
88
  It is recommend to use the HTML API documentation provided by the HexaPDF website as it is enhanced
@@ -93,12 +93,13 @@ with example graphics and PDF files and tightly integrated into the rest of the
93
93
 
94
94
  ## Requirements and Installation
95
95
 
96
- Since HexaPDF is written in Ruby, a working Ruby installation is needed - see the
97
- [official installation documentation][rbinstall] for details. Note that you need Ruby version 2.6 or
98
- higher as prior versions are not supported!
96
+ Since HexaPDF is written in Ruby, a working Ruby installation is needed - see the [official
97
+ installation documentation][rbinstall] for details. Note that you need Ruby version 3.0 or higher as
98
+ prior versions are not supported!
99
99
 
100
- HexaPDF works on all Ruby implementations that are CRuby compatible, e.g. TruffleRuby, and on any
101
- platform supported by Ruby (Linux, macOS, Windows, ...).
100
+ HexaPDF works on all Ruby implementations that are CRuby compatible and on any platform supported by
101
+ Ruby (Linux, macOS, Windows, ...). Implementations like JRuby and TruffleRuby should work but
102
+ HexaPDF is not actively tested against them.
102
103
 
103
104
  Apart from Ruby itself the HexaPDF library has only one external dependency `geom2d` which is
104
105
  written and provided by the HexaPDF authors. The `hexapdf` application has an additional dependency
@@ -117,7 +118,7 @@ Prawn is a **library for generating content**.
117
118
 
118
119
  To be more specific, it is easily possible to read an existing PDF with HexaPDF and modify parts of
119
120
  it before writing it out again. The modifications can be to the PDF object structure like removing
120
- superfluous annotations or the the content itself.
121
+ superfluous annotations or the content itself.
121
122
 
122
123
  Prawn has no such functionality. There is basic support for using a PDF as a template using the
123
124
  `pdf-reader` and `prawn-template` gems but support is very limited. However, Prawn has a very
@@ -4,6 +4,10 @@
4
4
  # inside a rectangular area, with various horizontal and vertical alignment
5
5
  # options.
6
6
  #
7
+ # It is not advised to use the `TextLayouter` class directly but instead via the
8
+ # [HexaPDF::Layout::TextBox] class and the general document layout
9
+ # functionality.
10
+ #
7
11
  # The text can be aligned horizontally by setting
8
12
  # [HexaPDF::Layout::Style#text_align] and vertically by
9
13
  # [HexaPDF::Layout::Style#text_valign]. In this example, a sample text is laid
@@ -3,6 +3,10 @@
3
3
  # The [HexaPDF::Layout::TextLayouter] class can be used to easily lay out text
4
4
  # mixed with inline boxes.
5
5
  #
6
+ # It is not advised to use the `TextLayouter` class directly but instead via the
7
+ # [HexaPDF::Layout::TextBox] class and the general document layout
8
+ # functionality.
9
+ #
6
10
  # Inline boxes are used for showing graphics that follow the flow of the text.
7
11
  # This means that their horizontal and their general vertical position is
8
12
  # determined by the text layout functionality. However, inline boxes may be
@@ -3,6 +3,10 @@
3
3
  # The [HexaPDF::Layout::TextLayouter] class can be used to easily lay out text,
4
4
  # automatically wrapping it appropriately.
5
5
  #
6
+ # It is not advised to use the `TextLayouter` class directly but instead via the
7
+ # [HexaPDF::Layout::TextBox] class and the general document layout
8
+ # functionality.
9
+ #
6
10
  # Text is broken only at certain characters:
7
11
  #
8
12
  # * The most important break points are **spaces**.
@@ -1,10 +1,15 @@
1
1
  # # Text Layouter - Styling
2
2
  #
3
3
  # The text used as part of a [HexaPDF::Layout::TextLayouter] class can be styled
4
- # using [HexaPDF::Layout::Style]. To do this [HexaPDF::Layout::TextFragment]
5
- # objects have to be created with the needed styling and then added to a text
6
- # layout object. In addition the style objects can be used for customizing the
7
- # text layouts themselves.
4
+ # using [HexaPDF::Layout::Style].
5
+ #
6
+ # It is not advised to use the `TextLayouter` class directly but instead via the
7
+ # [HexaPDF::Layout::TextBox] class and the general document layout
8
+ # functionality.
9
+ #
10
+ # To style [HexaPDF::Layout::TextFragment] objects, they have to be created with
11
+ # the needed styling and then added to a text layout object. In addition, the
12
+ # style objects can be used for customizing the text layouts themselves.
8
13
  #
9
14
  # This example shows how to do this and shows off the various styling option,
10
15
  # including using callbacks to further customize the appearance.
@@ -5,6 +5,11 @@
5
5
  # restriction: In the case of arbitrary shapes the vertical alignment has to be
6
6
  # "top".
7
7
  #
8
+ # Note that using [HexaPDF::Layout::TextBox] is preferred over
9
+ # `TextLayouter`. However, it is currently not possible to flow text into
10
+ # arbitrary shapes with `TextBox`. So if this functionality is required, the
11
+ # `TextLayouter` class needs to be used directly.
12
+ #
8
13
  # Arbitrary shapes boil down to varying line widths and horizontal offsets from
9
14
  # left. Imagine a circle: If text is fit in a circle, the line widths start at
10
15
  # zero, getting larger and larger until the middle of the cirle. And then they
@@ -3,6 +3,9 @@
3
3
  # The [HexaPDF::Layout::Box] class is used as the basis for all document layout
4
4
  # features.
5
5
  #
6
+ # While it is possible to use boxes in this manual way, the preferred way is to
7
+ # use them through the [Composer class](composer.html).
8
+ #
6
9
  # This example shows the basic properties that are available for all boxes, like
7
10
  # paddings, borders and and background color. It is also possible to use the
8
11
  # underlay and overlay callbacks with boxes.
@@ -2,6 +2,9 @@
2
2
  #
3
3
  # The [HexaPDF::Layout::Frame] class is used for placing rectangular boxes.
4
4
  #
5
+ # While it is possible to use frames in this manual way, the preferred way is to
6
+ # use them through the [Composer class](composer.html).
7
+ #
5
8
  # This example shows how to create a frame and how different box styles can be
6
9
  # used to specify where a box should be placed. After each box is drawn, the
7
10
  # frame's shape is drawn and then a new page is started. This is done to easily
@@ -3,6 +3,9 @@
3
3
  # This example shows how [HexaPDF::Layout::Frame] and [HexaPDF::Layout::TextBox]
4
4
  # can be used to flow text around objects.
5
5
  #
6
+ # While it is possible to use frames and boxes in this manual way, the preferred
7
+ # way is to use them through the [Composer class](composer.html).
8
+ #
6
9
  # Three boxes are placed repeatedly onto the frame until it is filled: two
7
10
  # floating boxes (one left, one right) and a text box. The text box is styled to
8
11
  # flow its content around the other two boxes.
@@ -10,7 +10,11 @@
10
10
  require 'hexapdf'
11
11
 
12
12
  doc = HexaPDF::Document.new
13
- 6.times { doc.pages.add }
13
+ 6.times do |i|
14
+ doc.pages.add.canvas.
15
+ font("Helvetica", size: 150).
16
+ text("Page #{i + 1}", at: [10, 660])
17
+ end
14
18
 
15
19
  doc.outline.add_item("Main") do |main|
16
20
  main.add_item("Page 1", destination: 0)
@@ -1,15 +1,15 @@
1
- # # Frame - Mask Mode
1
+ # # Composer - Mask Mode
2
2
  #
3
3
  # This example shows how to use the style property 'mask_mode' to achieve
4
4
  # certain effects like overlaying boxes on each other or using multiple
5
5
  # horizontal alignments on one line.
6
6
  #
7
7
  # Usage:
8
- # : `ruby frame_mask_mode.rb`
8
+ # : `ruby composer_mask_mode.rb`
9
9
  #
10
10
  require 'hexapdf'
11
11
 
12
- HexaPDF::Composer.create('frame_mask_mode.pdf') do |composer|
12
+ HexaPDF::Composer.create('composer_mask_mode.pdf') do |composer|
13
13
  box = composer.image(File.join(__dir__, 'machupicchu.jpg'),
14
14
  border: {width: 1}, mask_mode: :none)
15
15
  composer.text('Text overlaid over image', height: box.height, text_align: :center,
@@ -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-2024 Thomas Leitner
7
+ # Copyright (C) 2014-2025 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