Sha256: 18866d3b5624a8f1c2d9d2a0bf032953cce6f4ea90c7e5d6658ec6ffdb9b4bfa

Contents?: true

Size: 1.46 KB

Versions: 7

Compression:

Stored size: 1.46 KB

Contents

get '/sample8' do
  haml :sample8
end
post '/sample8' do
  set :client_id, params[:client_id]
  set :private_key, params[:private_key]
  set :guid, params[:guid]
  set :page_number, params[:page_number]
  
  
   #   file = GroupDocs::Storage::Folder.list!.last
   #   document = file.to_document
   #   document.page_images! 1024, 768, first_page: 0, page_count: 1 
   
  begin
    raise "Please enter all required parameters" if settings.client_id.empty? or settings.private_key.empty?
    files_list = GroupDocs::Storage::Folder.list!('/', {}, { :client_id => settings.client_id, :private_key => settings.private_key})
    doc = nil
    metadata = nil
    files_list.each do |element|
      if element.class.name.split('::').last == 'Folder'
        next
      end
      
      if element.guid == settings.guid
        metadata = element.to_document.metadata!({ :client_id => settings.client_id, :private_key => settings.private_key})
        doc = element.to_document
      end
    end
    images =  doc.page_images!(800, 400, {:first_page => 0, :page_count => metadata.page_count}, { :client_id => settings.client_id, :private_key => settings.private_key})

    unless images.empty?
      image = images[Integer(settings.page_number)]
    end
  rescue Exception => e
    err = e.message
  end  
  
  haml :sample8, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :guid =>settings.guid , :page_number=>settings.page_number, :image=>image, :err => err }
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
groupdocs-1.2.8 examples/api-samples/samples/sample8.rb
groupdocs-1.2.7 examples/api-samples/samples/sample8.rb
groupdocs-1.2.6 examples/api-samples/samples/sample8.rb
groupdocs-1.2.3 examples/api-samples/samples/sample8.rb
groupdocs-1.2.2 examples/api-samples/samples/sample8.rb
groupdocs-1.2.1 examples/api-samples/samples/sample8.rb
groupdocs-1.2.0 examples/api-samples/samples/sample8.rb