class Aspose::Cloud::Pdf::AnnotationEditor

Public Class Methods

new(filename) click to toggle source
# File lib/Pdf/annotation_editor.rb, line 6
def initialize filename
  @filename = filename
end

Public Instance Methods

download_attachment(attachment_index) click to toggle source

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

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

Gets list of all the attachments in pdf

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

Gets list of all the bookmarks in pdf

# 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
get_annotation(page_number, annotation_index) 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 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) click to toggle source

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

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

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

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

Gets total number of Attachments in a Pdf document

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

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

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

Gets total number of Bookmarks in a Pdf document

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

Gets number of child bookmarks in a specfied parent bookmark

@param number parent

# 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
is_child_bookmark(bookmark_index) 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 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