aspose_pdf_cloud 1.0.2 → 18.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +42 -0
- data/.swagger-codegen-ignore +58 -0
- data/.swagger-codegen/VERSION +1 -0
- data/LICENSE +21 -22
- data/README.md +51 -43
- data/aspose_pdf_cloud.gemspec +32 -8
- data/lib/aspose_pdf_cloud.rb +93 -58
- data/lib/aspose_pdf_cloud/api/pdf_api.rb +2624 -1916
- data/lib/aspose_pdf_cloud/api_client.rb +280 -92
- data/lib/aspose_pdf_cloud/api_error.rb +29 -6
- data/lib/aspose_pdf_cloud/configuration.rb +86 -63
- data/lib/aspose_pdf_cloud/models/annotation.rb +218 -45
- data/lib/aspose_pdf_cloud/models/annotation_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/annotations.rb +187 -25
- data/lib/aspose_pdf_cloud/models/annotations_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/append_document.rb +198 -23
- data/lib/aspose_pdf_cloud/models/attachment.rb +224 -49
- data/lib/aspose_pdf_cloud/models/attachment_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/attachments.rb +187 -25
- data/lib/aspose_pdf_cloud/models/attachments_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/bookmarks.rb +187 -25
- data/lib/aspose_pdf_cloud/models/bookmarks_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/color.rb +214 -31
- data/lib/aspose_pdf_cloud/models/document.rb +194 -29
- data/lib/aspose_pdf_cloud/models/document_pages_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/document_properties.rb +187 -25
- data/lib/aspose_pdf_cloud/models/document_properties_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/document_property.rb +197 -33
- data/lib/aspose_pdf_cloud/models/document_property_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/document_response.rb +206 -34
- data/lib/aspose_pdf_cloud/models/document_text_replace_response.rb +203 -41
- data/lib/aspose_pdf_cloud/models/field.rb +213 -42
- data/lib/aspose_pdf_cloud/models/field_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/field_type.rb +44 -0
- data/lib/aspose_pdf_cloud/models/fields.rb +187 -25
- data/lib/aspose_pdf_cloud/models/fields_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/font_styles.rb +43 -0
- data/lib/aspose_pdf_cloud/models/horizontal_alignment.rb +44 -0
- data/lib/aspose_pdf_cloud/models/http_status_code.rb +87 -0
- data/lib/aspose_pdf_cloud/models/image.rb +194 -29
- data/lib/aspose_pdf_cloud/models/image_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/images.rb +187 -25
- data/lib/aspose_pdf_cloud/models/images_list_request.rb +205 -0
- data/lib/aspose_pdf_cloud/models/images_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/line_spacing.rb +43 -0
- data/lib/aspose_pdf_cloud/models/link.rb +194 -27
- data/lib/aspose_pdf_cloud/models/link_action_type.rb +46 -0
- data/lib/aspose_pdf_cloud/models/link_annotation.rb +204 -39
- data/lib/aspose_pdf_cloud/models/link_annotation_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/link_annotations.rb +187 -25
- data/lib/aspose_pdf_cloud/models/link_annotations_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/link_element.rb +175 -14
- data/lib/aspose_pdf_cloud/models/link_highlighting_mode.rb +45 -0
- data/lib/aspose_pdf_cloud/models/merge_documents.rb +175 -14
- data/lib/aspose_pdf_cloud/models/optimize_options.rb +293 -0
- data/lib/aspose_pdf_cloud/models/page.rb +198 -33
- data/lib/aspose_pdf_cloud/models/page_text_replace_response.rb +203 -41
- data/lib/aspose_pdf_cloud/models/page_word_count.rb +192 -19
- data/lib/aspose_pdf_cloud/models/pages.rb +187 -25
- data/lib/aspose_pdf_cloud/models/paragraph.rb +303 -0
- data/lib/aspose_pdf_cloud/models/rectangle.rb +210 -27
- data/lib/aspose_pdf_cloud/models/rotation.rb +44 -0
- data/lib/aspose_pdf_cloud/models/saa_spose_response.rb +213 -0
- data/lib/aspose_pdf_cloud/models/segment.rb +206 -0
- data/lib/aspose_pdf_cloud/models/signature.rb +278 -54
- data/lib/aspose_pdf_cloud/models/signature_type.rb +42 -0
- data/lib/aspose_pdf_cloud/models/split_result.rb +175 -14
- data/lib/aspose_pdf_cloud/models/split_result_document.rb +206 -37
- data/lib/aspose_pdf_cloud/models/split_result_response.rb +196 -34
- data/lib/aspose_pdf_cloud/models/stamp.rb +312 -104
- data/lib/aspose_pdf_cloud/models/stamp_type.rb +44 -0
- data/lib/aspose_pdf_cloud/models/text_format.rb +197 -33
- data/lib/aspose_pdf_cloud/models/text_format_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/text_horizontal_alignment.rb +47 -0
- data/lib/aspose_pdf_cloud/models/text_item.rb +192 -29
- data/lib/aspose_pdf_cloud/models/text_item_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/text_items.rb +187 -25
- data/lib/aspose_pdf_cloud/models/text_items_response.rb +195 -34
- data/lib/aspose_pdf_cloud/models/text_line.rb +210 -0
- data/lib/aspose_pdf_cloud/models/text_rect.rb +220 -0
- data/lib/aspose_pdf_cloud/models/text_rects.rb +199 -0
- data/lib/aspose_pdf_cloud/models/text_rects_response.rb +222 -0
- data/lib/aspose_pdf_cloud/models/text_replace.rb +225 -25
- data/lib/aspose_pdf_cloud/models/text_replace_list_request.rb +209 -16
- data/lib/aspose_pdf_cloud/models/text_replace_request.rb +262 -0
- data/lib/aspose_pdf_cloud/models/text_replace_response.rb +222 -0
- data/lib/aspose_pdf_cloud/models/text_state.rb +211 -32
- data/lib/aspose_pdf_cloud/models/tiff_export_options.rb +266 -75
- data/lib/aspose_pdf_cloud/models/vertical_alignment.rb +45 -0
- data/lib/aspose_pdf_cloud/models/word_count.rb +174 -14
- data/lib/aspose_pdf_cloud/models/word_count_response.rb +196 -34
- data/lib/aspose_pdf_cloud/models/wrap_mode.rb +44 -0
- data/lib/aspose_pdf_cloud/version.rb +23 -2
- data/test/pdf_tests.rb +1268 -623
- data/test_data/33539.jpg +0 -0
- data/test_data/44781.jpg +0 -0
- data/test_data/4pages.pdf +0 -0
- data/test_data/BlankWithSignature.pdf +0 -0
- data/test_data/Hello_world.pdf +0 -0
- data/test_data/HtmlExample1.html +27 -0
- data/test_data/Koala.jpg +0 -0
- data/test_data/PdfWithAcroForm.pdf +321 -0
- data/test_data/PdfWithAnnotations.pdf +720 -1
- data/test_data/PdfWithBookmarks.pdf +0 -0
- data/test_data/PdfWithEmbeddedFiles.pdf +0 -0
- data/test_data/PdfWithImages2.pdf +0 -0
- data/test_data/PdfWithLinks.pdf +0 -0
- data/test_data/Penguins.jpg +0 -0
- data/test_data/butterfly.jpg +0 -0
- data/test_data/marketing.pdf +0 -0
- data/test_data/rusdoc.pdf +0 -0
- data/test_data/test1234.pfx +0 -0
- metadata +54 -13
- data/lib/aspose_pdf_cloud/models/barcode_response_list.rb +0 -45
- data/lib/aspose_pdf_cloud/models/base_object.rb +0 -86
- data/lib/aspose_pdf_cloud/models/base_response.rb +0 -61
- data/lib/aspose_pdf_cloud/models/page_response.rb +0 -61
@@ -0,0 +1,44 @@
|
|
1
|
+
=begin
|
2
|
+
--------------------------------------------------------------------------------------------------------------------
|
3
|
+
Copyright (c) 2018 Aspose.Pdf for Cloud
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
13
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
14
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
15
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
16
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
17
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
18
|
+
SOFTWARE.
|
19
|
+
--------------------------------------------------------------------------------------------------------------------
|
20
|
+
=end
|
21
|
+
|
22
|
+
require 'date'
|
23
|
+
|
24
|
+
module AsposePdfCloud
|
25
|
+
class WrapMode
|
26
|
+
|
27
|
+
NO_WRAP = "NoWrap".freeze
|
28
|
+
BY_WORDS = "ByWords".freeze
|
29
|
+
DISCRETIONARY_HYPHENATION = "DiscretionaryHyphenation".freeze
|
30
|
+
|
31
|
+
# Builds the enum from string
|
32
|
+
# @param [String] The enum value in the form of the string
|
33
|
+
# @return [String] The enum value
|
34
|
+
def build_from_hash(value)
|
35
|
+
# resolve issue with Concstant Name modification (ex: "FooName" to :FOO_NAME)
|
36
|
+
# consantValues = WrapMode.constants.select{|c| c.to_s == value}
|
37
|
+
constantValues = WrapMode.constants.select{ |const_name| WrapMode.const_get(const_name) == value}
|
38
|
+
|
39
|
+
raise "Invalid ENUM value #{value} for class #WrapMode" if constantValues.empty?
|
40
|
+
value
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -1,3 +1,24 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
=begin
|
2
|
+
--------------------------------------------------------------------------------------------------------------------
|
3
|
+
Copyright (c) 2018 Aspose.Pdf for Cloud
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
13
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
14
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
15
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
16
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
17
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
18
|
+
SOFTWARE.
|
19
|
+
--------------------------------------------------------------------------------------------------------------------
|
20
|
+
=end
|
21
|
+
|
22
|
+
module AsposePdfCloud
|
23
|
+
VERSION = "18.2.0"
|
3
24
|
end
|
data/test/pdf_tests.rb
CHANGED
@@ -1,623 +1,1268 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
1
|
+
=begin
|
2
|
+
--------------------------------------------------------------------------------------------------------------------
|
3
|
+
Copyright (c) 2018 Aspose.Pdf for Cloud
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
13
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
14
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
15
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
16
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
17
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
18
|
+
SOFTWARE.
|
19
|
+
--------------------------------------------------------------------------------------------------------------------
|
20
|
+
=end
|
21
|
+
|
22
|
+
require 'minitest/autorun'
|
23
|
+
require 'minitest/unit'
|
24
|
+
require 'aspose_storage_cloud'
|
25
|
+
|
26
|
+
require_relative '../lib/aspose_pdf_cloud'
|
27
|
+
|
28
|
+
class PdfTests < Minitest::Test
|
29
|
+
include MiniTest::Assertions
|
30
|
+
include AsposePdfCloud
|
31
|
+
include AsposeStorageCloud
|
32
|
+
|
33
|
+
|
34
|
+
def setup
|
35
|
+
# Get App key and App SID from https://cloud.aspose.com
|
36
|
+
AsposeApp.app_key_and_sid('', '')
|
37
|
+
|
38
|
+
@pdf_api = PdfApi.new
|
39
|
+
@storage_api = StorageApi.new
|
40
|
+
@storage_api.api_client.host = 'http://api-dev.aspose.cloud/v1.1'
|
41
|
+
|
42
|
+
@temp_folder = 'TempPdf'
|
43
|
+
@test_data_folder = '../test_data/'
|
44
|
+
|
45
|
+
config = @pdf_api.api_client.config
|
46
|
+
config.host = 'api-dev.aspose.cloud'
|
47
|
+
config.scheme = 'http'
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def teardown
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def upload_file(file_name)
|
56
|
+
response = @storage_api.put_create(@temp_folder + '/' + file_name, File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) } )
|
57
|
+
assert(response, "Failed to upload #{file_name} file.")
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# Annotations Tests
|
62
|
+
|
63
|
+
def test_get_page_annotations
|
64
|
+
file_name = 'PdfWithAnnotations.pdf'
|
65
|
+
upload_file(file_name)
|
66
|
+
|
67
|
+
page_number = 2
|
68
|
+
opts = {
|
69
|
+
:folder => @temp_folder
|
70
|
+
}
|
71
|
+
|
72
|
+
response = @pdf_api.get_page_annotations(file_name, page_number, opts)
|
73
|
+
assert(response, 'Failed to read document page annotations.')
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
# Append Tests
|
78
|
+
|
79
|
+
def test_post_append_document_using_query_params
|
80
|
+
file_name = 'PdfWithImages2.pdf'
|
81
|
+
append_file_name = '4pages.pdf'
|
82
|
+
|
83
|
+
upload_file(file_name)
|
84
|
+
upload_file(append_file_name)
|
85
|
+
|
86
|
+
opts = {
|
87
|
+
:append_file => append_file_name,
|
88
|
+
:startPage => 2,
|
89
|
+
:endPage => 4,
|
90
|
+
:folder => @temp_folder
|
91
|
+
}
|
92
|
+
|
93
|
+
response = @pdf_api.post_append_document(file_name, opts)
|
94
|
+
assert(response, 'Failed to append document to existing one.')
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
def test_post_append_document_using_body_params
|
99
|
+
file_name = 'PdfWithImages2.pdf'
|
100
|
+
append_file_name = '4pages.pdf'
|
101
|
+
|
102
|
+
upload_file(file_name)
|
103
|
+
upload_file(append_file_name)
|
104
|
+
|
105
|
+
append_document = AppendDocument.new
|
106
|
+
append_document.document = append_file_name
|
107
|
+
append_document.start_page = 2
|
108
|
+
append_document.end_page = 4
|
109
|
+
|
110
|
+
opts = {
|
111
|
+
:append_document => append_document,
|
112
|
+
:folder => @temp_folder
|
113
|
+
}
|
114
|
+
|
115
|
+
response = @pdf_api.post_append_document(file_name, opts)
|
116
|
+
assert(response, 'Failed to append document to existing one.')
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
# Attachments Tests
|
121
|
+
|
122
|
+
def test_get_document_attachment_by_index
|
123
|
+
file_name = 'PdfWithEmbeddedFiles.pdf'
|
124
|
+
upload_file(file_name)
|
125
|
+
|
126
|
+
attachment_index = 1
|
127
|
+
opts = {
|
128
|
+
:folder => @temp_folder
|
129
|
+
}
|
130
|
+
|
131
|
+
response = @pdf_api.get_document_attachment_by_index(file_name, attachment_index, opts)
|
132
|
+
assert(response, 'Failed to read document attachment info by its index')
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
def test_get_document_attachments
|
137
|
+
file_name = 'PdfWithEmbeddedFiles.pdf'
|
138
|
+
upload_file(file_name)
|
139
|
+
|
140
|
+
opts = {
|
141
|
+
:folder => @temp_folder
|
142
|
+
}
|
143
|
+
|
144
|
+
response = @pdf_api.get_document_attachments(file_name, opts)
|
145
|
+
assert(response, 'Failed to read document attachments info.')
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
def test_get_download_document_attachment_by_index
|
150
|
+
file_name = 'PdfWithEmbeddedFiles.pdf'
|
151
|
+
upload_file(file_name)
|
152
|
+
|
153
|
+
attachment_index = 1
|
154
|
+
opts = {
|
155
|
+
:folder => @temp_folder
|
156
|
+
}
|
157
|
+
|
158
|
+
response = @pdf_api.get_download_document_attachment_by_index(file_name, attachment_index, opts)
|
159
|
+
assert(response, 'Failed to download document attachment content by its index.')
|
160
|
+
end
|
161
|
+
|
162
|
+
|
163
|
+
# Bookmarks Tests
|
164
|
+
|
165
|
+
def test_get_document_bookmarks
|
166
|
+
file_name = 'PdfWithBookmarks.pdf'
|
167
|
+
upload_file(file_name)
|
168
|
+
|
169
|
+
opts = {
|
170
|
+
:folder => @temp_folder
|
171
|
+
}
|
172
|
+
|
173
|
+
response = @pdf_api.get_document_bookmarks(file_name, opts)
|
174
|
+
assert(response, 'Failed to read document bookmarks.')
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
# Document Save As Tiff Tests
|
179
|
+
|
180
|
+
def test_put_document_save_as_tiff_using_query_params
|
181
|
+
file_name = '4pages.pdf'
|
182
|
+
upload_file(file_name)
|
183
|
+
|
184
|
+
opts = {
|
185
|
+
:result_file => '4pages.tiff',
|
186
|
+
:brightness => 0.6,
|
187
|
+
:compression => 'Ccitt4',
|
188
|
+
:color_depth => 'format1bpp',
|
189
|
+
:left_margin => 0,
|
190
|
+
:right_margin => 0,
|
191
|
+
:top_margin => 0,
|
192
|
+
:bottom_margin => 0,
|
193
|
+
:orientation => 'portait', # Yes, we know 'portrait'. It will be fixed in the next version.
|
194
|
+
:skip_blank_pages => true,
|
195
|
+
:width => 1200,
|
196
|
+
:height => 1600,
|
197
|
+
:x_resolution => 200,
|
198
|
+
:y_resolution => 200,
|
199
|
+
:page_index => 2,
|
200
|
+
:page_count=> 2,
|
201
|
+
:folder => @temp_folder
|
202
|
+
}
|
203
|
+
|
204
|
+
response = @pdf_api.put_document_save_as_tiff(file_name, opts)
|
205
|
+
assert(response, 'Failed to save document as Tiff image')
|
206
|
+
end
|
207
|
+
|
208
|
+
|
209
|
+
def test_put_document_save_as_tiff_using_body_params
|
210
|
+
file_name = '4pages.pdf'
|
211
|
+
upload_file(file_name)
|
212
|
+
|
213
|
+
export_options = TiffExportOptions.new
|
214
|
+
export_options.result_file = '4pages.tiff'
|
215
|
+
export_options.brightness = 0.6
|
216
|
+
export_options.compression = 'Ccitt4'
|
217
|
+
export_options.color_depth = 'format1bpp'
|
218
|
+
export_options.left_margin = 0
|
219
|
+
export_options.right_margin = 0
|
220
|
+
export_options.top_margin = 0
|
221
|
+
export_options.bottom_margin = 0
|
222
|
+
export_options.orientation = 'portait' # Yes, we know 'portrait'. It will be fixed in the next version.
|
223
|
+
export_options.skip_blank_pages = true
|
224
|
+
export_options.width = 1200
|
225
|
+
export_options.height = 1600
|
226
|
+
export_options.x_resolution = 200
|
227
|
+
export_options.y_resolution = 200
|
228
|
+
export_options.page_index = 2
|
229
|
+
export_options.page_count = 2
|
230
|
+
|
231
|
+
opts = {
|
232
|
+
:export_options => export_options,
|
233
|
+
:folder => @temp_folder
|
234
|
+
}
|
235
|
+
|
236
|
+
response = @pdf_api.put_document_save_as_tiff(file_name, opts)
|
237
|
+
assert(response, 'Failed to save document as Tiff image')
|
238
|
+
end
|
239
|
+
|
240
|
+
|
241
|
+
# Document Tests
|
242
|
+
|
243
|
+
def test_get_document
|
244
|
+
file_name = '4pages.pdf'
|
245
|
+
upload_file(file_name)
|
246
|
+
|
247
|
+
opts = {
|
248
|
+
:folder => @temp_folder
|
249
|
+
}
|
250
|
+
|
251
|
+
response = @pdf_api.get_document(file_name, opts)
|
252
|
+
assert(response, 'Failed to read common document info.')
|
253
|
+
end
|
254
|
+
|
255
|
+
|
256
|
+
def test_post_optimize_document
|
257
|
+
file_name = '4pages.pdf'
|
258
|
+
upload_file(file_name)
|
259
|
+
|
260
|
+
optimize_options = OptimizeOptions.new
|
261
|
+
optimize_options.allow_reuse_page_content = false
|
262
|
+
optimize_options.compress_images = true
|
263
|
+
optimize_options.image_quality = 100
|
264
|
+
optimize_options.link_duplcate_streams = true
|
265
|
+
optimize_options.remove_unused_objects = true
|
266
|
+
optimize_options.remove_unused_streams = true
|
267
|
+
optimize_options.unembed_fonts = true
|
268
|
+
|
269
|
+
opts = {
|
270
|
+
:options => optimize_options,
|
271
|
+
:folder => @temp_folder
|
272
|
+
}
|
273
|
+
|
274
|
+
response = @pdf_api.post_optimize_document(file_name, opts)
|
275
|
+
assert(response, 'Failed to optimize document.')
|
276
|
+
end
|
277
|
+
|
278
|
+
|
279
|
+
def test_post_split_document
|
280
|
+
file_name = '4pages.pdf'
|
281
|
+
upload_file(file_name)
|
282
|
+
|
283
|
+
opts = {
|
284
|
+
:folder => @temp_folder
|
285
|
+
}
|
286
|
+
response = @pdf_api.post_split_document(file_name, opts)
|
287
|
+
assert(response, 'Failed to split document to parts.')
|
288
|
+
end
|
289
|
+
|
290
|
+
|
291
|
+
def test_put_convert_document
|
292
|
+
url = 'http://pdf995.com/samples/pdf.pdf'
|
293
|
+
format = 'tiff'
|
294
|
+
|
295
|
+
opts = {
|
296
|
+
:format => format,
|
297
|
+
:url => url
|
298
|
+
}
|
299
|
+
|
300
|
+
response = @pdf_api.put_convert_document(opts)
|
301
|
+
assert(response, 'Failed to convert document from request content to format specified')
|
302
|
+
end
|
303
|
+
|
304
|
+
|
305
|
+
def test_put_create_empty_document
|
306
|
+
file_name = 'empty.pdf'
|
307
|
+
|
308
|
+
opts = {
|
309
|
+
:folder => @temp_folder
|
310
|
+
}
|
311
|
+
|
312
|
+
response = @pdf_api.put_create_document(file_name, opts)
|
313
|
+
assert(response, 'Failed to create new document')
|
314
|
+
end
|
315
|
+
|
316
|
+
|
317
|
+
def test_put_create_document
|
318
|
+
file_name = 'HtmlExample1.pdf'
|
319
|
+
template_name = 'HtmlExample1.html'
|
320
|
+
|
321
|
+
upload_file(template_name)
|
322
|
+
|
323
|
+
opts = {
|
324
|
+
:template_file => @temp_folder + '/' + template_name,
|
325
|
+
:template_type => 'html',
|
326
|
+
:folder => @temp_folder
|
327
|
+
}
|
328
|
+
|
329
|
+
response = @pdf_api.put_create_document(file_name, opts)
|
330
|
+
assert(response, 'Failed to create document from HTML template.')
|
331
|
+
end
|
332
|
+
|
333
|
+
|
334
|
+
def test_put_create_document_from_images
|
335
|
+
image_1 = '33539.jpg'
|
336
|
+
upload_file(image_1)
|
337
|
+
|
338
|
+
image_2 = '44781.jpg'
|
339
|
+
upload_file(image_2)
|
340
|
+
|
341
|
+
result_doc_name = 'pdffromimagesinquery.pdf'
|
342
|
+
|
343
|
+
images = ImagesListRequest.new
|
344
|
+
images.images_list = [ @temp_folder + '/' + image_1, @temp_folder + '/' + image_2]
|
345
|
+
|
346
|
+
opts = {
|
347
|
+
:images => images,
|
348
|
+
:ocr => false,
|
349
|
+
:folder => @temp_folder
|
350
|
+
}
|
351
|
+
|
352
|
+
response = @pdf_api.put_create_document_from_images(result_doc_name, opts)
|
353
|
+
assert(response, 'Failed to create document from Images.')
|
354
|
+
end
|
355
|
+
|
356
|
+
# Fields Tests
|
357
|
+
|
358
|
+
def test_get_field
|
359
|
+
file_name = 'PdfWithAcroForm.pdf'
|
360
|
+
upload_file(file_name)
|
361
|
+
|
362
|
+
opts = {
|
363
|
+
:folder => @temp_folder
|
364
|
+
}
|
365
|
+
field_name = 'textField'
|
366
|
+
|
367
|
+
response = @pdf_api.get_field(file_name, field_name, opts)
|
368
|
+
assert(response, 'Failed to get document field by name.')
|
369
|
+
end
|
370
|
+
|
371
|
+
|
372
|
+
def test_get_fields
|
373
|
+
file_name = 'PdfWithAcroForm.pdf'
|
374
|
+
upload_file(file_name)
|
375
|
+
|
376
|
+
opts = {
|
377
|
+
:folder => @temp_folder
|
378
|
+
}
|
379
|
+
|
380
|
+
response = @pdf_api.get_fields(file_name, opts)
|
381
|
+
assert(response, 'Failed to get document fields.')
|
382
|
+
end
|
383
|
+
|
384
|
+
|
385
|
+
def test_post_create_field
|
386
|
+
file_name = 'Hello_world.pdf'
|
387
|
+
upload_file(file_name)
|
388
|
+
|
389
|
+
rect = Rectangle.new
|
390
|
+
rect.x = 50
|
391
|
+
rect.y = 200
|
392
|
+
rect.width = 150
|
393
|
+
rect.height = 200
|
394
|
+
|
395
|
+
field = Field.new
|
396
|
+
field.name = 'checkboxfield'
|
397
|
+
field.values = ['1']
|
398
|
+
field.type = 'Boolean'
|
399
|
+
field.rect = rect
|
400
|
+
|
401
|
+
page_number = 1
|
402
|
+
|
403
|
+
opts = {
|
404
|
+
:field => field,
|
405
|
+
:folder => @temp_folder
|
406
|
+
}
|
407
|
+
|
408
|
+
response = @pdf_api.post_create_field(file_name, page_number, opts)
|
409
|
+
assert(response, 'Failed to create field.')
|
410
|
+
end
|
411
|
+
|
412
|
+
|
413
|
+
def test_put_update_field
|
414
|
+
file_name = 'PdfWithAcroForm.pdf'
|
415
|
+
upload_file(file_name)
|
416
|
+
|
417
|
+
field_name = 'textField'
|
418
|
+
|
419
|
+
field = Field.new
|
420
|
+
field.name = field_name
|
421
|
+
field.values = ['Text field updated value.']
|
422
|
+
field.type = FieldType::TEXT
|
423
|
+
|
424
|
+
opts = {
|
425
|
+
:field => field,
|
426
|
+
:folder => @temp_folder
|
427
|
+
}
|
428
|
+
|
429
|
+
response = @pdf_api.put_update_field(file_name, field_name, opts)
|
430
|
+
assert(response, 'Failed to update fields.')
|
431
|
+
end
|
432
|
+
|
433
|
+
|
434
|
+
# Fragments And Segments Tests
|
435
|
+
|
436
|
+
def test_get_fragment
|
437
|
+
file_name = '4pages.pdf'
|
438
|
+
upload_file(file_name)
|
439
|
+
|
440
|
+
page_number = 1
|
441
|
+
fragment_number = 1
|
442
|
+
|
443
|
+
opts = {
|
444
|
+
:folder => @temp_folder
|
445
|
+
}
|
446
|
+
|
447
|
+
response = @pdf_api.get_fragment(file_name, page_number, fragment_number, opts)
|
448
|
+
assert(response, 'Failed to read page fragment.')
|
449
|
+
end
|
450
|
+
|
451
|
+
def test_get_fragment_text_format
|
452
|
+
file_name = '4pages.pdf'
|
453
|
+
upload_file(file_name)
|
454
|
+
|
455
|
+
page_number = 1
|
456
|
+
fragment_number = 1
|
457
|
+
|
458
|
+
opts = {
|
459
|
+
:folder => @temp_folder
|
460
|
+
}
|
461
|
+
|
462
|
+
response = @pdf_api.get_fragment_text_format(file_name, page_number, fragment_number, opts)
|
463
|
+
assert(response, 'Failed to read page fragment text format.')
|
464
|
+
end
|
465
|
+
|
466
|
+
|
467
|
+
def test_get_fragments
|
468
|
+
file_name = '4pages.pdf'
|
469
|
+
upload_file(file_name)
|
470
|
+
|
471
|
+
page_number = 1
|
472
|
+
|
473
|
+
opts = {
|
474
|
+
:folder => @temp_folder
|
475
|
+
}
|
476
|
+
response = @pdf_api.get_fragments(file_name, page_number, opts)
|
477
|
+
assert(response, 'Failed to read page fragments.')
|
478
|
+
end
|
479
|
+
|
480
|
+
|
481
|
+
def test_get_segment
|
482
|
+
file_name = '4pages.pdf'
|
483
|
+
upload_file(file_name)
|
484
|
+
|
485
|
+
page_number = 1
|
486
|
+
fragment_number = 1
|
487
|
+
segment_number = 1
|
488
|
+
|
489
|
+
opts = {
|
490
|
+
:folder => @temp_folder
|
491
|
+
}
|
492
|
+
|
493
|
+
response = @pdf_api.get_segment(file_name, page_number, fragment_number, segment_number, opts)
|
494
|
+
assert(response, 'Failed to read segment.')
|
495
|
+
end
|
496
|
+
|
497
|
+
|
498
|
+
def test_get_segment_text_format
|
499
|
+
file_name = '4pages.pdf'
|
500
|
+
upload_file(file_name)
|
501
|
+
|
502
|
+
page_number = 1
|
503
|
+
fragment_number = 1
|
504
|
+
segment_number = 1
|
505
|
+
|
506
|
+
opts = {
|
507
|
+
:folder => @temp_folder
|
508
|
+
}
|
509
|
+
|
510
|
+
response = @pdf_api.get_segment_text_format(file_name, page_number, fragment_number, segment_number, opts)
|
511
|
+
assert(response, 'Failed to read segment text format.')
|
512
|
+
end
|
513
|
+
|
514
|
+
|
515
|
+
def test_get_segments
|
516
|
+
file_name = '4pages.pdf'
|
517
|
+
upload_file(file_name)
|
518
|
+
|
519
|
+
page_number = 1
|
520
|
+
fragment_number = 1
|
521
|
+
|
522
|
+
opts = {
|
523
|
+
:folder => @temp_folder
|
524
|
+
}
|
525
|
+
|
526
|
+
response = @pdf_api.get_segments(file_name, page_number, fragment_number, opts)
|
527
|
+
assert(response, 'Failed to read fragment segments.')
|
528
|
+
end
|
529
|
+
|
530
|
+
|
531
|
+
# Images Tests
|
532
|
+
|
533
|
+
def test_get_image
|
534
|
+
file_name = 'PdfWithImages2.pdf'
|
535
|
+
upload_file(file_name)
|
536
|
+
|
537
|
+
page_number = 1
|
538
|
+
image_number = 1
|
539
|
+
opts = {
|
540
|
+
:folder => @temp_folder
|
541
|
+
}
|
542
|
+
|
543
|
+
response = @pdf_api.get_image(file_name, page_number, image_number, opts)
|
544
|
+
assert(response, 'Failed to read document image by number.')
|
545
|
+
end
|
546
|
+
|
547
|
+
|
548
|
+
def test_get_images
|
549
|
+
file_name = 'PdfWithImages2.pdf'
|
550
|
+
upload_file(file_name)
|
551
|
+
|
552
|
+
page_number = 1
|
553
|
+
opts = {
|
554
|
+
:folder => @temp_folder
|
555
|
+
}
|
556
|
+
|
557
|
+
response = @pdf_api.get_images(file_name, page_number, opts)
|
558
|
+
assert(response, 'Failed to read document images.')
|
559
|
+
end
|
560
|
+
|
561
|
+
|
562
|
+
def test_post_replace_image
|
563
|
+
file_name = 'PdfWithImages2.pdf'
|
564
|
+
upload_file(file_name)
|
565
|
+
|
566
|
+
image_file_name = 'Koala.jpg'
|
567
|
+
upload_file(image_file_name)
|
568
|
+
|
569
|
+
page_number = 1
|
570
|
+
image_number = 1
|
571
|
+
opts = {
|
572
|
+
:image_file => @temp_folder + '/' + image_file_name,
|
573
|
+
:folder => @temp_folder
|
574
|
+
}
|
575
|
+
|
576
|
+
response = @pdf_api.post_replace_image(file_name, page_number, image_number, opts)
|
577
|
+
assert(response, 'Failed to replace document image.')
|
578
|
+
end
|
579
|
+
|
580
|
+
|
581
|
+
# Links Tests
|
582
|
+
|
583
|
+
def test_get_page_link_annotation_by_index
|
584
|
+
file_name = 'PdfWithLinks.pdf'
|
585
|
+
upload_file(file_name)
|
586
|
+
|
587
|
+
page_number = 1
|
588
|
+
link_index = 1
|
589
|
+
opts = {
|
590
|
+
:folder => @temp_folder
|
591
|
+
}
|
592
|
+
|
593
|
+
response = @pdf_api.get_page_link_annotation_by_index(file_name, page_number, link_index, opts)
|
594
|
+
assert(response, 'Failed to read document page link annotation by its index.')
|
595
|
+
end
|
596
|
+
|
597
|
+
def test_get_page_link_annotations
|
598
|
+
file_name = 'PdfWithLinks.pdf'
|
599
|
+
upload_file(file_name)
|
600
|
+
|
601
|
+
page_number = 1
|
602
|
+
opts = {
|
603
|
+
:folder => @temp_folder
|
604
|
+
}
|
605
|
+
|
606
|
+
response = @pdf_api.get_page_link_annotations(file_name, page_number, opts)
|
607
|
+
assert(response, 'Failed to read document page link annotations.')
|
608
|
+
end
|
609
|
+
|
610
|
+
|
611
|
+
# Merge Tests
|
612
|
+
|
613
|
+
def test_put_merge_documents
|
614
|
+
file_name_list = ['4pages.pdf', 'PdfWithImages2.pdf', 'marketing.pdf']
|
615
|
+
file_name_list.each { |file_name| upload_file(file_name)}
|
616
|
+
|
617
|
+
result_name = 'MergingResult.pdf'
|
618
|
+
|
619
|
+
merge_documents = MergeDocuments.new
|
620
|
+
merge_documents.list = file_name_list
|
621
|
+
|
622
|
+
opts = {
|
623
|
+
:merge_documents => merge_documents,
|
624
|
+
:folder => @temp_folder
|
625
|
+
}
|
626
|
+
|
627
|
+
response = @pdf_api.put_merge_documents(result_name, opts)
|
628
|
+
assert(response, 'Failed to merge a list of documents')
|
629
|
+
end
|
630
|
+
|
631
|
+
|
632
|
+
# Pages Tests
|
633
|
+
|
634
|
+
def test_delete_page
|
635
|
+
file_name = '4pages.pdf'
|
636
|
+
upload_file(file_name)
|
637
|
+
|
638
|
+
page_number = 1
|
639
|
+
opts = {
|
640
|
+
:folder => @temp_folder
|
641
|
+
}
|
642
|
+
|
643
|
+
response = @pdf_api.delete_page(file_name, page_number, opts)
|
644
|
+
assert(response, 'Failed to delete document page by its number.')
|
645
|
+
end
|
646
|
+
|
647
|
+
|
648
|
+
def test_get_page
|
649
|
+
file_name = '4pages.pdf'
|
650
|
+
upload_file(file_name)
|
651
|
+
|
652
|
+
page_number = 3
|
653
|
+
opts = {
|
654
|
+
:folder => @temp_folder
|
655
|
+
}
|
656
|
+
|
657
|
+
response = @pdf_api.get_page(file_name, page_number, opts)
|
658
|
+
assert(response, 'Failed to get document page by its number.')
|
659
|
+
end
|
660
|
+
|
661
|
+
|
662
|
+
def test_get_pages
|
663
|
+
file_name = '4pages.pdf'
|
664
|
+
upload_file(file_name)
|
665
|
+
|
666
|
+
opts = {
|
667
|
+
:folder => @temp_folder
|
668
|
+
}
|
669
|
+
|
670
|
+
response = @pdf_api.get_pages(file_name, opts)
|
671
|
+
assert(response, 'Failed to read document pages info.')
|
672
|
+
end
|
673
|
+
|
674
|
+
|
675
|
+
def test_get_words_per_page
|
676
|
+
file_name = '4pages.pdf'
|
677
|
+
upload_file(file_name)
|
678
|
+
|
679
|
+
opts = {
|
680
|
+
:folder => @temp_folder
|
681
|
+
}
|
682
|
+
|
683
|
+
response = @pdf_api.get_words_per_page(file_name, opts)
|
684
|
+
assert(response, 'Failed to get number of words per document page.')
|
685
|
+
end
|
686
|
+
|
687
|
+
|
688
|
+
def test_post_move_page
|
689
|
+
file_name = '4pages.pdf'
|
690
|
+
upload_file(file_name)
|
691
|
+
|
692
|
+
opts = {
|
693
|
+
:folder => @temp_folder
|
694
|
+
}
|
695
|
+
page_number = 1
|
696
|
+
new_index = 1
|
697
|
+
|
698
|
+
response = @pdf_api.post_move_page(file_name, page_number, new_index, opts)
|
699
|
+
assert(response, 'Failed to move page to new position.')
|
700
|
+
end
|
701
|
+
|
702
|
+
|
703
|
+
def test_put_add_new_page
|
704
|
+
file_name = '4pages.pdf'
|
705
|
+
upload_file(file_name)
|
706
|
+
|
707
|
+
opts = {
|
708
|
+
:folder => @temp_folder
|
709
|
+
}
|
710
|
+
|
711
|
+
response = @pdf_api.put_add_new_page(file_name, opts)
|
712
|
+
assert(response, 'Failed to add new page to end of the document.')
|
713
|
+
end
|
714
|
+
|
715
|
+
def test_put_page_add_stamp
|
716
|
+
file_name = '4pages.pdf'
|
717
|
+
upload_file(file_name)
|
718
|
+
|
719
|
+
stamp_file_name = 'Penguins.jpg'
|
720
|
+
upload_file(stamp_file_name)
|
721
|
+
|
722
|
+
page_number = 1
|
723
|
+
|
724
|
+
stamp = Stamp.new
|
725
|
+
stamp.type = StampType::IMAGE
|
726
|
+
stamp.file_name = @temp_folder + '/' + stamp_file_name
|
727
|
+
stamp.background = true
|
728
|
+
stamp.width = 200
|
729
|
+
stamp.height = 200
|
730
|
+
stamp.x_indent = 100
|
731
|
+
stamp.y_indent = 100
|
732
|
+
|
733
|
+
opts = {
|
734
|
+
:folder => @temp_folder
|
735
|
+
}
|
736
|
+
|
737
|
+
response = @pdf_api.put_page_add_stamp(file_name, page_number, stamp, opts)
|
738
|
+
assert(response, 'Failed to add page stamp.')
|
739
|
+
end
|
740
|
+
|
741
|
+
|
742
|
+
# Paragraphs Tests
|
743
|
+
|
744
|
+
def test_put_add_text
|
745
|
+
file_name = '4pages.pdf'
|
746
|
+
upload_file(file_name)
|
747
|
+
|
748
|
+
page_number = 1
|
749
|
+
|
750
|
+
rectangle = Rectangle.new
|
751
|
+
rectangle.x = 100
|
752
|
+
rectangle.y = 100
|
753
|
+
rectangle.width = 200
|
754
|
+
rectangle.height = 200
|
755
|
+
|
756
|
+
foreground_color = Color.new
|
757
|
+
foreground_color.a = 0x00
|
758
|
+
foreground_color.r = 0x00
|
759
|
+
foreground_color.g = 0xFF
|
760
|
+
foreground_color.b = 0x00
|
761
|
+
|
762
|
+
background_color = Color.new
|
763
|
+
background_color.a = 0x00
|
764
|
+
background_color.r = 0xFF
|
765
|
+
background_color.g = 0x00
|
766
|
+
background_color.b = 0x00
|
767
|
+
|
768
|
+
text_state = TextState.new
|
769
|
+
text_state.font = 'Arial'
|
770
|
+
text_state.font_size = 10
|
771
|
+
text_state.foreground_color = foreground_color
|
772
|
+
text_state.background_color = background_color
|
773
|
+
text_state.font_style = FontStyles::BOLD
|
774
|
+
|
775
|
+
segment = Segment.new
|
776
|
+
segment.value = 'segment 1'
|
777
|
+
segment.text_state = text_state
|
778
|
+
|
779
|
+
text_line = TextLine.new
|
780
|
+
text_line.horizontal_alignment = TextHorizontalAlignment::RIGHT
|
781
|
+
text_line.segments = [segment]
|
782
|
+
|
783
|
+
paragraph = Paragraph.new
|
784
|
+
paragraph.rectangle = rectangle
|
785
|
+
paragraph.left_margin = 10
|
786
|
+
paragraph.right_margin = 10
|
787
|
+
paragraph.top_margin = 20
|
788
|
+
paragraph.bottom_margin = 20
|
789
|
+
paragraph.horizontal_alignment = TextHorizontalAlignment::FULL_JUSTIFY
|
790
|
+
paragraph.line_spacing = LineSpacing::FONT_SIZE
|
791
|
+
paragraph.rotation = 10
|
792
|
+
paragraph.subsequent_lines_indent = 20
|
793
|
+
paragraph.vertical_alignment = VerticalAlignment::CENTER
|
794
|
+
paragraph.wrap_mode = WrapMode::BY_WORDS
|
795
|
+
paragraph.lines = [text_line]
|
796
|
+
|
797
|
+
opts = {
|
798
|
+
:paragraph => paragraph,
|
799
|
+
:folder => @temp_folder
|
800
|
+
}
|
801
|
+
|
802
|
+
response = @pdf_api.put_add_text(file_name, page_number, opts)
|
803
|
+
assert(response, 'Failed to add text to the page.')
|
804
|
+
end
|
805
|
+
|
806
|
+
|
807
|
+
# Properties Tests
|
808
|
+
|
809
|
+
def test_delete_properties
|
810
|
+
file_name = 'PdfWithAcroForm.pdf'
|
811
|
+
upload_file(file_name)
|
812
|
+
|
813
|
+
property_1 = DocumentProperty.new
|
814
|
+
property_1.name = 'prop1'
|
815
|
+
property_1.value = 'val1'
|
816
|
+
|
817
|
+
opts_1 = {
|
818
|
+
:property => property_1,
|
819
|
+
:folder => @temp_folder
|
820
|
+
}
|
821
|
+
|
822
|
+
property_2 = DocumentProperty.new
|
823
|
+
property_2.name = 'prop2'
|
824
|
+
property_2.value = 'val2'
|
825
|
+
|
826
|
+
opts_2 = {
|
827
|
+
:property => property_2,
|
828
|
+
:folder => @temp_folder
|
829
|
+
}
|
830
|
+
|
831
|
+
@pdf_api.put_set_property(file_name, property_1.name, opts_1)
|
832
|
+
@pdf_api.put_set_property(file_name, property_2.name, opts_2)
|
833
|
+
|
834
|
+
opts = {
|
835
|
+
:folder => @temp_folder
|
836
|
+
}
|
837
|
+
|
838
|
+
response = @pdf_api.delete_properties(file_name, opts)
|
839
|
+
assert(response, 'Failed to delete document properties.')
|
840
|
+
end
|
841
|
+
|
842
|
+
|
843
|
+
def test_delete_property
|
844
|
+
file_name = 'PdfWithAcroForm.pdf'
|
845
|
+
upload_file(file_name)
|
846
|
+
|
847
|
+
property_1 = DocumentProperty.new
|
848
|
+
property_1.name = 'prop1'
|
849
|
+
property_1.value = 'val1'
|
850
|
+
|
851
|
+
opts_1 = {
|
852
|
+
:property => property_1,
|
853
|
+
:folder => @temp_folder
|
854
|
+
}
|
855
|
+
|
856
|
+
@pdf_api.put_set_property(file_name, property_1.name, opts_1)
|
857
|
+
|
858
|
+
opts = {
|
859
|
+
:folder => @temp_folder
|
860
|
+
}
|
861
|
+
|
862
|
+
response = @pdf_api.delete_property(file_name, property_1.name, opts)
|
863
|
+
assert(response, 'Failed to delete document property.')
|
864
|
+
end
|
865
|
+
|
866
|
+
|
867
|
+
def test_get_document_properties
|
868
|
+
file_name = 'PdfWithAcroForm.pdf'
|
869
|
+
upload_file(file_name)
|
870
|
+
|
871
|
+
property_1 = DocumentProperty.new
|
872
|
+
property_1.name = 'prop1'
|
873
|
+
property_1.value = 'val1'
|
874
|
+
|
875
|
+
opts_1 = {
|
876
|
+
:property => property_1,
|
877
|
+
:folder => @temp_folder
|
878
|
+
}
|
879
|
+
|
880
|
+
property_2 = DocumentProperty.new
|
881
|
+
property_2.name = 'prop2'
|
882
|
+
property_2.value = 'val2'
|
883
|
+
|
884
|
+
opts_2 = {
|
885
|
+
:property => property_2,
|
886
|
+
:folder => @temp_folder
|
887
|
+
}
|
888
|
+
|
889
|
+
@pdf_api.put_set_property(file_name, property_1.name, opts_1)
|
890
|
+
@pdf_api.put_set_property(file_name, property_2.name, opts_2)
|
891
|
+
|
892
|
+
opts = {
|
893
|
+
:folder => @temp_folder
|
894
|
+
}
|
895
|
+
|
896
|
+
response = @pdf_api.get_document_properties(file_name, opts)
|
897
|
+
assert(response, 'Failed to read document properties')
|
898
|
+
end
|
899
|
+
|
900
|
+
|
901
|
+
def test_get_document_property
|
902
|
+
file_name = 'PdfWithAcroForm.pdf'
|
903
|
+
upload_file(file_name)
|
904
|
+
|
905
|
+
property_1 = DocumentProperty.new
|
906
|
+
property_1.name = 'prop1'
|
907
|
+
property_1.value = 'val1'
|
908
|
+
|
909
|
+
opts_1 = {
|
910
|
+
:property => property_1,
|
911
|
+
:folder => @temp_folder
|
912
|
+
}
|
913
|
+
|
914
|
+
@pdf_api.put_set_property(file_name, property_1.name, opts_1)
|
915
|
+
|
916
|
+
opts = {
|
917
|
+
:folder => @temp_folder
|
918
|
+
}
|
919
|
+
|
920
|
+
response = @pdf_api.get_document_property(file_name, property_1.name, opts)
|
921
|
+
assert(response, 'Failed to read document property by name.')
|
922
|
+
end
|
923
|
+
|
924
|
+
|
925
|
+
def test_put_set_property
|
926
|
+
file_name = 'PdfWithAcroForm.pdf'
|
927
|
+
upload_file(file_name)
|
928
|
+
|
929
|
+
property_1 = DocumentProperty.new
|
930
|
+
property_1.name = 'prop1'
|
931
|
+
property_1.value = 'val1'
|
932
|
+
|
933
|
+
opts_1 = {
|
934
|
+
:property => property_1,
|
935
|
+
:folder => @temp_folder
|
936
|
+
}
|
937
|
+
|
938
|
+
response = @pdf_api.put_set_property(file_name, property_1.name, opts_1)
|
939
|
+
assert(response, 'Failed to add/update document property.')
|
940
|
+
end
|
941
|
+
|
942
|
+
|
943
|
+
# Sign Tests
|
944
|
+
|
945
|
+
def test_post_sign_document
|
946
|
+
file_name = 'BlankWithSignature.pdf'
|
947
|
+
upload_file(file_name)
|
948
|
+
|
949
|
+
signature_file_name = 'test1234.pfx'
|
950
|
+
upload_file(signature_file_name)
|
951
|
+
|
952
|
+
rectangle = Rectangle.new
|
953
|
+
rectangle.x = 100
|
954
|
+
rectangle.y = 100
|
955
|
+
rectangle.width = 400
|
956
|
+
rectangle.height = 100
|
957
|
+
|
958
|
+
signature = Signature.new
|
959
|
+
signature.authority = 'Sergey Smal'
|
960
|
+
signature.contact = 'test@mail.ru'
|
961
|
+
signature.date = '08/01/2012 12:15:00.000 PM'
|
962
|
+
signature.form_field_name = 'Signature1'
|
963
|
+
signature.location = 'Ukraine'
|
964
|
+
signature.password = 'test1234'
|
965
|
+
signature.rectangle = rectangle
|
966
|
+
signature.signature_path = @temp_folder + '/' + signature_file_name
|
967
|
+
signature.signature_type = SignatureType::PKCS_7
|
968
|
+
signature.visible = true
|
969
|
+
|
970
|
+
opts = {
|
971
|
+
:signature => signature,
|
972
|
+
:folder => @temp_folder
|
973
|
+
}
|
974
|
+
|
975
|
+
response = @pdf_api.post_sign_document(file_name, opts)
|
976
|
+
assert(response, 'Failed to sign document.')
|
977
|
+
end
|
978
|
+
|
979
|
+
def test_post_sign_page
|
980
|
+
file_name = 'BlankWithSignature.pdf'
|
981
|
+
upload_file(file_name)
|
982
|
+
|
983
|
+
signature_file_name = 'test1234.pfx'
|
984
|
+
upload_file(signature_file_name)
|
985
|
+
|
986
|
+
page_number = 1
|
987
|
+
|
988
|
+
rectangle = Rectangle.new
|
989
|
+
rectangle.x = 100
|
990
|
+
rectangle.y = 100
|
991
|
+
rectangle.width = 400
|
992
|
+
rectangle.height = 100
|
993
|
+
|
994
|
+
signature = Signature.new
|
995
|
+
signature.authority = 'Sergey Smal'
|
996
|
+
signature.contact = 'test@mail.ru'
|
997
|
+
signature.date = '08/01/2012 12:15:00.000 PM'
|
998
|
+
signature.form_field_name = 'Signature1'
|
999
|
+
signature.location = 'Ukraine'
|
1000
|
+
signature.password = 'test1234'
|
1001
|
+
signature.rectangle = rectangle
|
1002
|
+
signature.signature_path = @temp_folder + '/' + signature_file_name
|
1003
|
+
signature.signature_type = 'PKCS7'
|
1004
|
+
signature.visible = true
|
1005
|
+
|
1006
|
+
opts = {
|
1007
|
+
:signature => signature,
|
1008
|
+
:folder => @temp_folder
|
1009
|
+
}
|
1010
|
+
|
1011
|
+
response = @pdf_api.post_sign_page(file_name, page_number, opts)
|
1012
|
+
assert(response, 'Failed to sign page.')
|
1013
|
+
end
|
1014
|
+
|
1015
|
+
|
1016
|
+
# Text Items Tests
|
1017
|
+
|
1018
|
+
def test_get_page_text_items
|
1019
|
+
file_name = '4pages.pdf'
|
1020
|
+
upload_file(file_name)
|
1021
|
+
|
1022
|
+
page_number = 1
|
1023
|
+
opts = {
|
1024
|
+
:folder => @temp_folder
|
1025
|
+
}
|
1026
|
+
|
1027
|
+
response = @pdf_api.get_page_text_items(file_name, page_number, opts)
|
1028
|
+
assert(response, 'Failed to read page text items.')
|
1029
|
+
end
|
1030
|
+
|
1031
|
+
|
1032
|
+
def test_get_text_items
|
1033
|
+
file_name = '4pages.pdf'
|
1034
|
+
upload_file(file_name)
|
1035
|
+
|
1036
|
+
opts = {
|
1037
|
+
:folder => @temp_folder
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
response = @pdf_api.get_text_items(file_name, opts)
|
1041
|
+
assert(response, 'Failed to read document text items.')
|
1042
|
+
end
|
1043
|
+
|
1044
|
+
|
1045
|
+
# Text Replace Tests
|
1046
|
+
|
1047
|
+
def test_post_document_replace_text
|
1048
|
+
file_name = '4pages.pdf'
|
1049
|
+
upload_file(file_name)
|
1050
|
+
|
1051
|
+
text_replace_request = TextReplaceRequest.new
|
1052
|
+
text_replace_request.old_value = 'Page'
|
1053
|
+
text_replace_request.new_value = 'p_a_g_e'
|
1054
|
+
text_replace_request.regex = false
|
1055
|
+
|
1056
|
+
opts = {
|
1057
|
+
:folder => @temp_folder
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
response = @pdf_api.post_document_replace_text(file_name, text_replace_request, opts)
|
1061
|
+
assert(response, "Failed to replace document's text.")
|
1062
|
+
end
|
1063
|
+
|
1064
|
+
|
1065
|
+
def test_post_document_replace_text_list
|
1066
|
+
file_name = '4pages.pdf'
|
1067
|
+
upload_file(file_name)
|
1068
|
+
|
1069
|
+
text_replace_request_1 = TextReplaceRequest.new
|
1070
|
+
text_replace_request_1.old_value = 'First'
|
1071
|
+
text_replace_request_1.new_value = '1'
|
1072
|
+
text_replace_request_1.regex = false
|
1073
|
+
|
1074
|
+
text_replace_request_2 = TextReplaceRequest.new
|
1075
|
+
text_replace_request_2.old_value = 'Page'
|
1076
|
+
text_replace_request_2.new_value = 'p_a_g_e'
|
1077
|
+
text_replace_request_2.regex = false
|
1078
|
+
|
1079
|
+
text_replace_list_request = TextReplaceListRequest.new
|
1080
|
+
text_replace_list_request.text_replaces = [text_replace_request_1, text_replace_request_2]
|
1081
|
+
|
1082
|
+
opts = {
|
1083
|
+
:folder => @temp_folder
|
1084
|
+
}
|
1085
|
+
|
1086
|
+
response = @pdf_api.post_document_replace_text_list(file_name, text_replace_list_request, opts)
|
1087
|
+
assert(response, "Failed to replace document's text")
|
1088
|
+
end
|
1089
|
+
|
1090
|
+
|
1091
|
+
def test_post_page_replace_text
|
1092
|
+
file_name = '4pages.pdf'
|
1093
|
+
upload_file(file_name)
|
1094
|
+
|
1095
|
+
page_number = 1
|
1096
|
+
|
1097
|
+
text_replace_request = TextReplaceRequest.new
|
1098
|
+
text_replace_request.old_value = 'Page'
|
1099
|
+
text_replace_request.new_value = 'p_a_g_e'
|
1100
|
+
text_replace_request.regex = false
|
1101
|
+
|
1102
|
+
opts = {
|
1103
|
+
:folder => @temp_folder
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
response = @pdf_api.post_page_replace_text(file_name, page_number, text_replace_request, opts)
|
1107
|
+
assert(response, 'Failed to replace text')
|
1108
|
+
end
|
1109
|
+
|
1110
|
+
|
1111
|
+
def test_post_page_replace_text_list
|
1112
|
+
file_name = '4pages.pdf'
|
1113
|
+
upload_file(file_name)
|
1114
|
+
|
1115
|
+
page_number = 1
|
1116
|
+
|
1117
|
+
text_replace_request_1 = TextReplaceRequest.new
|
1118
|
+
text_replace_request_1.old_value = 'First'
|
1119
|
+
text_replace_request_1.new_value = '1'
|
1120
|
+
text_replace_request_1.regex = false
|
1121
|
+
|
1122
|
+
text_replace_request_2 = TextReplaceRequest.new
|
1123
|
+
text_replace_request_2.old_value = 'Page'
|
1124
|
+
text_replace_request_2.new_value = 'p_a_g_e'
|
1125
|
+
text_replace_request_2.regex = false
|
1126
|
+
|
1127
|
+
text_replace_list_request = TextReplaceListRequest.new
|
1128
|
+
text_replace_list_request.text_replaces = [text_replace_request_1, text_replace_request_2]
|
1129
|
+
|
1130
|
+
opts = {
|
1131
|
+
:folder => @temp_folder
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
response = @pdf_api.post_page_replace_text_list(file_name, page_number, text_replace_list_request, opts)
|
1135
|
+
assert(response, 'Failed to replace text')
|
1136
|
+
end
|
1137
|
+
|
1138
|
+
|
1139
|
+
# OCR Tests
|
1140
|
+
|
1141
|
+
def test_put_searchable_document
|
1142
|
+
file_name = 'rusdoc.pdf'
|
1143
|
+
upload_file(file_name)
|
1144
|
+
|
1145
|
+
opts = {
|
1146
|
+
:lang => 'rus,eng',
|
1147
|
+
:folder => @temp_folder
|
1148
|
+
}
|
1149
|
+
|
1150
|
+
response = @pdf_api.put_searchable_document(file_name, opts)
|
1151
|
+
assert(response, 'Filed to make document searchable')
|
1152
|
+
end
|
1153
|
+
|
1154
|
+
|
1155
|
+
def test_put_searchable_document_with_default_lang
|
1156
|
+
file_name = 'rusdoc.pdf'
|
1157
|
+
upload_file(file_name)
|
1158
|
+
|
1159
|
+
opts = {
|
1160
|
+
:folder => @temp_folder
|
1161
|
+
}
|
1162
|
+
|
1163
|
+
response = @pdf_api.put_searchable_document(file_name, opts)
|
1164
|
+
assert(response, 'Filed to make document searchable.')
|
1165
|
+
end
|
1166
|
+
|
1167
|
+
|
1168
|
+
# Text Tests
|
1169
|
+
|
1170
|
+
def test_get_text
|
1171
|
+
file_name = '4pages.pdf'
|
1172
|
+
upload_file(file_name)
|
1173
|
+
|
1174
|
+
x = 0
|
1175
|
+
y = 0
|
1176
|
+
width = 0
|
1177
|
+
height = 0
|
1178
|
+
opts = {
|
1179
|
+
:folder => @temp_folder
|
1180
|
+
}
|
1181
|
+
|
1182
|
+
response = @pdf_api.get_text(file_name, x, y, width, height, opts)
|
1183
|
+
assert(response, 'Filed to get document text.')
|
1184
|
+
end
|
1185
|
+
|
1186
|
+
def test_get_page_text_by_two_text_on_page
|
1187
|
+
file_name = '4pages.pdf'
|
1188
|
+
upload_file(file_name)
|
1189
|
+
|
1190
|
+
page_number = 1
|
1191
|
+
x = 0
|
1192
|
+
y = 0
|
1193
|
+
width = 0
|
1194
|
+
height = 0
|
1195
|
+
opts = {
|
1196
|
+
:format => ['First Page', 'Second Page'],
|
1197
|
+
# :format => 'First Page',
|
1198
|
+
:folder => @temp_folder
|
1199
|
+
}
|
1200
|
+
|
1201
|
+
response = @pdf_api.get_page_text(file_name, page_number, x, y, width, height, opts)
|
1202
|
+
assert(response, 'Filed to get document text.')
|
1203
|
+
end
|
1204
|
+
|
1205
|
+
|
1206
|
+
# Text Replace Tests
|
1207
|
+
|
1208
|
+
def test_post_document_text_replace_whole_doc_by_rect
|
1209
|
+
file_name = '4pages.pdf'
|
1210
|
+
upload_file(file_name)
|
1211
|
+
|
1212
|
+
rect = Rectangle.new
|
1213
|
+
rect.x = 100
|
1214
|
+
rect.y = 700
|
1215
|
+
rect.width = 300
|
1216
|
+
rect.height = 300
|
1217
|
+
|
1218
|
+
text_replace = TextReplace.new
|
1219
|
+
text_replace.old_value = 'Page'
|
1220
|
+
text_replace.new_value = 'p_a_g_e'
|
1221
|
+
text_replace.rect = rect
|
1222
|
+
|
1223
|
+
text_replace_list = TextReplaceListRequest.new
|
1224
|
+
text_replace_list.text_replaces = [text_replace]
|
1225
|
+
text_replace_list.start_index = 0
|
1226
|
+
text_replace_list.count_replace = 0
|
1227
|
+
|
1228
|
+
|
1229
|
+
opts = {
|
1230
|
+
:folder => @temp_folder
|
1231
|
+
}
|
1232
|
+
|
1233
|
+
response = @pdf_api.post_document_text_replace(file_name, text_replace_list, opts)
|
1234
|
+
assert(response, 'Filed to replace document text by rect.')
|
1235
|
+
end
|
1236
|
+
|
1237
|
+
|
1238
|
+
def test_post_page_text_replace_by_rect
|
1239
|
+
file_name = '4pages.pdf'
|
1240
|
+
upload_file(file_name)
|
1241
|
+
page_number = 1
|
1242
|
+
|
1243
|
+
rect = Rectangle.new
|
1244
|
+
rect.x = 100
|
1245
|
+
rect.y = 700
|
1246
|
+
rect.width = 300
|
1247
|
+
rect.height = 300
|
1248
|
+
|
1249
|
+
text_replace = TextReplace.new
|
1250
|
+
text_replace.old_value = 'Page'
|
1251
|
+
text_replace.new_value = 'p_a_g_e'
|
1252
|
+
text_replace.rect = rect
|
1253
|
+
|
1254
|
+
text_replace_list = TextReplaceListRequest.new
|
1255
|
+
text_replace_list.text_replaces = [text_replace]
|
1256
|
+
text_replace_list.start_index = 0
|
1257
|
+
text_replace_list.count_replace = 0
|
1258
|
+
|
1259
|
+
opts = {
|
1260
|
+
:folder => @temp_folder
|
1261
|
+
}
|
1262
|
+
|
1263
|
+
response = @pdf_api.post_page_text_replace(file_name, page_number, text_replace_list, opts)
|
1264
|
+
assert(response, 'Filed to replace page text by rect.')
|
1265
|
+
end
|
1266
|
+
|
1267
|
+
end
|
1268
|
+
|