Class: Aspose::Cloud::Pdf::AnnotationEditor

Inherits:
Object
  • Object
show all
Defined in:
lib/Pdf/annotation_editor.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ AnnotationEditor

Returns a new instance of AnnotationEditor.



6
7
8
# File 'lib/Pdf/annotation_editor.rb', line 6

def initialize filename
  @filename = filename
end

Instance Method Details

#download_attachment(attachment_index) ⇒ Object

Download a specfied Attachment from a PDF document

@param number attachment_index


362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
# File 'lib/Pdf/annotation_editor.rb', line 362

def download_attachment attachment_index
  begin

    if @filename == ''
      raise 'filename not specified'
    end

    if attachment_index == ''
      raise 'attachment index not specified'
    end
        
    file_info = self.get_attachment(attachment_index)


    str_uri = $product_uri + '/pdf/' + @filename + '/attachments/' + attachment_index.to_s + '/download'
    str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)        
    response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})

    valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)

    if valid_output == ''                   
      output_path = $out_put_location + file_info['Name'];
      Aspose::Cloud::Common::Utils.saveFile(response_stream,output_path)
      return ''
    else
      return valid_output
    end


  rescue Exception=>e
    print e
  end
end

#get_all_annotation(page_number) ⇒ Object

Gets list of all the annotations on a specified document page

@param number page_number


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/Pdf/annotation_editor.rb', line 80

def get_all_annotation page_number
  begin

    if @filename == ''
      raise 'filename not specified'
    end

    if page_number == ''
      raise 'page number not specified'
    end
        
    total_annotations = self.get_annotations_count(page_number)

    all_annotations = Array.new

    index = 1
    while index <= total_annotations
  
      all_annotations.push(self.get_annotation(page_number, index))
  
      index+=1
    end

    return all_annotations


  rescue Exception=>e
    print e
  end
end

#get_all_attachmentsObject

Gets list of all the attachments in pdf



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/Pdf/annotation_editor.rb', line 329

def get_all_attachments
  begin

    if @filename == ''
      raise 'filename not specified'
    end
        
        
    total_attachments = self.get_attachments_count

    all_attachments = Array.new

    index = 1
    while index <= total_attachments
  
      all_annotations.push(self.get_attachment(index))
  
      index+=1
    end

    return all_attachments


  rescue Exception=>e
    print e
  end
end

#get_all_bookmarksObject

Gets list of all the bookmarks in pdf



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/Pdf/annotation_editor.rb', line 239

def get_all_bookmarks
  begin

    if @filename == ''
      raise 'filename not specified'
    end
        
        
    total_bookmarks = self.get_bookmarks_count

    all_bookmarks = Array.new

    index = 1
    while index <= total_bookmarks
  
      all_annotations.push(self.get_bookmark(index))
  
      index+=1
    end

    return all_bookmarks


  rescue Exception=>e
    print e
  end
end

Gets list of all the links on a specified document page

@param number page_number


467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
# File 'lib/Pdf/annotation_editor.rb', line 467

def get_all_links page_number
  begin

    if @filename == ''
      raise 'filename not specified'
    end

    if page_number == ''
      raise 'page number not specified'
    end
        
    total_links = self.get_links_count(page_number)

    all_links = Array.new

    index = 1
    while index <= total_links
  
      all_annotations.push(self.get_link(page_number, index))
  
      index+=1
    end

    return all_links


  rescue Exception=>e
    print e
  end
end

#get_annotation(page_number, annotation_index) ⇒ Object

Gets a specfied annotation on a specified document page

@param number page_number
@param number annotation_index


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/Pdf/annotation_editor.rb', line 46

def get_annotation page_number, annotation_index
  begin

    if @filename == ''
      raise 'filename not specified'
    end

    if page_number == ''
      raise 'page number not specified'
    end

    if annotation_index == ''
      raise 'annotation index not specified'
    end

    str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/annotations/' + annotation_index.to_s
    str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)        
    response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})

    stream_hash = JSON.parse(response_stream)

    return stream_hash['Annotation']


  rescue Exception=>e
    print e
  end
end

#get_annotations_count(page_number) ⇒ Object

Gets number of annotations on a specified document page

@param number page_number


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/Pdf/annotation_editor.rb', line 15

def get_annotations_count page_number
  begin

    if @filename == ''
      raise 'filename not specified'
    end

    if page_number == ''
      raise 'page number not specified'
    end

    str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/annotations'
    str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)        
    response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})

    stream_hash = JSON.parse(response_stream)

    return stream_hash['Annotations']['List'].length


  rescue Exception=>e
    print e
  end
end

#get_attachment(attachment_index) ⇒ Object

Gets a specfied Attachment from a PDF document

@param number attachment_index


299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/Pdf/annotation_editor.rb', line 299

def get_attachment attachment_index
  begin

    if @filename == ''
      raise 'filename not specified'
    end

    if attachment_index == ''
      raise 'attachment index not specified'
    end
        

    str_uri = $product_uri + '/pdf/' + @filename + '/attachments/' + attachment_index.to_s
    str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)        
    response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})

    stream_hash = JSON.parse(response_stream)

    return stream_hash['Attachment']


  rescue Exception=>e
    print e
  end
end

#get_attachments_countObject

Gets total number of Attachments in a Pdf document



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/Pdf/annotation_editor.rb', line 271

def get_attachments_count
  begin

    if @filename == ''
      raise 'filename not specified'
    end
        

    str_uri = $product_uri + '/pdf/' + @filename + '/attachments'
    str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)        

    response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})

    stream_hash = JSON.parse(response_stream)

    return stream_hash['Attachments']['List'].length


  rescue Exception=>e
    print e
  end
end

#get_bookmark(bookmark_index) ⇒ Object

Gets a specfied Bookmark from a PDF document

@param number bookmark_index


173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/Pdf/annotation_editor.rb', line 173

def get_bookmark bookmark_index
  begin

    if @filename == ''
      raise 'filename not specified'
    end

    if bookmark_index == ''
      raise 'bookmark index not specified'
    end
        

    str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s
    str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)        
    response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})

    stream_hash = JSON.parse(response_stream)

    return stream_hash['Bookmark']


  rescue Exception=>e
    print e
  end
end

#get_bookmarks_countObject

Gets total number of Bookmarks in a Pdf document



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/Pdf/annotation_editor.rb', line 115

def get_bookmarks_count
  begin

    if @filename == ''
      raise 'filename not specified'
    end
        

    str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks'
    str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)  
    response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})

    stream_hash = JSON.parse(response_stream)

    return stream_hash['Bookmarks']['List'].length


  rescue Exception=>e
    print e
  end
end

#get_child_bookmark(parent_index, child_index) ⇒ Object

Gets a specfied Child Bookmark from a PDF document

@param number parent_index
@param number child_index


205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/Pdf/annotation_editor.rb', line 205

def get_child_bookmark parent_index, child_index
  begin

    if @filename == ''
      raise 'filename not specified'
    end

    if parent_index == ''
      raise 'parent index not specified'
    end

    if child_index == ''
      raise 'child index not specified'
    end
        

    str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + parent_index.to_s + '/bookmarks/' + child_index.to_s
    str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)        
    response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})

    stream_hash = JSON.parse(response_stream)

    return stream_hash['Bookmark']


  rescue Exception=>e
    print e
  end
end

#get_child_bookmarks_count(parent) ⇒ Object

Gets number of child bookmarks in a specfied parent bookmark

@param number parent


142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/Pdf/annotation_editor.rb', line 142

def get_child_bookmarks_count parent
  begin

    if @filename == ''
      raise 'filename not specified'
    end

    if parent == ''
      raise 'parent not specified'
    end
        

    str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + parent.to_s + '/bookmarks'
    str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)        
    response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})

    stream_hash = JSON.parse(response_stream)

    return stream_hash['Bookmarks']['List'].length


  rescue Exception=>e
    print e
  end
end

Gets a specfied link on a specified document page

@param number page_number
@param number annotation_index


433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# File 'lib/Pdf/annotation_editor.rb', line 433

def get_link page_number, link_index
  begin

    if @filename == ''
      raise 'filename not specified'
    end

    if page_number == ''
      raise 'page number not specified'
    end

    if link_index == ''
      raise 'link index not specified'
    end

    str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/links/' + link_index.to_s
    str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)        
    response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})

    stream_hash = JSON.parse(response_stream)

    return stream_hash['Link']


  rescue Exception=>e
    print e
  end
end

Gets total number of Links in a Pdf document

@param number page_number


401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/Pdf/annotation_editor.rb', line 401

def get_links_count page_number
  begin

    if @filename == ''
      raise 'filename not specified'
    end

    if page_number == ''
      raise 'page number not specified'
    end
        

    str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/links'
    str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)        
    response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})

    stream_hash = JSON.parse(response_stream)

    return stream_hash['Links']['List'].length


  rescue Exception=>e
    print e
  end
end

#is_child_bookmark(bookmark_index) ⇒ Object

Checks whether selected bookmark is parent or child Gets a specfied child Bookmark for selected parent bookmark in Pdf document

@param number bookmark_index


503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
# File 'lib/Pdf/annotation_editor.rb', line 503

def is_child_bookmark bookmark_index
  begin

    if @filename == ''
      raise 'filename not specified'
    end

    if bookmark_index == ''
      raise 'bookmark index not specified'
    end
        

    str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks/' + bookmark_index.to_s
    str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)        
    response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})

    stream_hash = JSON.parse(response_stream)

    return stream_hash['Bookmark']


  rescue Exception=>e
    print e
  end
end