groupdocs 1.5.7 → 1.5.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +51 -0
- data/examples/api-samples/Gemfile +1 -1
- data/examples/api-samples/Gemfile.lock +43 -0
- data/examples/api-samples/public/docs/{sample2.html → sample01.html} +39 -19
- data/examples/api-samples/public/docs/{sample3.html → sample02.html} +28 -22
- data/examples/api-samples/public/docs/sample03.html +285 -0
- data/examples/api-samples/public/docs/{sample4.html → sample04.html} +30 -36
- data/examples/api-samples/public/docs/{sample5.html → sample05.html} +68 -31
- data/examples/api-samples/public/docs/sample06.html +299 -0
- data/examples/api-samples/public/docs/{sample7.html → sample07.html} +53 -18
- data/examples/api-samples/public/docs/{sample8.html → sample08.html} +64 -41
- data/examples/api-samples/public/docs/sample09.html +260 -0
- data/examples/api-samples/public/docs/sample10.html +67 -28
- data/examples/api-samples/public/docs/sample11.html +171 -55
- data/examples/api-samples/public/docs/sample12.html +53 -17
- data/examples/api-samples/public/docs/sample13.html +52 -16
- data/examples/api-samples/public/docs/sample14.html +51 -8
- data/examples/api-samples/public/docs/sample15.html +46 -10
- data/examples/api-samples/public/docs/sample16.html +81 -7
- data/examples/api-samples/public/docs/sample17.html +103 -15
- data/examples/api-samples/public/docs/sample18.html +117 -41
- data/examples/api-samples/public/docs/sample19.html +410 -36
- data/examples/api-samples/public/docs/sample20.html +46 -10
- data/examples/api-samples/public/docs/sample21.html +504 -45
- data/examples/api-samples/public/docs/sample22.html +166 -28
- data/examples/api-samples/public/docs/sample23.html +61 -25
- data/examples/api-samples/public/docs/sample24.html +100 -12
- data/examples/api-samples/public/docs/sample25.html +123 -49
- data/examples/api-samples/public/docs/sample26.html +41 -8
- data/examples/api-samples/public/docs/sample27.html +125 -50
- data/examples/api-samples/public/docs/sample28.html +27 -9
- data/examples/api-samples/public/docs/sample29.html +10 -10
- data/examples/api-samples/public/docs/sample30.html +70 -14
- data/examples/api-samples/public/docs/sample31.html +108 -67
- data/examples/api-samples/public/docs/sample32.html +71 -99
- data/examples/api-samples/public/docs/sample33.html +107 -32
- data/examples/api-samples/public/docs/{sample1.html → sample34.html} +58 -18
- data/examples/api-samples/public/docs/sample35.html +666 -0
- data/examples/api-samples/public/docs/{sample6.html → sample36.html} +56 -37
- data/examples/api-samples/public/docs/sample37.html +815 -0
- data/examples/api-samples/public/docs/sample38.html +508 -0
- data/examples/api-samples/public/docs/sample39.html +921 -0
- data/examples/api-samples/public/docs/sample40.html +510 -0
- data/examples/api-samples/public/docs/sample41.html +452 -0
- data/examples/api-samples/public/docs/sample42.html +311 -0
- data/examples/api-samples/public/templates/test_all_fields2.pdf +0 -0
- data/examples/api-samples/samples/sample01.rb +37 -0
- data/examples/api-samples/samples/sample02.rb +41 -0
- data/examples/api-samples/samples/sample03.rb +73 -0
- data/examples/api-samples/samples/sample04.rb +47 -0
- data/examples/api-samples/samples/{sample5.rb → sample05.rb} +26 -14
- data/examples/api-samples/samples/sample06.rb +80 -0
- data/examples/api-samples/samples/sample07.rb +52 -0
- data/examples/api-samples/samples/sample08.rb +69 -0
- data/examples/api-samples/samples/sample09.rb +83 -0
- data/examples/api-samples/samples/sample10.rb +29 -15
- data/examples/api-samples/samples/sample11.rb +89 -37
- data/examples/api-samples/samples/sample12.rb +22 -11
- data/examples/api-samples/samples/sample13.rb +22 -10
- data/examples/api-samples/samples/sample14.rb +23 -5
- data/examples/api-samples/samples/sample15.rb +18 -7
- data/examples/api-samples/samples/sample16.rb +28 -4
- data/examples/api-samples/samples/sample17.rb +31 -5
- data/examples/api-samples/samples/sample18.rb +36 -8
- data/examples/api-samples/samples/sample19.rb +138 -18
- data/examples/api-samples/samples/sample20.rb +14 -3
- data/examples/api-samples/samples/sample21.rb +162 -23
- data/examples/api-samples/samples/sample22.rb +73 -22
- data/examples/api-samples/samples/sample23.rb +17 -6
- data/examples/api-samples/samples/sample24.rb +34 -7
- data/examples/api-samples/samples/sample25.rb +37 -12
- data/examples/api-samples/samples/sample26.rb +12 -5
- data/examples/api-samples/samples/sample27.rb +38 -12
- data/examples/api-samples/samples/sample28.rb +25 -6
- data/examples/api-samples/samples/sample29.rb +12 -12
- data/examples/api-samples/samples/sample30.rb +27 -15
- data/examples/api-samples/samples/sample31.rb +44 -33
- data/examples/api-samples/samples/sample32.rb +43 -41
- data/examples/api-samples/samples/sample33.rb +42 -14
- data/examples/api-samples/samples/sample34.rb +40 -0
- data/examples/api-samples/samples/sample35.rb +224 -0
- data/examples/api-samples/samples/sample36.rb +58 -0
- data/examples/api-samples/samples/sample37.rb +229 -0
- data/examples/api-samples/samples/sample38.rb +128 -0
- data/examples/api-samples/samples/sample39.rb +252 -0
- data/examples/api-samples/samples/sample40.rb +164 -0
- data/examples/api-samples/samples/sample41.rb +118 -0
- data/examples/api-samples/samples/sample42.rb +97 -0
- data/examples/api-samples/views/_others_samples.haml +25 -11
- data/examples/api-samples/views/index.haml +23 -11
- data/examples/api-samples/views/popup.haml +32 -0
- data/examples/api-samples/views/{sample1.haml → sample01.haml} +12 -7
- data/examples/api-samples/views/{sample2.haml → sample02.haml} +20 -15
- data/examples/api-samples/views/sample03.haml +83 -0
- data/examples/api-samples/views/sample04.haml +49 -0
- data/examples/api-samples/views/{sample5.haml → sample05.haml} +19 -14
- data/examples/api-samples/views/sample06.haml +53 -0
- data/examples/api-samples/views/sample07.haml +47 -0
- data/examples/api-samples/views/{sample8.haml → sample08.haml} +17 -12
- data/examples/api-samples/views/{sample9.haml → sample09.haml} +19 -4
- data/examples/api-samples/views/sample10.haml +18 -13
- data/examples/api-samples/views/sample11.haml +48 -19
- data/examples/api-samples/views/sample12.haml +26 -21
- data/examples/api-samples/views/sample13.haml +18 -12
- data/examples/api-samples/views/sample14.haml +21 -15
- data/examples/api-samples/views/sample15.haml +16 -9
- data/examples/api-samples/views/sample16.haml +18 -5
- data/examples/api-samples/views/sample17.haml +14 -9
- data/examples/api-samples/views/sample18.haml +13 -7
- data/examples/api-samples/views/sample19.haml +37 -8
- data/examples/api-samples/views/sample20.haml +13 -8
- data/examples/api-samples/views/sample21.haml +71 -13
- data/examples/api-samples/views/sample22.haml +53 -16
- data/examples/api-samples/views/sample23.haml +9 -4
- data/examples/api-samples/views/sample24.haml +9 -4
- data/examples/api-samples/views/sample25.haml +18 -13
- data/examples/api-samples/views/sample26.haml +8 -3
- data/examples/api-samples/views/sample27.haml +20 -14
- data/examples/api-samples/views/sample28.haml +16 -10
- data/examples/api-samples/views/sample29.haml +4 -4
- data/examples/api-samples/views/sample30.haml +16 -10
- data/examples/api-samples/views/sample31.haml +39 -32
- data/examples/api-samples/views/sample32.haml +25 -36
- data/examples/api-samples/views/sample33.haml +14 -17
- data/examples/api-samples/views/sample34.haml +48 -0
- data/examples/api-samples/views/sample35.haml +95 -0
- data/examples/api-samples/views/sample36.haml +64 -0
- data/examples/api-samples/views/sample37.haml +124 -0
- data/examples/api-samples/views/sample38.haml +115 -0
- data/examples/api-samples/views/sample39.haml +236 -0
- data/examples/api-samples/views/sample40.haml +95 -0
- data/examples/api-samples/views/{sample4.haml → sample41.haml} +90 -72
- data/examples/api-samples/views/sample42.haml +59 -0
- data/lib/groupdocs/api/helpers/rest_helper.rb +13 -1
- data/lib/groupdocs/datasource.rb +2 -1
- data/lib/groupdocs/document.rb +101 -13
- data/lib/groupdocs/document/annotation.rb +28 -13
- data/lib/groupdocs/document/annotation/marker.rb +18 -0
- data/lib/groupdocs/document/annotation/reply.rb +9 -2
- data/lib/groupdocs/document/field.rb +5 -1
- data/lib/groupdocs/job.rb +12 -2
- data/lib/groupdocs/questionnaire.rb +174 -4
- data/lib/groupdocs/questionnaire/collector.rb +21 -0
- data/lib/groupdocs/questionnaire/question.rb +19 -0
- data/lib/groupdocs/questionnaire/question/answer.rb +5 -0
- data/lib/groupdocs/questionnaire/question/conditions.rb +20 -0
- data/lib/groupdocs/signature.rb +36 -308
- data/lib/groupdocs/signature/envelope.rb +146 -4
- data/lib/groupdocs/signature/field.rb +20 -1
- data/lib/groupdocs/signature/field/location.rb +18 -7
- data/lib/groupdocs/signature/form.rb +199 -10
- data/lib/groupdocs/signature/shared/document_methods.rb +38 -0
- data/lib/groupdocs/signature/shared/entity_methods.rb +0 -1
- data/lib/groupdocs/signature/shared/field_methods.rb +13 -38
- data/lib/groupdocs/signature/shared/recipient_methods.rb +8 -0
- data/lib/groupdocs/signature/template.rb +3 -1
- data/lib/groupdocs/storage.rb +4 -1
- data/lib/groupdocs/storage/file.rb +18 -1
- data/lib/groupdocs/subscription.rb +8 -3
- data/lib/groupdocs/user.rb +8 -0
- data/lib/groupdocs/version.rb +1 -1
- data/spec/groupdocs/document/annotation_spec.rb +1 -14
- data/spec/groupdocs/subscription_spec.rb +2 -2
- metadata +86 -32
- checksums.yaml +0 -15
- data/examples/api-samples/public/docs/sample9.html +0 -200
- data/examples/api-samples/samples/sample1.rb +0 -25
- data/examples/api-samples/samples/sample2.rb +0 -29
- data/examples/api-samples/samples/sample3.rb +0 -33
- data/examples/api-samples/samples/sample4.rb +0 -51
- data/examples/api-samples/samples/sample6.rb +0 -49
- data/examples/api-samples/samples/sample7.rb +0 -42
- data/examples/api-samples/samples/sample8.rb +0 -61
- data/examples/api-samples/samples/sample9.rb +0 -48
- data/examples/api-samples/views/sample3.haml +0 -44
- data/examples/api-samples/views/sample6.haml +0 -49
- data/examples/api-samples/views/sample7.haml +0 -42
@@ -0,0 +1,164 @@
|
|
1
|
+
# GET request
|
2
|
+
get '/sample40' do
|
3
|
+
haml :sample40
|
4
|
+
end
|
5
|
+
|
6
|
+
# POST request
|
7
|
+
post '/sample40/check_guid' do
|
8
|
+
begin
|
9
|
+
result = nil
|
10
|
+
i = 0
|
11
|
+
for i in 1..10
|
12
|
+
i +=1
|
13
|
+
# Check is downloads folder exist
|
14
|
+
if File.exist?("#{File.dirname(__FILE__)}/../public/callback_info.txt")
|
15
|
+
result = File.read("#{File.dirname(__FILE__)}/../public/callback_info.txt")
|
16
|
+
if result != '' then break end
|
17
|
+
end
|
18
|
+
sleep(5)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Check result
|
22
|
+
if result == 'Error'
|
23
|
+
result = "File was not found. Looks like something went wrong."
|
24
|
+
else
|
25
|
+
result
|
26
|
+
end
|
27
|
+
|
28
|
+
rescue Exception => e
|
29
|
+
err = e.message
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
# POST request
|
35
|
+
post '/sample40/callback' do
|
36
|
+
|
37
|
+
source_id = ''
|
38
|
+
client_id = ''
|
39
|
+
private_key = ''
|
40
|
+
|
41
|
+
# Get callback request
|
42
|
+
data = JSON.parse(request.body.read)
|
43
|
+
begin
|
44
|
+
participant = nil
|
45
|
+
raise 'Empty params!' if data.empty?
|
46
|
+
|
47
|
+
# Get value of SourceId
|
48
|
+
data.each do |key, value|
|
49
|
+
if key == 'SourceId'
|
50
|
+
source_id = value
|
51
|
+
end
|
52
|
+
if key == 'SerializedData'
|
53
|
+
data = JSON.parse(value)
|
54
|
+
data.each do |key, value|
|
55
|
+
if key == 'ParticipantGuid'
|
56
|
+
participant = value
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Get private key and client_id from file user_info.txt
|
63
|
+
if File.exist?("#{File.dirname(__FILE__)}/../public/user_info.txt")
|
64
|
+
contents = File.read("#{File.dirname(__FILE__)}/../public/user_info.txt")
|
65
|
+
contents = contents.split(' ')
|
66
|
+
client_id = contents[0]
|
67
|
+
private_key = contents[1]
|
68
|
+
end
|
69
|
+
|
70
|
+
# Create new Form
|
71
|
+
form = GroupDocs::Signature::Form.new({:id => source_id})
|
72
|
+
# Create new Signature
|
73
|
+
signature = GroupDocs::Signature.new()
|
74
|
+
doc_info = signature.get_sign_form_participant!(form.id , participant, {:client_id => client_id, :private_key => private_key} )
|
75
|
+
|
76
|
+
guid = doc_info[:documentGuid]
|
77
|
+
|
78
|
+
out_file = File.new("#{File.dirname(__FILE__)}/../public/callback_info.txt", 'w')
|
79
|
+
# white space is required
|
80
|
+
out_file.write(guid)
|
81
|
+
out_file.close
|
82
|
+
|
83
|
+
rescue Exception => e
|
84
|
+
err = e.message
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
# POST request
|
91
|
+
post '/sample40' do
|
92
|
+
# set variables
|
93
|
+
set :client_id, params[:clientId]
|
94
|
+
set :private_key, params[:privateKey]
|
95
|
+
set :form_guid, params[:formGuid]
|
96
|
+
set :callback, params[:callbackUrl]
|
97
|
+
set :base_path, params[:basePath]
|
98
|
+
|
99
|
+
begin
|
100
|
+
|
101
|
+
# Check required variables
|
102
|
+
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.form_guid.empty?
|
103
|
+
|
104
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
105
|
+
|
106
|
+
# Configure your access to API server
|
107
|
+
GroupDocs.configure do |groupdocs|
|
108
|
+
groupdocs.client_id = settings.client_id
|
109
|
+
groupdocs.private_key = settings.private_key
|
110
|
+
# Optionally specify API server and version
|
111
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
112
|
+
end
|
113
|
+
|
114
|
+
# Write client and private key to the file for callback job
|
115
|
+
if settings.callback
|
116
|
+
out_file = File.new("#{File.dirname(__FILE__)}/../public/user_info.txt", 'w')
|
117
|
+
# white space is required
|
118
|
+
out_file.write("#{settings.client_id} ")
|
119
|
+
out_file.write("#{settings.private_key} ")
|
120
|
+
out_file.close
|
121
|
+
end
|
122
|
+
|
123
|
+
guid = settings.form_guid
|
124
|
+
|
125
|
+
# Create new Form with guid
|
126
|
+
form = GroupDocs::Signature::Form.new()
|
127
|
+
form.name = "Test Form"
|
128
|
+
# Get id with new Form
|
129
|
+
id = form.create!({:formId => guid})
|
130
|
+
# Get Form
|
131
|
+
form = GroupDocs::Signature::Form.get!(id)
|
132
|
+
# Publish the Form
|
133
|
+
form.publish!({:callbackUrl => settings.callback})
|
134
|
+
|
135
|
+
# Get url from request
|
136
|
+
case settings.base_path
|
137
|
+
|
138
|
+
when 'https://stage-api-groupdocs.dynabic.com'
|
139
|
+
url = "http://stage-apps-groupdocs.dynabic.com/signature2/forms/signembed/ #{guid}"
|
140
|
+
when 'https://dev-api-groupdocs.dynabic.com'
|
141
|
+
url = "http://dev-apps-groupdocs.dynabic.com/signature2/forms/signembed/ #{guid}"
|
142
|
+
else
|
143
|
+
url = "https://apps.groupdocs.com/signature2/forms/signembed/ #{guid}"
|
144
|
+
end
|
145
|
+
# Delete file callback_info.txt
|
146
|
+
if File.exist?("#{File.dirname(__FILE__)}/../public/callback_info.txt")
|
147
|
+
File.delete("#{File.dirname(__FILE__)}/../public/callback_info.txt")
|
148
|
+
end
|
149
|
+
|
150
|
+
# Add the signature to url the request
|
151
|
+
iframe = GroupDocs::Api::Request.new(:path => url).prepare_and_sign_url
|
152
|
+
iframe = "<iframe width='100%' id='downloadframe' height='600' src='#{iframe}'></iframe>"
|
153
|
+
|
154
|
+
rescue Exception => e
|
155
|
+
err = e.message
|
156
|
+
end
|
157
|
+
|
158
|
+
# Set variables for template
|
159
|
+
haml :sample40, :locals => {:userId => settings.client_id,
|
160
|
+
:privateKey => settings.private_key,
|
161
|
+
:callback => settings.callback,
|
162
|
+
:iframe => iframe,
|
163
|
+
:err => err}
|
164
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# GET request
|
2
|
+
get '/sample41' do
|
3
|
+
haml :sample41
|
4
|
+
end
|
5
|
+
|
6
|
+
# POST request
|
7
|
+
post '/sample41' do
|
8
|
+
# set variables
|
9
|
+
set :client_id, params[:clientId]
|
10
|
+
set :private_key, params[:privateKey]
|
11
|
+
set :source, params[:source]
|
12
|
+
set :file_id, params[:fileId]
|
13
|
+
set :url, params[:url]
|
14
|
+
set :base_path, params[:basePath]
|
15
|
+
|
16
|
+
# Set download path
|
17
|
+
downloads_path = "#{File.dirname(__FILE__)}/../public/downloads"
|
18
|
+
|
19
|
+
# Remove all files from download directory or create folder if it not there
|
20
|
+
if File.directory?(downloads_path)
|
21
|
+
Dir.foreach(downloads_path) { |f| fn = File.join(downloads_path, f); File.delete(fn) if f != '.' && f != '..' }
|
22
|
+
else
|
23
|
+
Dir::mkdir(downloads_path)
|
24
|
+
end
|
25
|
+
|
26
|
+
begin
|
27
|
+
# Check required variables
|
28
|
+
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
|
29
|
+
|
30
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
31
|
+
|
32
|
+
# Configure your access to API server
|
33
|
+
GroupDocs.configure do |groupdocs|
|
34
|
+
groupdocs.client_id = settings.client_id
|
35
|
+
groupdocs.private_key = settings.private_key
|
36
|
+
# Optionally specify API server and version
|
37
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
38
|
+
end
|
39
|
+
|
40
|
+
# Get document by file GUID
|
41
|
+
case settings.source
|
42
|
+
when 'guid'
|
43
|
+
# Create instance of File
|
44
|
+
file = GroupDocs::Storage::File.new({:guid => settings.file_id})
|
45
|
+
when 'local'
|
46
|
+
# Construct path
|
47
|
+
file_path = "#{Dir.tmpdir}/#{params[:file][:filename]}"
|
48
|
+
# Open file
|
49
|
+
File.open(file_path, 'wb') { |f| f.write(params[:file][:tempfile].read) }
|
50
|
+
# Make a request to API using client_id and private_key
|
51
|
+
file = GroupDocs::Storage::File.upload!(file_path, {})
|
52
|
+
when 'url'
|
53
|
+
# Upload file from defined url
|
54
|
+
file = GroupDocs::Storage::File.upload_web!(settings.url)
|
55
|
+
else
|
56
|
+
raise 'Wrong GUID source.'
|
57
|
+
end
|
58
|
+
|
59
|
+
# Raise exception if something went wrong
|
60
|
+
raise 'No such file' unless file.is_a?(GroupDocs::Storage::File)
|
61
|
+
|
62
|
+
# Make GroupDocs::Storage::Document instance
|
63
|
+
document = file.to_document
|
64
|
+
|
65
|
+
# Create Hash with the options for job. :status=> -1 means the Draft status of the job
|
66
|
+
options = {:actions => [:convert, :number_lines], :out_formats => ['doc'], :name => 'sample'}
|
67
|
+
|
68
|
+
# Create Job with provided options with Draft status (Sheduled job)
|
69
|
+
job = GroupDocs::Job.create!(options)
|
70
|
+
|
71
|
+
# Add the documents to previously created Job
|
72
|
+
job.add_document!(document, {:check_ownership => false})
|
73
|
+
|
74
|
+
|
75
|
+
# Update the Job with new status. :status => '0' mean Active status of the job (Start the job)
|
76
|
+
id = job.update!({:status => 'pending'})
|
77
|
+
|
78
|
+
i = 1
|
79
|
+
|
80
|
+
while i<5 do
|
81
|
+
sleep(5)
|
82
|
+
job = GroupDocs::Job.get!(id[:job_id])
|
83
|
+
break if job.status == :archived
|
84
|
+
i = i + 1
|
85
|
+
end
|
86
|
+
|
87
|
+
# Get the document into Pdf format
|
88
|
+
file = job.documents!()
|
89
|
+
|
90
|
+
document = file[:inputs][0].outputs[0]
|
91
|
+
|
92
|
+
# Set iframe with document GUID or raise an error
|
93
|
+
if document
|
94
|
+
|
95
|
+
#Get url from request
|
96
|
+
case settings.base_path
|
97
|
+
|
98
|
+
when 'https://stage-api-groupdocs.dynabic.com'
|
99
|
+
url = "http://stage-apps-groupdocs.dynabic.com/document-viewer/embed/#{document.guid}"
|
100
|
+
when 'https://dev-api-groupdocs.dynabic.com'
|
101
|
+
url = "http://dev-apps-groupdocs.dynabic.com/document-viewer/embed/#{document.guid}"
|
102
|
+
else
|
103
|
+
url = "https://apps.groupdocs.com/document-viewer/embed/#{document.guid}"
|
104
|
+
end
|
105
|
+
|
106
|
+
# Add the signature in url
|
107
|
+
iframe = GroupDocs::Api::Request.new(:path => url).prepare_and_sign_url
|
108
|
+
iframe = "<iframe width='100%' height='600' frameborder='0' src='#{iframe}'></iframe>"
|
109
|
+
else
|
110
|
+
raise 'File was not converted'
|
111
|
+
end
|
112
|
+
rescue Exception => e
|
113
|
+
err = e.message
|
114
|
+
end
|
115
|
+
|
116
|
+
# Set variables for template
|
117
|
+
haml :sample41, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :err => err, :iframe => iframe}
|
118
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# GET request
|
2
|
+
get '/sample42' do
|
3
|
+
haml :sample42
|
4
|
+
end
|
5
|
+
|
6
|
+
# POST request
|
7
|
+
post '/sample42' do
|
8
|
+
# set variables
|
9
|
+
set :client_id, params[:clientId]
|
10
|
+
set :private_key, params[:privateKey]
|
11
|
+
set :file_id, params[:fileId]
|
12
|
+
set :base_path, params[:basePath]
|
13
|
+
|
14
|
+
begin
|
15
|
+
# Check required variables
|
16
|
+
raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty?
|
17
|
+
|
18
|
+
if settings.base_path.empty? then settings.base_path = 'https://api.groupdocs.com' end
|
19
|
+
|
20
|
+
# Configure your access to API server
|
21
|
+
GroupDocs.configure do |groupdocs|
|
22
|
+
groupdocs.client_id = settings.client_id
|
23
|
+
groupdocs.private_key = settings.private_key
|
24
|
+
# Optionally specify API server and version
|
25
|
+
groupdocs.api_server = settings.base_path # default is 'https://api.groupdocs.com'
|
26
|
+
end
|
27
|
+
|
28
|
+
document = GroupDocs::Storage::File.new(:guid => settings.file_id).to_document
|
29
|
+
|
30
|
+
# Check, has document the annotations?
|
31
|
+
raise 'Your document has no annotations' if document.annotations!.empty?
|
32
|
+
|
33
|
+
# Create Hash with the options for job. :status=> -1 means the Draft status of the job
|
34
|
+
options = {:actions => [:import_annotations], :name => 'sample'}
|
35
|
+
|
36
|
+
# Create Job with provided options with Draft status (Sheduled job)
|
37
|
+
job = GroupDocs::Job.create!(options)
|
38
|
+
|
39
|
+
# Add the documents to previously created Job
|
40
|
+
job.add_document!(document, {:check_ownership => false})
|
41
|
+
|
42
|
+
|
43
|
+
# Update the Job with new status. :status => '0' mean Active status of the job (Start the job)
|
44
|
+
id = job.update!({:status => '0'})
|
45
|
+
|
46
|
+
i = 1
|
47
|
+
|
48
|
+
while i<5 do
|
49
|
+
sleep(5)
|
50
|
+
job = GroupDocs::Job.get!(id[:job_id])
|
51
|
+
break if job.status == :archived
|
52
|
+
i = i + 1
|
53
|
+
end
|
54
|
+
|
55
|
+
# Get the document into Pdf format
|
56
|
+
file = job.documents!()
|
57
|
+
|
58
|
+
document = file[:inputs]
|
59
|
+
|
60
|
+
# Set iframe with document GUID or raise an error
|
61
|
+
if document
|
62
|
+
|
63
|
+
#Get url from request
|
64
|
+
case settings.base_path
|
65
|
+
|
66
|
+
when 'https://stage-api-groupdocs.dynabic.com'
|
67
|
+
url = "http://stage-apps-groupdocs.dynabic.com/document-annotation/embed/#{document[0].guid}"
|
68
|
+
when 'https://dev-api-groupdocs.dynabic.com'
|
69
|
+
url = "http://dev-apps-groupdocs.dynabic.com/document-annotation/embed/#{document[0].guid}"
|
70
|
+
else
|
71
|
+
url = "https://apps.groupdocs.com/document-annotation/embed/#{document[0].guid}"
|
72
|
+
end
|
73
|
+
|
74
|
+
# Add the signature in url
|
75
|
+
iframe = GroupDocs::Api::Request.new(:path => url).prepare_and_sign_url
|
76
|
+
iframe = "<iframe width='100%' height='600' frameborder='0' src='#{iframe}'></iframe>"
|
77
|
+
|
78
|
+
path = "#{File.dirname(__FILE__)}/../public/downloads"
|
79
|
+
# Remove all files from download directory or create folder if it not there
|
80
|
+
if File.directory?(path)
|
81
|
+
Dir.foreach(path) { |f| fn = File.join(downloads_path, f); File.delete(fn) if f != '.' && f != '..' }
|
82
|
+
else
|
83
|
+
Dir::mkdir(path)
|
84
|
+
end
|
85
|
+
|
86
|
+
GroupDocs::User.download!(path, document[0].outputs[0].name, document[0].outputs[0].guid)
|
87
|
+
message = "<span style=\"color:green\">File with annotations was downloaded to server's local folder. You can check them <a href=\"/downloads/#{document[0].outputs[0].name}\">here</a></span>"
|
88
|
+
else
|
89
|
+
raise 'File was not converted'
|
90
|
+
end
|
91
|
+
rescue Exception => e
|
92
|
+
err = e.message
|
93
|
+
end
|
94
|
+
|
95
|
+
# Set variables for template
|
96
|
+
haml :sample42, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :err => err, :iframe => iframe, :message => message}
|
97
|
+
end
|
@@ -2,23 +2,23 @@
|
|
2
2
|
Choose another one sample:
|
3
3
|
%ul
|
4
4
|
%li
|
5
|
-
%a{:href => '/
|
5
|
+
%a{:href => '/sample01'} Sample01 - How to login to GroupDocs using the API
|
6
6
|
%li
|
7
|
-
%a{:href => '/
|
7
|
+
%a{:href => '/sample02'} Sample02 - How to list files within GroupDocs Storage using the Storage API
|
8
8
|
%li
|
9
|
-
%a{:href => '/
|
9
|
+
%a{:href => '/sample03'} Sample03 - How to upload a file to GroupDocs using the Storage API
|
10
10
|
%li
|
11
|
-
%a{:href => '/
|
11
|
+
%a{:href => '/sample04'} Sample04 - How to download a file from GroupDocs Storage using the Storage API
|
12
12
|
%li
|
13
|
-
%a{:href => '/
|
13
|
+
%a{:href => '/sample05'} Sample05 - How to copy / move a file using the GroupDocs Storage API
|
14
14
|
%li
|
15
|
-
%a{:href => '/
|
15
|
+
%a{:href => '/sample06'} Sample06 - How to add a Signature to a document in GroupDocs Signature
|
16
16
|
%li
|
17
|
-
%a{:href => '/
|
17
|
+
%a{:href => '/sample07'} Sample07 - How to create a list of thumbnails for a document
|
18
18
|
%li
|
19
|
-
%a{:href => '/
|
19
|
+
%a{:href => '/sample08'} Sample08 - How to return a URL representing a single page of a Document
|
20
20
|
%li
|
21
|
-
%a{:href => '/
|
21
|
+
%a{:href => '/sample09'} Sample09 - How to generate an embedded Viewer URL for a Document
|
22
22
|
%li
|
23
23
|
%a{:href => '/sample10'} Sample10 - How to share a document to other users
|
24
24
|
%li
|
@@ -68,6 +68,20 @@
|
|
68
68
|
%li
|
69
69
|
%a{:href => '/sample33'} Sample33 - How to convert and merge/combine several HTML documents into one PDF Document
|
70
70
|
%li
|
71
|
-
%a{:href => '/
|
71
|
+
%a{:href => '/sample34'} Sample34 - How to create folder in the GroupDocs account
|
72
72
|
%li
|
73
|
-
%a{:href => '/
|
73
|
+
%a{:href => '/sample35'} Sample35 - How to get fields and their data from PDF file
|
74
|
+
%li
|
75
|
+
%a{:href => '/sample36'} Sample36 - How to download signed documents when envelope was signed using Ruby SDK
|
76
|
+
%li
|
77
|
+
%a{:href => '/sample37'} Sample37 - How to create envelop and download signed document when envelop was signed using callback
|
78
|
+
%li
|
79
|
+
%a{:href => '/sample38'} Sample38 - How to create new user and add him as collaborator to doc with annotations
|
80
|
+
%li
|
81
|
+
%a{:href => '/sample39'} Sample39 - How to add a Signature to a document and redirect after signing with GroupDocs widget
|
82
|
+
%li
|
83
|
+
%a{:href => '/sample40'} Sample40 - How to set callback for signature form and re-direct when it was signed
|
84
|
+
%li
|
85
|
+
%a{:href => '/sample41'} Sample41 - How to add numeration in the doc file using GroupDocs Ruby SDK
|
86
|
+
%li
|
87
|
+
%a{:href => '/sample42'} Sample42 - How to download document with annotations using GroupDocs Ruby SDK
|
@@ -2,23 +2,23 @@
|
|
2
2
|
%div{:style => 'padding:10px;'}
|
3
3
|
%ul
|
4
4
|
%li
|
5
|
-
%a{:href => '/
|
5
|
+
%a{:href => '/sample01'} Sample01 - How to login to GroupDocs using the API
|
6
6
|
%li
|
7
|
-
%a{:href => '/
|
7
|
+
%a{:href => '/sample02'} Sample02 - How to list files within GroupDocs Storage using the Storage API
|
8
8
|
%li
|
9
|
-
%a{:href => '/
|
9
|
+
%a{:href => '/sample03'} Sample03 - How to upload a file to GroupDocs using the Storage API
|
10
10
|
%li
|
11
|
-
%a{:href => '/
|
11
|
+
%a{:href => '/sample04'} Sample04 - How to download a file from GroupDocs Storage using the Storage API
|
12
12
|
%li
|
13
|
-
%a{:href => '/
|
13
|
+
%a{:href => '/sample05'} Sample05 - How to copy / move a file using the GroupDocs Storage API
|
14
14
|
%li
|
15
|
-
%a{:href => '/
|
15
|
+
%a{:href => '/sample06'} Sample06 - How to add a Signature to a document in GroupDocs Signature
|
16
16
|
%li
|
17
|
-
%a{:href => '/
|
17
|
+
%a{:href => '/sample07'} Sample07 - How to create a list of thumbnails for a document
|
18
18
|
%li
|
19
|
-
%a{:href => '/
|
19
|
+
%a{:href => '/sample08'} Sample08 - How to return a URL representing a single page of a Document
|
20
20
|
%li
|
21
|
-
%a{:href => '/
|
21
|
+
%a{:href => '/sample09'} Sample09 - How to generate an embedded Viewer URL for a Document
|
22
22
|
%li
|
23
23
|
%a{:href => '/sample10'} Sample10 - How to share a document to other users
|
24
24
|
%li
|
@@ -68,6 +68,18 @@
|
|
68
68
|
%li
|
69
69
|
%a{:href => '/sample33'} Sample33 - How to convert and merge/combine several HTML documents into one PDF Document
|
70
70
|
%li
|
71
|
-
%a{:href => '/
|
71
|
+
%a{:href => '/sample34'} Sample34 - How to create folder in the GroupDocs account
|
72
72
|
%li
|
73
|
-
%a{:href => '/
|
73
|
+
%a{:href => '/sample35'} Sample35 - How to get fields and their data from PDF file
|
74
|
+
%li
|
75
|
+
%a{:href => '/sample36'} Sample36 - How to download signed documents when envelope was signed using Ruby SDK
|
76
|
+
%li
|
77
|
+
%a{:href => '/sample37'} Sample37 - How to create envelop and download signed document when envelop was signed using callback
|
78
|
+
%li
|
79
|
+
%a{:href => '/sample38'} Sample38 - How to create new user and add him as collaborator to doc with annotations
|
80
|
+
%li
|
81
|
+
%a{:href => '/sample39'} Sample39 - How to add a Signature to a document and re-direct after signing with GroupDocs widget
|
82
|
+
%li
|
83
|
+
%a{:href => '/sample41'} Sample41 - How to add numeration in the doc file using GroupDocs Ruby SDK
|
84
|
+
%li
|
85
|
+
%a{:href => '/sample42'} Sample42 - How to download document with annotations using GroupDocs Ruby SDK
|