Sha256: da6e54d42ee86e8f5cf85fc218b2475d5a601671dfc309060638b07a8860843d

Contents?: true

Size: 754 Bytes

Versions: 8

Compression:

Stored size: 754 Bytes

Contents

#!/usr/bin/env ruby

begin
    require 'origami'
rescue LoadError
    $: << File.join(__dir__, "../../lib")
    require 'origami'
end
include Origami

OUTPUT_FILE = "#{File.basename(__FILE__, ".rb")}.pdf"

# Creating a new file
pdf = PDF.new

# Embedding the file into the PDF.
pdf.attach_file(DATA,
    name: "README.txt",
    filter: :ASCIIHexDecode
)

contents = ContentStream.new
contents.write "File attachment sample",
    x: 150, y: 750, rendering: Text::Rendering::FILL, size: 30

pdf.append_page Page.new.setContents(contents)

pdf.onDocumentOpen Action::JavaScript <<JS
    this.exportDataObject({cName:"README.txt", nLaunch:2});
JS


pdf.save(OUTPUT_FILE)

puts "PDF file saved as #{OUTPUT_FILE}."

__END__
This is the attached file contents.

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
origamindee-3.1.0 examples/attachments/attachment.rb
origamindee-3.0.0 examples/attachments/attachment.rb
origami-2.1.0 examples/attachments/attachment.rb
origami-2.0.4 examples/attachments/attachment.rb
origami-2.0.3 examples/attachments/attachment.rb
origami-2.0.2 examples/attachments/attachment.rb
origami-2.0.1 examples/attachments/attachment.rb
origami-2.0.0 examples/attachments/attachment.rb