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.



22
23
24
25
26
# File 'lib/Pdf/annotation_editor.rb', line 22

def initialize(filename)
  @filename = filename
  raise 'filename not specified.' if filename.empty?
  @base_uri =  Aspose::Cloud::Common::Product.product_uri + '/pdf/' + @filename
end

Instance Method Details

#download_attachment(attachment_index, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Download a specfied Attachment from a PDF document

@param number attachment_index


182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/Pdf/annotation_editor.rb', line 182

def download_attachment(attachment_index, folder_name='', storage_type = 'Aspose', storage_name = '')
  raise 'attachment_index not specified.' if attachment_index.nil?
  attachment = self.get_attachment(attachment_index,folder_name,storage_type,storage_name)

  str_uri = "#{@base_uri}/attachments/#{attachment_index}/download"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)

  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  response_stream = RestClient.get(signed_str_uri, {:accept=>'application/json'})

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

  if valid_output.empty?
    output_path = "#{Aspose::Cloud::Common::AsposeApp.output_location}#{attachment['Name']}"
    Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)
  end
  valid_output
end

#get_all_annotation(page_number, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Gets list of all the annotations on a specified document page

@param number page_number


61
62
63
64
65
66
67
68
69
70
# File 'lib/Pdf/annotation_editor.rb', line 61

def get_all_annotation(page_number, folder_name='', storage_type = 'Aspose', storage_name = '')
  raise 'page_number not specified.' if page_number.nil?

  annotations = Array.new
  total_annotations = self.get_annotations_count(page_number,folder_name,storage_type,storage_name)
  total_annotations.times do |i|
    annotations.push(self.get_annotation(page_number,i+1,folder_name,storage_type,storage_name))
  end
  annotations
end

#get_all_attachments(folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Gets list of all the attachments in pdf



169
170
171
172
173
174
175
176
# File 'lib/Pdf/annotation_editor.rb', line 169

def get_all_attachments(folder_name='', storage_type = 'Aspose', storage_name = '')
  attachments = Array.new
  total_attachments = self.get_attachments_count(folder_name,storage_type,storage_name)
  total_attachments.times do |i|
    attachments.push(self.get_attachment(i+1,folder_name,storage_type,storage_name))
  end
  attachments
end

#get_all_bookmarks(folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Gets list of all the bookmarks in pdf



132
133
134
135
136
137
138
139
# File 'lib/Pdf/annotation_editor.rb', line 132

def get_all_bookmarks(folder_name='', storage_type = 'Aspose', storage_name = '')
  bookmarks = Array.new
  total_bookmarks = self.get_bookmarks_count(folder_name,storage_type,storage_name)
  total_bookmarks.times do |i|
    bookmarks.push(self.get_bookmark(i+1,folder_name,storage_type,storage_name))
  end
  bookmarks
end

Gets list of all the links on a specified document page

@param number page_number


236
237
238
239
240
241
242
243
244
245
# File 'lib/Pdf/annotation_editor.rb', line 236

def get_all_links(page_number, folder_name='', storage_type = 'Aspose', storage_name = '')
  raise 'page_number not specified.' if page_number.nil?

  links = Array.new
  total_links = self.get_links_count(page_number,folder_name,storage_type,storage_name)
  total_links.times do |i|
    links.push(self.get_link(page_number,i+1,folder_name,storage_type,storage_name))
  end
  links
end

#get_annotation(page_number, annotation_index, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ 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
# File 'lib/Pdf/annotation_editor.rb', line 46

def get_annotation(page_number, annotation_index, folder_name='', storage_type = 'Aspose', storage_name = '')
  raise 'page_number not specified.' if page_number.nil?
  raise 'annotation_index not specified.' if annotation_index.nil?

  str_uri = "#{@base_uri}/pages/#{page_number}/annotations/#{annotation_index}"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)

  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Annotation']
end

#get_annotations_count(page_number, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Gets number of annotations on a specified document page

@param number page_number


31
32
33
34
35
36
37
38
39
# File 'lib/Pdf/annotation_editor.rb', line 31

def get_annotations_count(page_number, folder_name='', storage_type = 'Aspose', storage_name = '')
  raise 'page_number not specified.' if page_number.nil?

  str_uri = "#{@base_uri}/pages/#{page_number}/annotations"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)

  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Annotations']['List'].length
end

#get_attachment(attachment_index, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Gets a specfied Attachment from a PDF document

@param number attachment_index


156
157
158
159
160
161
162
163
164
# File 'lib/Pdf/annotation_editor.rb', line 156

def get_attachment(attachment_index, folder_name='', storage_type = 'Aspose', storage_name = '')
  raise 'attachment_index not specified.' if attachment_index.nil?

  str_uri = "#{@base_uri}/attachments/#{attachment_index}"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)

  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Attachment']
end

#get_attachments_count(folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Gets total number of Attachments in a Pdf document



144
145
146
147
148
149
150
# File 'lib/Pdf/annotation_editor.rb', line 144

def get_attachments_count(folder_name='', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{@base_uri}/attachments"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)

  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Attachments']['List'].length
end

#get_bookmark(bookmark_index, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Gets a specfied Bookmark from a PDF document

@param number bookmark_index


103
104
105
106
107
108
109
110
111
# File 'lib/Pdf/annotation_editor.rb', line 103

def get_bookmark(bookmark_index, folder_name='', storage_type = 'Aspose', storage_name = '')
  raise 'bookmark_index not specified.' if bookmark_index.nil?

  str_uri = "#{@base_uri}/bookmarks/#{bookmark_index}"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)

  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Bookmark']
end

#get_bookmarks_count(folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Gets total number of Bookmarks in a Pdf document



75
76
77
78
79
80
81
# File 'lib/Pdf/annotation_editor.rb', line 75

def get_bookmarks_count(folder_name='', storage_type = 'Aspose', storage_name = '')
  str_uri = "#{@base_uri}/bookmarks"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)

  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Bookmarks']['List'].length
end

#get_child_bookmark(parent_index, child_index, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Gets a specfied Child Bookmark from a PDF document

@param number parent_index
@param number child_index


118
119
120
121
122
123
124
125
126
127
# File 'lib/Pdf/annotation_editor.rb', line 118

def get_child_bookmark(parent_index, child_index, folder_name='', storage_type = 'Aspose', storage_name = '')
  raise 'parent_index not specified.' if parent_index.nil?
  raise 'child_index not specified.' if child_index.nil?

  str_uri = "#{@base_uri}/bookmarks/#{parent_index}/bookmarks/#{child_index}"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)

  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Bookmark']
end

#get_child_bookmarks_count(parent, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ Object

Gets number of child bookmarks in a specfied parent bookmark

@param number parent


88
89
90
91
92
93
94
95
96
# File 'lib/Pdf/annotation_editor.rb', line 88

def get_child_bookmarks_count(parent, folder_name='', storage_type = 'Aspose', storage_name = '')
  raise 'parent not specified.' if parent.nil?

  str_uri = "#{@base_uri}/bookmarks/#{parent}/bookmarks"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)

  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Bookmarks']['List'].length
end

Gets a specfied link on a specified document page

@param number page_number
@param number annotation_index


221
222
223
224
225
226
227
228
229
230
# File 'lib/Pdf/annotation_editor.rb', line 221

def get_link(page_number, link_index, folder_name='', storage_type = 'Aspose', storage_name = '')
  raise 'page_number not specified.' if page_number.nil?
  raise 'link_index not specified.' if link_index.nil?

  str_uri = "#{@base_uri}/pages/#{page_number}/links/#{link_index}"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)

  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Link']
end

Gets total number of Links in a Pdf document

@param number page_number


206
207
208
209
210
211
212
213
214
# File 'lib/Pdf/annotation_editor.rb', line 206

def get_links_count(page_number, folder_name='', storage_type = 'Aspose', storage_name = '')
  raise 'page_number not specified.' if page_number.nil?

  str_uri = "#{@base_uri}/pages/#{page_number}/links"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)

  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Links']['List'].length
end

#is_child_bookmark(bookmark_index, folder_name = '', storage_type = 'Aspose', storage_name = '') ⇒ 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


251
252
253
254
255
256
257
258
259
# File 'lib/Pdf/annotation_editor.rb', line 251

def is_child_bookmark(bookmark_index, folder_name='', storage_type = 'Aspose', storage_name = '')
  raise 'bookmark_index not specified.' if bookmark_index.nil?

  str_uri = "#{@base_uri}/bookmarks/#{bookmark_index}"
  str_uri = Aspose::Cloud::Common::Utils.append_storage(str_uri,folder_name,storage_name,storage_type)

  signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  JSON.parse(RestClient.get(signed_str_uri, {:accept=>'application/json'}))['Bookmark']
end