class Origami::XDP::Packet::PDF

An XDF pdf element encloses a PDF packet.

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/origami/xfa/pdf.rb, line 34
def initialize
    super("pdf")

    add_attribute 'xmlns', 'http://ns.adobe.com/xdp/pdf/'
end

Public Instance Methods

enclose_pdf(pdfdata) click to toggle source
# File lib/origami/xfa/pdf.rb, line 40
def enclose_pdf(pdfdata)
    require 'base64'
    b64data = Base64.encode64(pdfdata).chomp!

    doc = elements['document'] || add_element('document')
    chunk = doc.elements['chunk'] || doc.add_element('chunk')

    chunk.text = b64data

    self
end
enclosed_pdf() click to toggle source
# File lib/origami/xfa/pdf.rb, line 62
def enclosed_pdf
    return nil unless has_enclosed_pdf?

    require 'base64'
    Base64.decode64(elements['document/chunk'].text)
end
has_enclosed_pdf?() click to toggle source
# File lib/origami/xfa/pdf.rb, line 52
def has_enclosed_pdf?
    chunk = elements['document/chunk']

    not chunk.nil? and not chunk.text.nil?
end
remove_enclosed_pdf() click to toggle source
# File lib/origami/xfa/pdf.rb, line 58
def remove_enclosed_pdf
    elements.delete('document') if has_enclosed_pdf?
end