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.



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

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


165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/Pdf/annotation_editor.rb', line 165

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


44
45
46
47
48
49
50
51
52
53
# File 'lib/Pdf/annotation_editor.rb', line 44

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



152
153
154
155
156
157
158
159
# File 'lib/Pdf/annotation_editor.rb', line 152

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



115
116
117
118
119
120
121
122
# File 'lib/Pdf/annotation_editor.rb', line 115

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


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

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


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

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


14
15
16
17
18
19
20
21
22
# File 'lib/Pdf/annotation_editor.rb', line 14

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


139
140
141
142
143
144
145
146
147
# File 'lib/Pdf/annotation_editor.rb', line 139

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



127
128
129
130
131
132
133
# File 'lib/Pdf/annotation_editor.rb', line 127

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


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

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



58
59
60
61
62
63
64
# File 'lib/Pdf/annotation_editor.rb', line 58

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


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

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


71
72
73
74
75
76
77
78
79
# File 'lib/Pdf/annotation_editor.rb', line 71

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


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

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


189
190
191
192
193
194
195
196
197
# File 'lib/Pdf/annotation_editor.rb', line 189

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


234
235
236
237
238
239
240
241
242
# File 'lib/Pdf/annotation_editor.rb', line 234

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