Sha256: dde9205baee445b53de4a806cab1697c1da20e819d3dfde83011201ac232845f
Contents?: true
Size: 1.87 KB
Versions: 19
Compression:
Stored size: 1.87 KB
Contents
# # Composer # # This example shows how [HexaPDF::Composer] simplifies the creation of PDF # documents by providing a high-level interface to the box layouting engine. # # Basic style properties can be set using the [HexaPDF::Composer#style] method # and the style name `:basic`. These properties are reused by every box and can # be adjusted on a box-by-box basis. Newly defined styles also inherit the # properties from the `:basic` style. # # Various methods allow the easy creation of boxes, for example, text and image # boxes. All these boxes are automatically drawn on the page. If the page has # not enough room left for a box, the box is split across pages (which are # automatically created) if possible or just drawn on the new page. # # Usage: # : `ruby composer.rb` # require 'hexapdf' lorem_ipsum = "Lorem ipsum dolor sit amet, con\u{00AD}sectetur adipis\u{00AD}cing elit, sed do eiusmod tempor incidi\u{00AD}dunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exer\u{00AD}citation ullamco laboris nisi ut aliquip ex ea commodo consequat. ".tr("\n", " ") HexaPDF::Composer.create('composer.pdf') do |pdf| pdf.style(:base, line_spacing: 1.5, last_line_gap: true, align: :justify) pdf.style(:image, border: {width: 1}, padding: 5, margin: 10) pdf.style(:link, fill_color: [6, 158, 224], underline: true) image = File.join(__dir__, 'machupicchu.jpg') pdf.text(lorem_ipsum * 2) pdf.image(image, style: :image, width: 200, position: :float) pdf.image(image, style: :image, width: 200, position: :absolute, position_hint: [200, 300]) pdf.text(lorem_ipsum * 20, position: :flow) pdf.formatted_text(["Produced by ", {link: "https://hexapdf.gettalong.org", text: "HexaPDF", style: :link}, " via HexaPDF::Composer"], font_size: 15, align: :center, padding: 15) end
Version data entries
19 entries across 19 versions & 1 rubygems