require 'aspose_pdf_cloud'
include AsposePdfCloud

app_key = 'XXXXX'
app_sid = 'XXXXX'
@pdf_api = PdfApi.new(app_key, app_sid)
file_name = 'PdfWithAnnotations.pdf'
# Upload the File
@pdf_api.put_create(file_name, :: File.open('example_data/' + file_name, 'r') { |io| io.read(io.size) })
puts 'Uploaded the File'
opts = {
  folder: @temp_folder
}

text_style = TextStyle.new
text_style.font_size = 12
text_style.font = 'Arial'
text_style.foreground_color = Color.new(A: 0xFF, R: 0, G: 0xFF, B: 0)
text_style.background_color = Color.new(A: 0xFF, R: 0xFF, G: 0, B: 0)

annotation = FreeTextAnnotation.new
annotation.name = 'Test Free Text'
annotation.text_style = text_style
annotation.rect = Rectangle.new(LLX: 100, LLY: 100, URX: 200, URY: 200)
annotation.flags = [AnnotationFlags::DEFAULT]
annotation.horizontal_alignment = HorizontalAlignment::CENTER
annotation.intent = FreeTextIntent::FREE_TEXT_TYPE_WRITER
annotation.rich_text = 'Rich Text'
annotation.subject = 'Text Box Subj'
annotation.z_index = 1
annotation.justification = Justification::CENTER
annotation.title = 'Title'

annotations_response = @pdf_api.get_document_free_text_annotations(file_name, opts)
annotation_id = annotations_response[0].annotations.list[0].id

response = @pdf_api.put_free_text_annotation(file_name, annotation_id, annotation, opts)
puts response
