asposecloud 1.0.0 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- 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,74 @@
|
|
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 a particular page to image with default size
|
18
|
+
def test_convert_to_image
|
19
|
+
# Create Object of folder class
|
20
|
+
folder = Aspose::Cloud::AsposeStorage::Folder.new
|
21
|
+
response = folder.upload_file '../Data/test_convert.pdf'
|
22
|
+
assert_equal true, response
|
23
|
+
|
24
|
+
# Create object of slides converter class
|
25
|
+
converter = Aspose::Cloud::Pdf::Converter.new('test_convert.pdf')
|
26
|
+
assert_nothing_thrown 'Error' do
|
27
|
+
converter.convert_to_image(page_number=1, image_format='png')
|
28
|
+
end
|
29
|
+
|
30
|
+
assert_equal true, File.exist?('../Output/test_convert_1.png')
|
31
|
+
end
|
32
|
+
|
33
|
+
# Convert a particular page to image with specified size
|
34
|
+
def test_convert_to_image_by_size
|
35
|
+
converter = Aspose::Cloud::Pdf::Converter.new('test_convert.pdf')
|
36
|
+
assert_nothing_thrown 'Error' do
|
37
|
+
converter.convert_to_image_by_size(page_number=1, image_format='png', width=100, height=100)
|
38
|
+
end
|
39
|
+
|
40
|
+
assert_equal true, File.exist?('../Output/test_convert_1.png')
|
41
|
+
end
|
42
|
+
|
43
|
+
# Convert a pdf document to specified format
|
44
|
+
def test_convert
|
45
|
+
converter = Aspose::Cloud::Pdf::Converter.new('Test.pdf')
|
46
|
+
assert_nothing_thrown 'Error' do
|
47
|
+
converter.convert(save_format='tiff')
|
48
|
+
end
|
49
|
+
|
50
|
+
assert_equal true, File.exist?('../Output/Test.tiff')
|
51
|
+
end
|
52
|
+
|
53
|
+
# Convert a local pdf document to specified format without using storage
|
54
|
+
def test_convert_local_file
|
55
|
+
converter = Aspose::Cloud::Pdf::Converter.new('Test.pdf')
|
56
|
+
assert_nothing_thrown 'Error' do
|
57
|
+
input_file = '../Data/test_file_on_storage.pdf'
|
58
|
+
converter.convert_local_file(input_file, output_file='output.tiff', save_format='tiff')
|
59
|
+
end
|
60
|
+
|
61
|
+
assert_equal true, File.exist?('../Output/test_file_on_storage.tiff')
|
62
|
+
end
|
63
|
+
|
64
|
+
# Convert PDF from Remote Server to other Formats
|
65
|
+
def test_convert_by_url
|
66
|
+
converter = Aspose::Cloud::Pdf::Converter.new('Test.pdf')
|
67
|
+
assert_nothing_thrown 'Error' do
|
68
|
+
url = 'http://linux.hanski.info/tests/scribus_form_en.pdf'
|
69
|
+
converter.convert_by_url(url, save_format='tiff', output_file='output.tiff')
|
70
|
+
end
|
71
|
+
|
72
|
+
assert_equal true, File.exist?('../Output/output.tiff')
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,285 @@
|
|
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
|
+
# Get PDF Document Page Count
|
18
|
+
def test_get_page_count
|
19
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
20
|
+
response = document.get_page_count()
|
21
|
+
assert_equal true, response>=0
|
22
|
+
end
|
23
|
+
|
24
|
+
# Append PDF Files
|
25
|
+
def test_append_document
|
26
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
27
|
+
response = document.append_document(append_file='Testing.pdf')
|
28
|
+
assert_equal true, response
|
29
|
+
end
|
30
|
+
|
31
|
+
# Merge multiple PDF files
|
32
|
+
def test_merge_documents
|
33
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
34
|
+
response = document.merge_documents(merged_filename='Test.pdf', source_files=['input1.pdf', 'input2.pdf'])
|
35
|
+
assert_equal true, response
|
36
|
+
end
|
37
|
+
|
38
|
+
# Get Form Field Count from a PDF Document
|
39
|
+
def test_get_form_field_count
|
40
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
41
|
+
response = document.get_form_field_count()
|
42
|
+
assert_equal true, response>=0
|
43
|
+
end
|
44
|
+
|
45
|
+
# Get all Form Fields from the PDF Document
|
46
|
+
def test_get_form_fields
|
47
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
48
|
+
response = document.get_form_fields()
|
49
|
+
assert_instance_of(Array, response)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Get a Particular Form Field from the PDF Document
|
53
|
+
def test_get_form_field
|
54
|
+
document = Aspose::Cloud::Pdf::Document.new('complaintform.pdf')
|
55
|
+
response = document.get_form_field(field_name='last')
|
56
|
+
assert_instance_of(Hash, response)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Update a Form Field in a PDF Document
|
60
|
+
def test_update_form_field
|
61
|
+
document = Aspose::Cloud::Pdf::Document.new('complaintform.pdf')
|
62
|
+
response = document.update_form_field(field_name='last', field_type=0, field_value='Tom')
|
63
|
+
assert_instance_of(Hash, response)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Create PDF from HTML
|
67
|
+
def test_create_from_html
|
68
|
+
document = Aspose::Cloud::Pdf::Document.new('create_from_html.pdf')
|
69
|
+
response = document.create_from_html(html_filename='index.html')
|
70
|
+
assert_equal true, response
|
71
|
+
end
|
72
|
+
|
73
|
+
# Create PDF from XML
|
74
|
+
def test_create_from_xml
|
75
|
+
document = Aspose::Cloud::Pdf::Document.new('create_from_xml.pdf')
|
76
|
+
response = document.create_from_xml(xslt_filename='template.xslt', xml_filename='template-data.xml')
|
77
|
+
assert_equal true, response
|
78
|
+
end
|
79
|
+
|
80
|
+
# Create PDF from JPEG
|
81
|
+
def test_create_from_jpeg
|
82
|
+
document = Aspose::Cloud::Pdf::Document.new('create_from_jpeg.pdf')
|
83
|
+
assert_nothing_thrown 'Error' do
|
84
|
+
document.create_from_jpeg(jpeg_filename='Lighthouse.jpg')
|
85
|
+
end
|
86
|
+
assert_equal true, File.exist?('../Output/create_from_jpeg.pdf')
|
87
|
+
end
|
88
|
+
|
89
|
+
# Create PDF from SVG
|
90
|
+
def test_create_from_svg
|
91
|
+
document = Aspose::Cloud::Pdf::Document.new('create_from_svg.pdf')
|
92
|
+
assert_nothing_thrown 'Error' do
|
93
|
+
response = document.create_from_svg(svg_filename='input.svg')
|
94
|
+
end
|
95
|
+
assert_equal true, File.exist?('../Output/create_from_svg.pdf')
|
96
|
+
end
|
97
|
+
|
98
|
+
# Create PDF from TIFF
|
99
|
+
def test_create_from_tiff
|
100
|
+
document = Aspose::Cloud::Pdf::Document.new('create_from_tiff.pdf')
|
101
|
+
assert_nothing_thrown 'Error' do
|
102
|
+
response = document.create_from_tiff(tiff_filename='input.tiff')
|
103
|
+
end
|
104
|
+
assert_equal true, File.exist?('../Output/create_from_tiff.pdf')
|
105
|
+
end
|
106
|
+
|
107
|
+
# Create Empty PDF
|
108
|
+
def test_create_empty_pdf
|
109
|
+
document = Aspose::Cloud::Pdf::Document.new('Empty.pdf')
|
110
|
+
assert_nothing_thrown 'Error' do
|
111
|
+
document.create_empty_pdf()
|
112
|
+
end
|
113
|
+
assert_equal true, File.exist?('../Output/Empty.pdf')
|
114
|
+
end
|
115
|
+
|
116
|
+
# Add a new page in PDF
|
117
|
+
def test_add_new_page
|
118
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
119
|
+
assert_nothing_thrown 'Error' do
|
120
|
+
document.add_new_page()
|
121
|
+
end
|
122
|
+
assert_equal true, File.exist?('../Output/Test.pdf')
|
123
|
+
end
|
124
|
+
|
125
|
+
# Delete page from PDF
|
126
|
+
def test_delete_page
|
127
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
128
|
+
assert_nothing_thrown 'Error' do
|
129
|
+
document.delete_page(page_number=2)
|
130
|
+
end
|
131
|
+
assert_equal true, File.exist?('../Output/Test.pdf')
|
132
|
+
end
|
133
|
+
|
134
|
+
# Replace Image in a PDF file using Local Image Stream
|
135
|
+
def test_replace_image_stream
|
136
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
137
|
+
input_file = 'path/to/inputfile'
|
138
|
+
image_stream = File.read(input_file, nil, nil, {"mode"=>"b"})
|
139
|
+
response = document.replace_image_stream(page_number=1, image_index=1, image_stream)
|
140
|
+
assert_equal true, File.exist?('../Output/Test.pdf')
|
141
|
+
end
|
142
|
+
|
143
|
+
# Replace Image in a PDF File using Image File
|
144
|
+
def test_replace_image_file
|
145
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
146
|
+
assert_nothing_thrown 'Error' do
|
147
|
+
document.replace_image_file(page_number=1, image_index=1, image_file='watermark.png')
|
148
|
+
end
|
149
|
+
assert_equal true, File.exist?('../Output/Test.pdf')
|
150
|
+
end
|
151
|
+
|
152
|
+
# Get a Particular Document Property from a PDF
|
153
|
+
def test_get_document_property
|
154
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
155
|
+
response = document.get_document_property(property_name='Author')
|
156
|
+
assert_instance_of(Hash, response)
|
157
|
+
end
|
158
|
+
|
159
|
+
# Get All Document Properties from a PDF
|
160
|
+
def test_get_document_properties
|
161
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
162
|
+
response = document.get_document_properties()
|
163
|
+
assert_instance_of(Array, response)
|
164
|
+
end
|
165
|
+
|
166
|
+
# Set document property
|
167
|
+
def test_set_document_property
|
168
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
169
|
+
response = document.set_document_property(property_name='Test', property_value='123')
|
170
|
+
assert_instance_of(Hash, response)
|
171
|
+
end
|
172
|
+
|
173
|
+
# Remove All Document Properties from a PDF
|
174
|
+
def test_remove_all_properties
|
175
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
176
|
+
response = document.remove_all_properties()
|
177
|
+
assert_equal true, response
|
178
|
+
end
|
179
|
+
|
180
|
+
# Split all pages of a PDF document
|
181
|
+
def test_split_all_pages
|
182
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
183
|
+
assert_nothing_thrown 'Error' do
|
184
|
+
document.split_all_pages()
|
185
|
+
end
|
186
|
+
assert_equal true, File.exist?('../Output/Test_1.pdf')
|
187
|
+
assert_equal true, File.exist?('../Output/Test_2.pdf')
|
188
|
+
end
|
189
|
+
|
190
|
+
# Split specfied pages of a PDF document
|
191
|
+
def test_split_pages
|
192
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
193
|
+
assert_nothing_thrown 'Error' do
|
194
|
+
document.split_pages(from=1, to=2)
|
195
|
+
end
|
196
|
+
assert_equal true, File.exist?('../Output/Test_1.pdf')
|
197
|
+
assert_equal true, File.exist?('../Output/Test_2.pdf')
|
198
|
+
end
|
199
|
+
|
200
|
+
# Split all pages of a PDF document to specified format
|
201
|
+
def test_split_pages_to_any_format
|
202
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
203
|
+
assert_nothing_thrown 'Error' do
|
204
|
+
document.split_pages_to_any_format(from=1, to=2, save_format='png')
|
205
|
+
end
|
206
|
+
assert_equal true, File.exist?('../Output/Test_1.png')
|
207
|
+
assert_equal true, File.exist?('../Output/Test_2.png')
|
208
|
+
end
|
209
|
+
|
210
|
+
# Add Text Stamp (Watermark) to a PDF Page
|
211
|
+
def test_add_stamp
|
212
|
+
document = Aspose::Cloud::Pdf::Document.new('Test.pdf')
|
213
|
+
assert_nothing_thrown 'Error' do
|
214
|
+
post_data = '{
|
215
|
+
"Type": 0,
|
216
|
+
"Background": true,
|
217
|
+
"BottomMargin": 2.0,
|
218
|
+
"HorizontalAlignment": 1,
|
219
|
+
"LeftMargin": 3.0,
|
220
|
+
"Opacity": 0.5,
|
221
|
+
"RightMargin": 0.0,
|
222
|
+
"Rotate": 3,
|
223
|
+
"RotateAngle": 45.0,
|
224
|
+
"TopMargin": 4.0,
|
225
|
+
"VerticalAlignment": 3,
|
226
|
+
"XIndent": 2.0,
|
227
|
+
"YIndent": 2.5,
|
228
|
+
"Zoom": 1.5,
|
229
|
+
"TextAlignment": 0,
|
230
|
+
"Value": "STAMP TEXT",
|
231
|
+
"TextState": {
|
232
|
+
"FontSize": 14.0,
|
233
|
+
"Font": "Arial",
|
234
|
+
"ForegroundColor": {
|
235
|
+
"A": 0,
|
236
|
+
"R": 255,
|
237
|
+
"G": 0,
|
238
|
+
"B": 0
|
239
|
+
},
|
240
|
+
"BackgroundColor": {
|
241
|
+
"A": 0,
|
242
|
+
"R": 0,
|
243
|
+
"G": 0,
|
244
|
+
"B": 255
|
245
|
+
},
|
246
|
+
"FontStyle": 2
|
247
|
+
},
|
248
|
+
"FileName": null,
|
249
|
+
"Width": 0.0,
|
250
|
+
"Height": 0.0,
|
251
|
+
"PageIndex": 0,
|
252
|
+
"StartingNumber": 0
|
253
|
+
}'
|
254
|
+
document.add_stamp(page_number=2, post_data)
|
255
|
+
end
|
256
|
+
assert_equal true, File.exist?('../Output/Test.pdf')
|
257
|
+
end
|
258
|
+
|
259
|
+
# Sign PDF Documents
|
260
|
+
def test_add_signature
|
261
|
+
document = Aspose::Cloud::Pdf::Document.new('sign.pdf')
|
262
|
+
assert_nothing_thrown 'Error' do
|
263
|
+
json_data = '{
|
264
|
+
"SignaturePath": "temp.pfx",
|
265
|
+
"SignatureType": "PKCS7",
|
266
|
+
"Password": "password",
|
267
|
+
"Reason": "Success",
|
268
|
+
"Contact": "test@mail.ru",
|
269
|
+
"Location": "Ukraine",
|
270
|
+
"Visible": true,
|
271
|
+
"Rectangle": {
|
272
|
+
"X": 100,
|
273
|
+
"Y": 100,
|
274
|
+
"Width": 400,
|
275
|
+
"Height": 100
|
276
|
+
},
|
277
|
+
"FormFieldName": "Signature2",
|
278
|
+
"Authority": "Sergey Smal",
|
279
|
+
"Date": "1-1-2015"
|
280
|
+
}'
|
281
|
+
document.add_signature(json_data, page_number=1)
|
282
|
+
end
|
283
|
+
assert_equal true, File.exist?('../Output/sign.pdf')
|
284
|
+
end
|
285
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require_relative '../../lib/asposecloud'
|
4
|
+
|
5
|
+
class ExtractorTests < 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 number of images in a specified page
|
18
|
+
def test_get_image_count
|
19
|
+
extractor = Aspose::Cloud::Pdf::Extractor.new('Test.pdf')
|
20
|
+
response = extractor.get_image_count(page_number=1)
|
21
|
+
assert_equal true, response>=0
|
22
|
+
end
|
23
|
+
|
24
|
+
# Get the particular image from the specified page with the default image size
|
25
|
+
def test_get_image_default_size
|
26
|
+
extractor = Aspose::Cloud::Pdf::Extractor.new('Test.pdf')
|
27
|
+
response = extractor.get_image_default_size(page_number=1, image_index=1, image_format='png')
|
28
|
+
assert_equal true, File.exist?('../Output/Test_1.png')
|
29
|
+
end
|
30
|
+
|
31
|
+
# Get the particular image from the specified page with the custom image size
|
32
|
+
def test_get_image_custom_size
|
33
|
+
extractor = Aspose::Cloud::Pdf::Extractor.new('Test.pdf')
|
34
|
+
response = extractor.get_image_custom_size(page_number=1, image_index=1, image_format='png', width=100, height=100)
|
35
|
+
assert_equal true, File.exist?('../Output/Test_1.png')
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require_relative '../../lib/asposecloud'
|
4
|
+
|
5
|
+
class TextEditorTests < 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 text from the whole PDF file or a specific page
|
18
|
+
def test_get_text
|
19
|
+
texteditor = Aspose::Cloud::Pdf::TextEditor.new('Test.pdf')
|
20
|
+
response = texteditor.get_text(page_number=1)
|
21
|
+
assert_instance_of(String, response)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Get text items from the whole PDF file or a specific page
|
25
|
+
def test_get_text_items
|
26
|
+
texteditor = Aspose::Cloud::Pdf::TextEditor.new('Test.pdf')
|
27
|
+
response = texteditor.get_text_items(page_number=1, fragment_number=1)
|
28
|
+
assert_instance_of(Array, response)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Get count of the fragments from a particular page
|
32
|
+
def test_get_fragment_count
|
33
|
+
texteditor = Aspose::Cloud::Pdf::TextEditor.new('Test.pdf')
|
34
|
+
response = texteditor.get_fragment_count(page_number=1)
|
35
|
+
assert_equal true, response>=0
|
36
|
+
end
|
37
|
+
|
38
|
+
# Get TextFormat of a particular Fragment
|
39
|
+
def test_get_text_format
|
40
|
+
texteditor = Aspose::Cloud::Pdf::TextEditor.new('Test.pdf')
|
41
|
+
response = texteditor.get_text_format(page_number=1, fragment_number=1)
|
42
|
+
assert_instance_of(Hash, response)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Get Text Format of a Particular Segment
|
46
|
+
def test_get_segment_text_format
|
47
|
+
texteditor = Aspose::Cloud::Pdf::TextEditor.new('Test.pdf')
|
48
|
+
response = texteditor.get_segment_text_format(page_number=1, fragment_number=1, segment_number=1)
|
49
|
+
assert_instance_of(Hash, response)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Replace all instances of old text with new text in a PDF file or a particular page
|
53
|
+
def test_replace_text
|
54
|
+
texteditor = Aspose::Cloud::Pdf::TextEditor.new('Test.pdf')
|
55
|
+
response = texteditor.replace_text(old_text='This', new_text='It', is_regular_expression = false, page_number = 0)
|
56
|
+
assert_equal true, response
|
57
|
+
end
|
58
|
+
|
59
|
+
# Replace Multiple Texts in a PDF file or a particular page
|
60
|
+
def test_replace_multiple_text
|
61
|
+
str_xml = '<TextReplaceListRequest>
|
62
|
+
<TextReplace>
|
63
|
+
<OldValue>Kevin</OldValue>
|
64
|
+
<NewValue>Mike</NewValue>
|
65
|
+
<Regex>true</Regex>
|
66
|
+
</TextReplace>
|
67
|
+
<TextReplace>
|
68
|
+
<OldValue>nick</OldValue>
|
69
|
+
<NewValue>Cruise</NewValue>
|
70
|
+
<Regex>false</Regex>
|
71
|
+
</TextReplace>
|
72
|
+
</TextReplaceListRequest>'
|
73
|
+
texteditor = Aspose::Cloud::Pdf::TextEditor.new('test_replace_text.pdf')
|
74
|
+
response = texteditor.replace_multiple_text(str_xml)
|
75
|
+
assert_equal true, response
|
76
|
+
end
|
77
|
+
|
78
|
+
# Get count of the segments in a fragment
|
79
|
+
def test_get_segment_count
|
80
|
+
texteditor = Aspose::Cloud::Pdf::TextEditor.new('Test.pdf')
|
81
|
+
response = texteditor.get_segment_count(page_number=1, fragment_number=1)
|
82
|
+
assert_equal true, response>=0
|
83
|
+
end
|
84
|
+
end
|