Sha256: 5509ffc33067891285e5df36f296c8cc5147b3c37aac9c7e9409f2ea5bf5fcde

Contents?: true

Size: 641 Bytes

Versions: 2

Compression:

Stored size: 641 Bytes

Contents

require 'base64'

module Indico
    def self.preprocess_pdf(pdf)
        if pdf.class == Array
            # Batch Request
            pdf_array = Array.new

            # process each image
            pdf.each do |_pdf|
                pdf_array.push(preprocess_pdf(_pdf))
            end

            return pdf_array
        elsif pdf.class != String
            raise Exception.new("PDF input must be filename, url or base64 string")
        end

        begin
            return Base64.encode64(File.read(pdf))
        rescue
            # likely a url or a base64 encoded string already
            return pdf
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
indico-0.10.5 lib/indico/pdf.rb
indico-0.10.4 lib/indico/pdf.rb