class Aspose::Cloud::Pdf::AnnotationEditor

Public Class Methods

new(filename) click to toggle source
# 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

Public Instance Methods

download_attachment(attachment_index, folder_name='', storage_type = 'Aspose', storage_name = '') click to toggle source

Download a specfied Attachment from a PDF document @param number attachment_index

# 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 = '') click to toggle source

Gets list of all the annotations on a specified document page

@param number page_number

# 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 = '') click to toggle source

Gets list of all the attachments in pdf

# 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 = '') click to toggle source

Gets list of all the bookmarks in pdf

# 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
get_annotation(page_number, annotation_index, folder_name='', storage_type = 'Aspose', storage_name = '') click to toggle source

Gets a specfied annotation on a specified document page

@param number page_number @param number annotation_index

# 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 = '') click to toggle source

Gets number of annotations on a specified document page @param number page_number

# 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 = '') click to toggle source

Gets a specfied Attachment from a PDF document @param number attachment_index

# 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 = '') click to toggle source

Gets total number of Attachments in a Pdf document

# 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 = '') click to toggle source

Gets a specfied Bookmark from a PDF document @param number bookmark_index

# 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 = '') click to toggle source

Gets total number of Bookmarks in a Pdf document

# 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 = '') click to toggle source

Gets a specfied Child Bookmark from a PDF document @param number parent_index @param number child_index

# 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 = '') click to toggle source

Gets number of child bookmarks in a specfied parent bookmark

@param number parent

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

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

@param number bookmark_index

# 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