examples/api-samples/samples/sample18.rb in groupdocs-1.2.11 vs examples/api-samples/samples/sample18.rb in groupdocs-1.3.0

- old
+ new

@@ -25,15 +25,16 @@ document = element end end message = "" + iframe = "" unless document.instance_of? String # convert file convert = document.to_document.convert!(settings.convert_type, {}, {:client_id => settings.client_id, :private_key => settings.private_key}) - sleep(3) + sleep(5) if convert.instance_of? GroupDocs::Job # get all jobs jobs = GroupDocs::Job::all!({}, {:client_id => settings.client_id, :private_key => settings.private_key}) @@ -44,10 +45,18 @@ job = element end end if job.status == :archived + # get job by ID + job = GroupDocs::Job.new(id: convert.id) + # get all job documents + documents = job.documents!({:client_id => settings.client_id, :private_key => settings.private_key}) + # get compared file giud + guid = documents[:inputs].first.outputs.first.guid + # construct result iframe + iframe = "<iframe src='https://apps.groupdocs.com/document-viewer/embed/#{guid}' frameborder='0' width='100%' height='600'></iframe>" message = "<p>Converted file saved successfully." end end end @@ -55,7 +64,7 @@ rescue Exception => e err = e.message end # set variables for template - haml :sample18, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :fileId => settings.file_id, :message => message, :err => err } + haml :sample18, :locals => { :userId => settings.client_id, :privateKey => settings.private_key, :fileId => settings.file_id, :message => message, :iframe => iframe, :err => err } end