File: flash.rb

package info (click to toggle)
origami-pdf 2.1.0-1~exp2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,444 kB
  • sloc: ruby: 17,883; makefile: 8
file content (37 lines) | stat: -rwxr-xr-x 869 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env ruby

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

#
# Embeding a Flash asset inside a PDF document.
#

SWF_PATH = File.join(__dir__, "helloworld.swf")
OUTPUT_FILE = "#{File.basename(__FILE__, ".rb")}.pdf"

# Creating a new file
pdf = PDF.new

# Embedding the SWF file into the PDF.
swf = pdf.attach_file(SWF_PATH)

# Creating a Flash annotation on the page.
pdf.append_page do |page|
    annot = page.add_flash_application(swf,
                                       windowed: true,
                                       navigation_pane: true,
                                       toolbar: true)

    # Setting the player position on the page.
    annot.Rect = Rectangle.new [204, 573, 403, 718]
end

pdf.save(OUTPUT_FILE)

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