asposecloud 1.0.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +31 -9
- data/Tests/Barcode/builder_tests.rb +95 -0
- data/Tests/Barcode/reader_tests.rb +70 -0
- data/Tests/Cells/charteditor_tests.rb +139 -0
- data/Tests/Cells/converter_tests.rb +83 -0
- data/Tests/Cells/extractor_tests.rb +40 -0
- data/Tests/Cells/texteditor_tests.rb +52 -0
- data/Tests/Cells/workbook_tests.rb +167 -0
- data/Tests/Cells/worksheet_tests.rb +435 -0
- data/Tests/Data/barcodeQR.bmp +0 -0
- data/Tests/Data/barcodeQR.jpg +0 -0
- data/Tests/Data/barcodeQR.tiff +0 -0
- data/Tests/Data/bizcard.psd +0 -0
- data/Tests/Data/macbook.gif +0 -0
- data/Tests/Data/mail_merge_regions.docx +0 -0
- data/Tests/Data/mail_merge_template.docx +0 -0
- data/Tests/Data/test_cells.xlsx +0 -0
- data/Tests/Data/test_multi_pages.docx +0 -0
- data/Tests/Data/test_slides.pptx +0 -0
- data/Tests/Email/converter_tests.rb +30 -0
- data/Tests/Email/document_tests.rb +55 -0
- data/Tests/Imaging/converter_tests.rb +32 -0
- data/Tests/Imaging/document_tests.rb +132 -0
- data/Tests/Imaging/extractor_tests.rb +67 -0
- data/Tests/Imaging/image_tests.rb +55 -0
- data/Tests/Ocr/extractor_tests.rb +34 -0
- data/Tests/Pdf/annotationeditor_tests.rb +128 -0
- data/Tests/Pdf/converter_tests.rb +74 -0
- data/Tests/Pdf/document_tests.rb +285 -0
- data/Tests/Pdf/extractor_tests.rb +37 -0
- data/Tests/Pdf/texteditor_tests.rb +84 -0
- data/Tests/Slides/converter_tests.rb +59 -0
- data/Tests/Slides/document_tests.rb +187 -0
- data/Tests/Slides/extractor_tests.rb +92 -0
- data/Tests/Storage/folder_tests.rb +64 -0
- data/Tests/Tasks/assignments_tests.rb +44 -0
- data/Tests/Tasks/calendar_tests.rb +45 -0
- data/Tests/Tasks/converter_tests.rb +32 -0
- data/Tests/Tasks/document_tests.rb +114 -0
- data/Tests/Tasks/resources_tests.rb +44 -0
- data/Tests/Words/builder_tests.rb +56 -0
- data/Tests/Words/converter_tests.rb +54 -0
- data/Tests/Words/document_tests.rb +208 -0
- data/Tests/Words/extractor_tests.rb +120 -0
- data/Tests/Words/mail_merge_tests.rb +120 -0
- data/Tests/setup.json +6 -0
- data/lib/Barcode/builder.rb +270 -20
- data/lib/Barcode/reader.rb +112 -18
- data/lib/Cells/chart_editor.rb +102 -0
- data/lib/Cells/convertor.rb +22 -2
- data/lib/Cells/text_editor.rb +8 -2
- data/lib/Cells/workbook.rb +63 -3
- data/lib/Cells/worksheet.rb +479 -10
- data/lib/Common/utils.rb +2 -0
- data/lib/Email/converter.rb +2 -18
- data/lib/Email/document.rb +32 -17
- data/lib/Ocr/extractor.rb +26 -20
- data/lib/Pdf/annotation_editor.rb +0 -17
- data/lib/Pdf/converter.rb +25 -17
- data/lib/Pdf/document.rb +167 -23
- data/lib/Pdf/extractor.rb +0 -17
- data/lib/Pdf/text_editor.rb +35 -20
- data/lib/Slides/converter.rb +48 -18
- data/lib/Slides/document.rb +186 -51
- data/lib/Slides/extractor.rb +35 -18
- data/lib/Storage/folder.rb +30 -25
- data/lib/Words/builder.rb +23 -29
- data/lib/Words/converter.rb +30 -17
- data/lib/Words/document.rb +336 -28
- data/lib/Words/extractor.rb +112 -33
- data/lib/Words/mail_merge.rb +2 -20
- data/{Tests/word_tests.rb → lib/aspose_imaging.rb} +5 -17
- data/lib/asposecloud.rb +3 -1
- data/lib/asposecloud/version.rb +1 -1
- data/lib/imaging/converter.rb +55 -0
- data/lib/imaging/document.rb +301 -0
- data/lib/imaging/extractor.rb +165 -0
- data/lib/imaging/image.rb +118 -0
- data/lib/restclient.rb +36 -0
- data/lib/tasks/assignments.rb +19 -19
- data/lib/tasks/calendar.rb +27 -19
- data/lib/tasks/converter.rb +4 -17
- data/lib/tasks/document.rb +79 -22
- data/lib/tasks/resources.rb +18 -18
- metadata +70 -19
- checksums.yaml +0 -7
- data/Tests/barcode_tests.rb +0 -45
- data/Tests/cell_tests.rb +0 -41
- data/Tests/email_tests.rb +0 -43
- data/Tests/pdf_tests.rb +0 -76
- data/Tests/slide_tests.rb +0 -41
- data/Tests/storage_tests.rb +0 -86
- data/Tests/tasks_tests.rb +0 -24
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require_relative '../../lib/asposecloud'
|
4
|
+
|
5
|
+
class CalendarTests < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
file = File.read('../setup.json')
|
9
|
+
data = JSON.parse(file)
|
10
|
+
|
11
|
+
Aspose::Cloud::Common::AsposeApp.app_key = data['app_key']
|
12
|
+
Aspose::Cloud::Common::AsposeApp.app_sid = data['app_sid']
|
13
|
+
Aspose::Cloud::Common::AsposeApp.output_location = data['output_location']
|
14
|
+
Aspose::Cloud::Common::Product.set_base_product_uri(data['product_uri'])
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get all Calendars from Project
|
18
|
+
def test_get_calendars
|
19
|
+
calendar = Aspose::Cloud::Tasks::Calendar.new('test_tasks.mpp')
|
20
|
+
response = calendar.get_calendars()
|
21
|
+
assert_instance_of(Array, response)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Get a particular Calendar from Project
|
25
|
+
def test_get_calendar
|
26
|
+
calendar = Aspose::Cloud::Tasks::Calendar.new('test_tasks.mpp')
|
27
|
+
response = calendar.get_calendar(calendar_id=5)
|
28
|
+
assert_instance_of(Hash, response)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Add a Calendar to Project
|
32
|
+
def test_add_calendar
|
33
|
+
json_data = '{"Name":"ADDED CALENDAR","Uid":0,"Days":[{"DayType":1,"DayWorking":false,"FromDate":"0001-01-01T00:00:00","ToDate":"0001-01-01T00:00:00","WorkingTimes":[]},{"DayType":2,"DayWorking":true,"FromDate":"0001-01-01T00:00:00","ToDate":"0001-01-01T00:00:00","WorkingTimes":[{"FromTime":"2010-01-01T09:00:00","ToTime":"2010-01-01T12:00:00"},{"FromTime":"2010-01-01T13:00:00","ToTime":"2010-01-01T18:00:00"}]},{"DayType":3,"DayWorking":true,"FromDate":"0001-01-01T00:00:00","ToDate":"0001-01-01T00:00:00","WorkingTimes":[{"FromTime":"2010-01-01T09:00:00","ToTime":"2010-01-01T12:00:00"},{"FromTime":"2010-01-01T13:00:00","ToTime":"2010-01-01T18:00:00"}]},{"DayType":4,"DayWorking":true,"FromDate":"0001-01-01T00:00:00","ToDate":"0001-01-01T00:00:00","WorkingTimes":[{"FromTime":"2010-01-01T09:00:00","ToTime":"2010-01-01T12:00:00"},{"FromTime":"2010-01-01T13:00:00","ToTime":"2010-01-01T18:00:00"}]},{"DayType":5,"DayWorking":true,"FromDate":"0001-01-01T00:00:00","ToDate":"0001-01-01T00:00:00","WorkingTimes":[{"FromTime":"2010-01-01T09:00:00","ToTime":"2010-01-01T12:00:00"},{"FromTime":"2010-01-01T13:00:00","ToTime":"2010-01-01T18:00:00"}]},{"DayType":6,"DayWorking":true,"FromDate":"0001-01-01T00:00:00","ToDate":"0001-01-01T00:00:00","WorkingTimes":[{"FromTime":"2010-01-01T09:00:00","ToTime":"2010-01-01T12:00:00"},{"FromTime":"2010-01-01T13:00:00","ToTime":"2010-01-01T18:00:00"}]},{"DayType":7,"DayWorking":true,"FromDate":"0001-01-01T00:00:00","ToDate":"0001-01-01T00:00:00","WorkingTimes":[{"FromTime":"2010-01-01T09:00:00","ToTime":"2010-01-01T13:00:00"}]}],"Exceptions":[],"IsBaseCalendar":true,"BaseCalendar":null,"IsBaselineCalendar":false}'
|
34
|
+
calendar = Aspose::Cloud::Tasks::Calendar.new('test_tasks.mpp')
|
35
|
+
response = calendar.add_calendar(json_data)
|
36
|
+
assert_instance_of(Hash, response)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Delete a Calendar from Project
|
40
|
+
def test_delete_calendar
|
41
|
+
calendar = Aspose::Cloud::Tasks::Calendar.new('test_tasks.mpp')
|
42
|
+
response = calendar.delete_calendar(calendar_id=5)
|
43
|
+
assert_equal true, response
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require_relative '../../lib/asposecloud'
|
4
|
+
|
5
|
+
class ConverterTests < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
file = File.read('../setup.json')
|
9
|
+
data = JSON.parse(file)
|
10
|
+
|
11
|
+
Aspose::Cloud::Common::AsposeApp.app_key = data['app_key']
|
12
|
+
Aspose::Cloud::Common::AsposeApp.app_sid = data['app_sid']
|
13
|
+
Aspose::Cloud::Common::AsposeApp.output_location = data['output_location']
|
14
|
+
Aspose::Cloud::Common::Product.set_base_product_uri(data['product_uri'])
|
15
|
+
end
|
16
|
+
|
17
|
+
# Convert Project Data to Other Formats
|
18
|
+
def test_convert
|
19
|
+
# Create Object of folder class
|
20
|
+
folder = Aspose::Cloud::AsposeStorage::Folder.new
|
21
|
+
response = folder.upload_file '../Data/test_tasks.mpp'
|
22
|
+
assert_equal true, response
|
23
|
+
|
24
|
+
# Create object of converter class
|
25
|
+
converter = Aspose::Cloud::Tasks::Converter.new('test_tasks.mpp')
|
26
|
+
assert_nothing_thrown 'Error' do
|
27
|
+
converter.convert(save_format='pdf')
|
28
|
+
end
|
29
|
+
|
30
|
+
assert_equal true, File.exist?('../Output/test_tasks.pdf')
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require_relative '../../lib/asposecloud'
|
4
|
+
|
5
|
+
class DocumentTests < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
file = File.read('../setup.json')
|
9
|
+
data = JSON.parse(file)
|
10
|
+
|
11
|
+
Aspose::Cloud::Common::AsposeApp.app_key = data['app_key']
|
12
|
+
Aspose::Cloud::Common::AsposeApp.app_sid = data['app_sid']
|
13
|
+
Aspose::Cloud::Common::AsposeApp.output_location = data['output_location']
|
14
|
+
Aspose::Cloud::Common::Product.set_base_product_uri(data['product_uri'])
|
15
|
+
end
|
16
|
+
|
17
|
+
# Retrieve Project Properties
|
18
|
+
def test_get_properties
|
19
|
+
document = Aspose::Cloud::Tasks::Document.new('test_tasks.mpp')
|
20
|
+
response = document.get_properties()
|
21
|
+
assert_instance_of(Array, response)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Gell all tasks
|
25
|
+
def test_get_tasks
|
26
|
+
document = Aspose::Cloud::Tasks::Document.new('test_tasks.mpp')
|
27
|
+
response = document.get_tasks()
|
28
|
+
assert_instance_of(Array, response)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Retrieve Task Information
|
32
|
+
def test_get_task
|
33
|
+
document = Aspose::Cloud::Tasks::Document.new('test_tasks.mpp')
|
34
|
+
response = document.get_task(task_id=1)
|
35
|
+
assert_instance_of(Hash, response)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Add a Task to Project
|
39
|
+
def test_add_task
|
40
|
+
document = Aspose::Cloud::Tasks::Document.new('test_tasks.mpp')
|
41
|
+
response = document.add_task(task_name='Blog Post', before_task_id=1)
|
42
|
+
assert_instance_of(Hash, response)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Delete a Task from Project
|
46
|
+
def test_delete_task
|
47
|
+
document = Aspose::Cloud::Tasks::Document.new('test_tasks.mpp')
|
48
|
+
response = document.delete_task(task_id=1)
|
49
|
+
assert_equal true, response
|
50
|
+
end
|
51
|
+
|
52
|
+
# Get all Links
|
53
|
+
def test_get_links
|
54
|
+
document = Aspose::Cloud::Tasks::Document.new('test_tasks.mpp')
|
55
|
+
response = document.get_links()
|
56
|
+
assert_instance_of(Array, response)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Add a Task Link to Project
|
60
|
+
def test_add_link
|
61
|
+
document = Aspose::Cloud::Tasks::Document.new('test_tasks.mpp')
|
62
|
+
response = document.add_link(link='NewProductDev.mpp/taskLinks/1', index=1, predecessor_uid=1, successor_uid=2, link_type='StartToStart', lag=0, lag_format='Day')
|
63
|
+
assert_equal true, response
|
64
|
+
end
|
65
|
+
|
66
|
+
# Delete a Task Link
|
67
|
+
def test_delete_link
|
68
|
+
document = Aspose::Cloud::Tasks::Document.new('test_tasks.mpp')
|
69
|
+
response = document.delete_link(link_index=1)
|
70
|
+
assert_equal true, response
|
71
|
+
end
|
72
|
+
|
73
|
+
# Get all Outline Codes
|
74
|
+
def test_get_outline_codes
|
75
|
+
document = Aspose::Cloud::Tasks::Document.new('test_tasks.mpp')
|
76
|
+
response = document.get_outline_codes()
|
77
|
+
assert_instance_of(Hash, response)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Retrieve Outline Code Information
|
81
|
+
def test_get_outline_code
|
82
|
+
document = Aspose::Cloud::Tasks::Document.new('test_tasks.mpp')
|
83
|
+
response = document.get_outline_code(outline_code_id=1)
|
84
|
+
assert_instance_of(Hash, response)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Delete Outline Code
|
88
|
+
def test_delete_outline_code
|
89
|
+
document = Aspose::Cloud::Tasks::Document.new('test_tasks.mpp')
|
90
|
+
response = document.delete_outline_code(outline_code_id=1)
|
91
|
+
assert_equal true, response
|
92
|
+
end
|
93
|
+
|
94
|
+
# Get all Extended Attributes
|
95
|
+
def test_get_extended_attributes
|
96
|
+
document = Aspose::Cloud::Tasks::Document.new('test_tasks.mpp')
|
97
|
+
response = document.get_extended_attributes()
|
98
|
+
assert_instance_of(Hash, response)
|
99
|
+
end
|
100
|
+
|
101
|
+
# Retrieve Extended Attribute Information
|
102
|
+
def test_get_extended_attribute
|
103
|
+
document = Aspose::Cloud::Tasks::Document.new('test_tasks.mpp')
|
104
|
+
response = document.get_extended_attribute(attribute_id=1)
|
105
|
+
assert_instance_of(Hash, response)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Delete Extended Attribute
|
109
|
+
def test_delete_extended_attribute
|
110
|
+
document = Aspose::Cloud::Tasks::Document.new('test_tasks.mpp')
|
111
|
+
response = document.delete_extended_attribute(attribute_id=1)
|
112
|
+
assert_equal true, response
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require_relative '../../lib/asposecloud'
|
4
|
+
|
5
|
+
class ResourcesTests < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
file = File.read('../setup.json')
|
9
|
+
data = JSON.parse(file)
|
10
|
+
|
11
|
+
Aspose::Cloud::Common::AsposeApp.app_key = data['app_key']
|
12
|
+
Aspose::Cloud::Common::AsposeApp.app_sid = data['app_sid']
|
13
|
+
Aspose::Cloud::Common::AsposeApp.output_location = data['output_location']
|
14
|
+
Aspose::Cloud::Common::Product.set_base_product_uri(data['product_uri'])
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get all Resources
|
18
|
+
def test_get_resources
|
19
|
+
resources = Aspose::Cloud::Tasks::Resources.new('test_tasks.mpp')
|
20
|
+
response = resources.get_resources()
|
21
|
+
assert_instance_of(Array, response)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Retrieve Resource Information
|
25
|
+
def test_get_resource
|
26
|
+
resources = Aspose::Cloud::Tasks::Resources.new('test_tasks.mpp')
|
27
|
+
response = resources.get_resource(resource_id=1)
|
28
|
+
assert_instance_of(Hash, response)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Add a Resource To Project
|
32
|
+
def test_add_resource
|
33
|
+
resources = Aspose::Cloud::Tasks::Resources.new('test_tasks.mpp')
|
34
|
+
response = resources.add_resource(resource_name='Mark', after_resource_id=1)
|
35
|
+
assert_instance_of(Hash, response)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Delete Resource From Project
|
39
|
+
def test_delete_resource
|
40
|
+
resources = Aspose::Cloud::Tasks::Resources.new('test_tasks.mpp')
|
41
|
+
response = resources.delete_resource(resource_id=3)
|
42
|
+
assert_equal true, response
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require_relative '../../lib/asposecloud'
|
3
|
+
|
4
|
+
class BuilderTests < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
file = File.read('../setup.json')
|
8
|
+
data = JSON.parse(file)
|
9
|
+
|
10
|
+
Aspose::Cloud::Common::AsposeApp.app_key = data['app_key']
|
11
|
+
Aspose::Cloud::Common::AsposeApp.app_sid = data['app_sid']
|
12
|
+
Aspose::Cloud::Common::AsposeApp.output_location = data['output_location']
|
13
|
+
Aspose::Cloud::Common::Product.set_base_product_uri(data['product_uri'])
|
14
|
+
end
|
15
|
+
|
16
|
+
# Insert water mark text into the document
|
17
|
+
def test_insert_watermark_text
|
18
|
+
# Create object of folder class
|
19
|
+
folder = Aspose::Cloud::AsposeStorage::Folder.new
|
20
|
+
response = folder.upload_file '../Data/test_multi_pages.docx'
|
21
|
+
assert_equal true, response
|
22
|
+
|
23
|
+
builder = Aspose::Cloud::Words::Builder.new('test_multi_pages.docx')
|
24
|
+
assert_nothing_thrown 'Error' do
|
25
|
+
builder.insert_watermark_text(text='Watermark Text', rotation_angle=180)
|
26
|
+
end
|
27
|
+
assert_equal true, File.exist?('../Output/test_multi_pages.docx')
|
28
|
+
end
|
29
|
+
|
30
|
+
# Insert water mark image into the document
|
31
|
+
def test_insert_watermark_image
|
32
|
+
builder = Aspose::Cloud::Words::Builder.new('test_multi_pages.docx')
|
33
|
+
assert_nothing_thrown 'Error' do
|
34
|
+
builder.insert_watermark_image(image_file='watermark.png', rotation_angle=90)
|
35
|
+
end
|
36
|
+
assert_equal true, File.exist?('../Output/test_multi_pages.docx')
|
37
|
+
end
|
38
|
+
|
39
|
+
# Remove Watermark from a Word Document
|
40
|
+
def test_remove_watermark
|
41
|
+
builder = Aspose::Cloud::Words::Builder.new('test_multi_pages.docx')
|
42
|
+
assert_nothing_thrown 'Error' do
|
43
|
+
builder.remove_watermark()
|
44
|
+
end
|
45
|
+
assert_equal true, File.exist?('../Output/test_multi_pages.docx')
|
46
|
+
end
|
47
|
+
|
48
|
+
# Replace a text with the new value in the document
|
49
|
+
def test_replace_text
|
50
|
+
builder = Aspose::Cloud::Words::Builder.new('test_multi_pages.docx')
|
51
|
+
assert_nothing_thrown 'Error' do
|
52
|
+
builder.replace_text(old_text='Testing Page 1', new_text='First Page', is_match_case = false, is_match_whole_word = false)
|
53
|
+
end
|
54
|
+
assert_equal true, File.exist?('../Output/test_multi_pages.docx')
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require_relative '../../lib/asposecloud'
|
3
|
+
|
4
|
+
class ConverterTests < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
file = File.read('../setup.json')
|
8
|
+
data = JSON.parse(file)
|
9
|
+
|
10
|
+
Aspose::Cloud::Common::AsposeApp.app_key = data['app_key']
|
11
|
+
Aspose::Cloud::Common::AsposeApp.app_sid = data['app_sid']
|
12
|
+
Aspose::Cloud::Common::AsposeApp.output_location = data['output_location']
|
13
|
+
Aspose::Cloud::Common::Product.set_base_product_uri(data['product_uri'])
|
14
|
+
end
|
15
|
+
|
16
|
+
# Convert document to other formats using storage
|
17
|
+
def test_convert
|
18
|
+
# Create object of folder class
|
19
|
+
folder = Aspose::Cloud::AsposeStorage::Folder.new
|
20
|
+
response = folder.upload_file '../Data/test_multi_pages.docx'
|
21
|
+
assert_equal true, response
|
22
|
+
|
23
|
+
converter = Aspose::Cloud::Words::Converter.new('test_multi_pages.docx')
|
24
|
+
assert_nothing_thrown 'Error' do
|
25
|
+
converter.convert(save_format='pdf')
|
26
|
+
end
|
27
|
+
assert_equal true, File.exist?('../Output/test_multi_pages.pdf')
|
28
|
+
end
|
29
|
+
|
30
|
+
# Convert document to other formats without storage
|
31
|
+
def test_convert_local_file
|
32
|
+
converter = Aspose::Cloud::Words::Converter.new('test_multi_pages.docx')
|
33
|
+
assert_nothing_thrown 'Error' do
|
34
|
+
converter.convert_local_file(input_file_path='../Data/test_multi_pages.docx', output_filename='test_multi_pages.pdf', save_format='pdf')
|
35
|
+
end
|
36
|
+
assert_equal true, File.exist?('../Output/test_multi_pages.pdf')
|
37
|
+
end
|
38
|
+
|
39
|
+
# Convert web pages to Word Documents
|
40
|
+
def test_convert_web_pages
|
41
|
+
converter = Aspose::Cloud::Words::Converter.new('test_multi_pages.docx')
|
42
|
+
assert_nothing_thrown 'Error' do
|
43
|
+
str_xml = '<LoadWebDocumentData>
|
44
|
+
<LoadingDocumentUrl>http://google.com</LoadingDocumentUrl>
|
45
|
+
<DocSaveOptionsData>
|
46
|
+
<SaveFormat>doc</SaveFormat>
|
47
|
+
<FileName>google.doc</FileName>
|
48
|
+
</DocSaveOptionsData>
|
49
|
+
</LoadWebDocumentData>'
|
50
|
+
converter.convert_web_pages(str_xml)
|
51
|
+
end
|
52
|
+
assert_equal true, File.exist?('../Output/google.doc')
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,208 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require_relative '../../lib/asposecloud'
|
3
|
+
|
4
|
+
class DocumentTests < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
file = File.read('../setup.json')
|
8
|
+
data = JSON.parse(file)
|
9
|
+
|
10
|
+
Aspose::Cloud::Common::AsposeApp.app_key = data['app_key']
|
11
|
+
Aspose::Cloud::Common::AsposeApp.app_sid = data['app_sid']
|
12
|
+
Aspose::Cloud::Common::AsposeApp.output_location = data['output_location']
|
13
|
+
Aspose::Cloud::Common::Product.set_base_product_uri(data['product_uri'])
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_save_as
|
17
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
18
|
+
assert_nothing_thrown 'Error' do
|
19
|
+
options_xml = '<PdfSaveOptions>
|
20
|
+
<SaveFormat>pdf</SaveFormat>
|
21
|
+
<FileName>Output.pdf</FileName>
|
22
|
+
<ImageCompression>Jpeg</ImageCompression>
|
23
|
+
<JpegQuality>70</JpegQuality>
|
24
|
+
<TextCompression>Flate</TextCompression>
|
25
|
+
</PdfSaveOptions>'
|
26
|
+
document.save_as(options_xml)
|
27
|
+
end
|
28
|
+
assert_equal true, File.exist?('../Output/Output.pdf')
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_split_document
|
32
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
33
|
+
assert_nothing_thrown 'Error' do
|
34
|
+
response = document.split_document(from=1, to=2, save_format='pdf')
|
35
|
+
end
|
36
|
+
assert_instance_of(Array, response)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_get_page_setup
|
40
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
41
|
+
response = document.get_page_setup(section_index=1)
|
42
|
+
assert_instance_of(Hash, response)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_update_page_setup
|
46
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
47
|
+
assert_nothing_thrown 'Error' do
|
48
|
+
options_xml = '<PageSetup>
|
49
|
+
<LeftMargin>99</LeftMargin>
|
50
|
+
<Orientation>Landscape</Orientation>
|
51
|
+
<PaperSize>A5</PaperSize>
|
52
|
+
</PageSetup>'
|
53
|
+
document.update_page_setup(section_index=1, options_xml)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_append_document
|
58
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
59
|
+
assert_nothing_thrown 'Error' do
|
60
|
+
response = document.append_document(append_docs=["Test.docx"], import_format_modes=["KeepSourceFormatting", "UseDestinationStyles"])
|
61
|
+
end
|
62
|
+
assert_equal true, File.exist?('../Output/test_multi_pages.docx')
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_get_document_info
|
66
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
67
|
+
response = document.get_document_info()
|
68
|
+
assert_instance_of(Hash, response)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_get_property
|
72
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
73
|
+
response = document.get_property(property_name='Author')
|
74
|
+
assert_instance_of(Hash, response)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_set_property
|
78
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
79
|
+
response = document.set_property(property_name='Test', property_value='123')
|
80
|
+
assert_instance_of(Hash, response)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_delete_property
|
84
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
85
|
+
response = document.delete_property(property_name='Test')
|
86
|
+
assert_equal true, response
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_get_properties
|
90
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
91
|
+
response = document.get_properties()
|
92
|
+
assert_instance_of(Array, response)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_get_protection
|
96
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
97
|
+
response = document.get_protection()
|
98
|
+
assert_equal 'NoProtection', response
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_protect_document
|
102
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
103
|
+
assert_nothing_thrown 'Error' do
|
104
|
+
document.protect_document(password='123456', protection_type = 'AllowOnlyComments')
|
105
|
+
end
|
106
|
+
assert_equal true, File.exist?('../Output/test_multi_pages.docx')
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_unprotect_document
|
110
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
111
|
+
assert_nothing_thrown 'Error' do
|
112
|
+
document.unprotect_document(password='123456', protection_type = 'AllowOnlyComments')
|
113
|
+
end
|
114
|
+
assert_equal true, File.exist?('../Output/test_multi_pages.docx')
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_update_protection
|
118
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
119
|
+
assert_nothing_thrown 'Error' do
|
120
|
+
document.update_protection(old_password='123456', new_password='123456789', protection_type = 'AllowOnlyComments')
|
121
|
+
end
|
122
|
+
assert_equal true, File.exist?('../Output/test_multi_pages.docx')
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_get_hyperlinks
|
126
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
127
|
+
response = document.get_hyperlinks()
|
128
|
+
assert_instance_of(Array, response)
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_get_hyperlink
|
132
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
133
|
+
response = document.get_hyperlink(hyperlink_index=1)
|
134
|
+
assert_instance_of(Hash, response)
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_get_hyperlinks_count
|
138
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
139
|
+
response = document.get_hyperlinks_count()
|
140
|
+
assert_equal true, response>=0
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_get_bookmarks
|
144
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
145
|
+
response = document.get_bookmarks()
|
146
|
+
assert_instance_of(Array, response)
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_get_bookmark
|
150
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
151
|
+
response = document.get_bookmark(bookmark_name='First')
|
152
|
+
assert_instance_of(Hash, response)
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_get_bookmarks_count
|
156
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
157
|
+
response = document.get_bookmarks_count()
|
158
|
+
assert_equal true, response>=0
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_update_bookmark
|
162
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
163
|
+
response = document.update_bookmark(bookmark_name='First', bookmark_text='This is new text')
|
164
|
+
assert_instance_of(Hash, response)
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_delete_headers_footers
|
168
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
169
|
+
response = document.delete_headers_footers()
|
170
|
+
assert_equal true, response
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_accept_tracking_changes
|
174
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
175
|
+
assert_nothing_thrown 'Error' do
|
176
|
+
document.accept_tracking_changes()
|
177
|
+
end
|
178
|
+
assert_equal true, File.exist?('../Output/test_multi_pages.docx')
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_reject_tracking_changes
|
182
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
183
|
+
assert_nothing_thrown 'Error' do
|
184
|
+
document.reject_tracking_changes()
|
185
|
+
end
|
186
|
+
assert_equal true, File.exist?('../Output/test_multi_pages.docx')
|
187
|
+
end
|
188
|
+
|
189
|
+
def test_insert_page_number
|
190
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
191
|
+
assert_nothing_thrown 'Error' do
|
192
|
+
document.insert_page_number(alignment='right', format='{PAGE} of {NUMPAGES}', is_top = false, set_page_number_on_first_page = false)
|
193
|
+
end
|
194
|
+
assert_equal true, File.exist?('../Output/test_multi_pages.docx')
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_update_fields
|
198
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
199
|
+
response = document.update_fields()
|
200
|
+
assert_equal true, response
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_update_paragraph_run_font
|
204
|
+
document = Aspose::Cloud::Words::Document.new('test_multi_pages.docx')
|
205
|
+
response = document.update_paragraph_run_font(para_id=1, run_index=1, font_name='Calibri')
|
206
|
+
assert_instance_of(Hash, response)
|
207
|
+
end
|
208
|
+
end
|