aspose_pdf_cloud 19.3.0 → 19.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -5
- data/docs/BorderCornerStyle.md +11 -0
- data/docs/BorderInfo.md +13 -0
- data/docs/Cell.md +21 -0
- data/docs/ColumnAdjustment.md +12 -0
- data/docs/CryptoAlgorithm.md +14 -0
- data/docs/GraphInfo.md +19 -0
- data/docs/ImageFooter.md +23 -0
- data/docs/ImageHeader.md +23 -0
- data/docs/ImageStamp.md +5 -5
- data/docs/MarginInfo.md +5 -5
- data/docs/PageNumberStamp.md +24 -0
- data/docs/PdfApi.md +451 -27
- data/docs/PdfPageStamp.md +5 -5
- data/docs/PermissionsFlags.md +17 -0
- data/docs/Row.md +19 -0
- data/docs/StampBase.md +0 -5
- data/docs/Table.md +31 -0
- data/docs/TableBroken.md +12 -0
- data/docs/TextFooter.md +23 -0
- data/docs/TextHeader.md +23 -0
- data/docs/TextStamp.md +5 -5
- data/lib/aspose_pdf_cloud.rb +15 -0
- data/lib/aspose_pdf_cloud/api/pdf_api.rb +1530 -215
- data/lib/aspose_pdf_cloud/models/border_corner_style.rb +44 -0
- data/lib/aspose_pdf_cloud/models/border_info.rb +241 -0
- data/lib/aspose_pdf_cloud/models/cell.rb +323 -0
- data/lib/aspose_pdf_cloud/models/column_adjustment.rb +45 -0
- data/lib/aspose_pdf_cloud/models/crypto_algorithm.rb +46 -0
- data/lib/aspose_pdf_cloud/models/graph_info.rb +303 -0
- data/lib/aspose_pdf_cloud/models/image_footer.rb +343 -0
- data/lib/aspose_pdf_cloud/models/image_header.rb +343 -0
- data/lib/aspose_pdf_cloud/models/image_stamp.rb +54 -54
- data/lib/aspose_pdf_cloud/models/margin_info.rb +5 -21
- data/lib/aspose_pdf_cloud/models/page_number_stamp.rb +353 -0
- data/lib/aspose_pdf_cloud/models/pdf_page_stamp.rb +54 -54
- data/lib/aspose_pdf_cloud/models/permissions_flags.rb +50 -0
- data/lib/aspose_pdf_cloud/models/row.rb +308 -0
- data/lib/aspose_pdf_cloud/models/stamp_base.rb +1 -51
- data/lib/aspose_pdf_cloud/models/table.rb +425 -0
- data/lib/aspose_pdf_cloud/models/table_broken.rb +45 -0
- data/lib/aspose_pdf_cloud/models/text_footer.rb +343 -0
- data/lib/aspose_pdf_cloud/models/text_header.rb +343 -0
- data/lib/aspose_pdf_cloud/models/text_stamp.rb +54 -54
- data/lib/aspose_pdf_cloud/version.rb +1 -1
- data/test/pdf_tests.rb +407 -5
- data/test_data/4pagesEncrypted.pdf +0 -0
- metadata +33 -2
@@ -31,33 +31,18 @@ module AsposePdfCloud
|
|
31
31
|
# Sets or gets a bool value that indicates the content is stamped as background. If the value is true, the stamp content is layed at the bottom. By defalt, the value is false, the stamp content is layed at the top.
|
32
32
|
attr_accessor :background
|
33
33
|
|
34
|
-
# Gets or sets bottom margin of stamp.
|
35
|
-
attr_accessor :bottom_margin
|
36
|
-
|
37
34
|
# Gets or sets Horizontal alignment of stamp on the page.
|
38
35
|
attr_accessor :horizontal_alignment
|
39
36
|
|
40
|
-
# Gets or sets left margin of stamp.
|
41
|
-
attr_accessor :left_margin
|
42
|
-
|
43
37
|
# Gets or sets a value to indicate the stamp opacity. The value is from 0.0 to 1.0. By default the value is 1.0.
|
44
38
|
attr_accessor :opacity
|
45
39
|
|
46
|
-
# Gets or sets right margin of stamp.
|
47
|
-
attr_accessor :right_margin
|
48
|
-
|
49
40
|
# Sets or gets the rotation of stamp content according values. Note. This property is for set angles which are multiples of 90 degrees (0, 90, 180, 270 degrees). To set arbitrary angle use RotateAngle property. If angle set by ArbitraryAngle is not multiple of 90 then Rotate property returns Rotation.None.
|
50
41
|
attr_accessor :rotate
|
51
42
|
|
52
43
|
# Gets or sets rotate angle of stamp in degrees. This property allows to set arbitrary rotate angle.
|
53
44
|
attr_accessor :rotate_angle
|
54
45
|
|
55
|
-
# Gets or sets top margin of stamp.
|
56
|
-
attr_accessor :top_margin
|
57
|
-
|
58
|
-
# Gets or sets vertical alignment of stamp on page.
|
59
|
-
attr_accessor :vertical_alignment
|
60
|
-
|
61
46
|
# Horizontal stamp coordinate, starting from the left.
|
62
47
|
attr_accessor :x_indent
|
63
48
|
|
@@ -76,27 +61,42 @@ module AsposePdfCloud
|
|
76
61
|
# Gets text properties of the stamp. See for details.
|
77
62
|
attr_accessor :text_state
|
78
63
|
|
64
|
+
# Gets or sets vertical alignment of stamp on page.
|
65
|
+
attr_accessor :vertical_alignment
|
66
|
+
|
67
|
+
# Gets or sets bottom margin of stamp.
|
68
|
+
attr_accessor :bottom_margin
|
69
|
+
|
70
|
+
# Gets or sets left margin of stamp.
|
71
|
+
attr_accessor :left_margin
|
72
|
+
|
73
|
+
# Gets or sets top margin of stamp.
|
74
|
+
attr_accessor :top_margin
|
75
|
+
|
76
|
+
# Gets or sets right margin of stamp.
|
77
|
+
attr_accessor :right_margin
|
78
|
+
|
79
79
|
|
80
80
|
# Attribute mapping from ruby-style variable name to JSON key.
|
81
81
|
def self.attribute_map
|
82
82
|
{
|
83
83
|
:'links' => :'Links',
|
84
84
|
:'background' => :'Background',
|
85
|
-
:'bottom_margin' => :'BottomMargin',
|
86
85
|
:'horizontal_alignment' => :'HorizontalAlignment',
|
87
|
-
:'left_margin' => :'LeftMargin',
|
88
86
|
:'opacity' => :'Opacity',
|
89
|
-
:'right_margin' => :'RightMargin',
|
90
87
|
:'rotate' => :'Rotate',
|
91
88
|
:'rotate_angle' => :'RotateAngle',
|
92
|
-
:'top_margin' => :'TopMargin',
|
93
|
-
:'vertical_alignment' => :'VerticalAlignment',
|
94
89
|
:'x_indent' => :'XIndent',
|
95
90
|
:'y_indent' => :'YIndent',
|
96
91
|
:'zoom' => :'Zoom',
|
97
92
|
:'text_alignment' => :'TextAlignment',
|
98
93
|
:'value' => :'Value',
|
99
|
-
:'text_state' => :'TextState'
|
94
|
+
:'text_state' => :'TextState',
|
95
|
+
:'vertical_alignment' => :'VerticalAlignment',
|
96
|
+
:'bottom_margin' => :'BottomMargin',
|
97
|
+
:'left_margin' => :'LeftMargin',
|
98
|
+
:'top_margin' => :'TopMargin',
|
99
|
+
:'right_margin' => :'RightMargin'
|
100
100
|
}
|
101
101
|
end
|
102
102
|
|
@@ -105,21 +105,21 @@ module AsposePdfCloud
|
|
105
105
|
{
|
106
106
|
:'links' => :'Array<Link>',
|
107
107
|
:'background' => :'BOOLEAN',
|
108
|
-
:'bottom_margin' => :'Float',
|
109
108
|
:'horizontal_alignment' => :'HorizontalAlignment',
|
110
|
-
:'left_margin' => :'Float',
|
111
109
|
:'opacity' => :'Float',
|
112
|
-
:'right_margin' => :'Float',
|
113
110
|
:'rotate' => :'Rotation',
|
114
111
|
:'rotate_angle' => :'Float',
|
115
|
-
:'top_margin' => :'Float',
|
116
|
-
:'vertical_alignment' => :'VerticalAlignment',
|
117
112
|
:'x_indent' => :'Float',
|
118
113
|
:'y_indent' => :'Float',
|
119
114
|
:'zoom' => :'Float',
|
120
115
|
:'text_alignment' => :'HorizontalAlignment',
|
121
116
|
:'value' => :'String',
|
122
|
-
:'text_state' => :'TextState'
|
117
|
+
:'text_state' => :'TextState',
|
118
|
+
:'vertical_alignment' => :'VerticalAlignment',
|
119
|
+
:'bottom_margin' => :'Float',
|
120
|
+
:'left_margin' => :'Float',
|
121
|
+
:'top_margin' => :'Float',
|
122
|
+
:'right_margin' => :'Float'
|
123
123
|
}
|
124
124
|
end
|
125
125
|
|
@@ -141,26 +141,14 @@ module AsposePdfCloud
|
|
141
141
|
self.background = attributes[:'Background']
|
142
142
|
end
|
143
143
|
|
144
|
-
if attributes.has_key?(:'BottomMargin')
|
145
|
-
self.bottom_margin = attributes[:'BottomMargin']
|
146
|
-
end
|
147
|
-
|
148
144
|
if attributes.has_key?(:'HorizontalAlignment')
|
149
145
|
self.horizontal_alignment = attributes[:'HorizontalAlignment']
|
150
146
|
end
|
151
147
|
|
152
|
-
if attributes.has_key?(:'LeftMargin')
|
153
|
-
self.left_margin = attributes[:'LeftMargin']
|
154
|
-
end
|
155
|
-
|
156
148
|
if attributes.has_key?(:'Opacity')
|
157
149
|
self.opacity = attributes[:'Opacity']
|
158
150
|
end
|
159
151
|
|
160
|
-
if attributes.has_key?(:'RightMargin')
|
161
|
-
self.right_margin = attributes[:'RightMargin']
|
162
|
-
end
|
163
|
-
|
164
152
|
if attributes.has_key?(:'Rotate')
|
165
153
|
self.rotate = attributes[:'Rotate']
|
166
154
|
end
|
@@ -169,14 +157,6 @@ module AsposePdfCloud
|
|
169
157
|
self.rotate_angle = attributes[:'RotateAngle']
|
170
158
|
end
|
171
159
|
|
172
|
-
if attributes.has_key?(:'TopMargin')
|
173
|
-
self.top_margin = attributes[:'TopMargin']
|
174
|
-
end
|
175
|
-
|
176
|
-
if attributes.has_key?(:'VerticalAlignment')
|
177
|
-
self.vertical_alignment = attributes[:'VerticalAlignment']
|
178
|
-
end
|
179
|
-
|
180
160
|
if attributes.has_key?(:'XIndent')
|
181
161
|
self.x_indent = attributes[:'XIndent']
|
182
162
|
end
|
@@ -201,6 +181,26 @@ module AsposePdfCloud
|
|
201
181
|
self.text_state = attributes[:'TextState']
|
202
182
|
end
|
203
183
|
|
184
|
+
if attributes.has_key?(:'VerticalAlignment')
|
185
|
+
self.vertical_alignment = attributes[:'VerticalAlignment']
|
186
|
+
end
|
187
|
+
|
188
|
+
if attributes.has_key?(:'BottomMargin')
|
189
|
+
self.bottom_margin = attributes[:'BottomMargin']
|
190
|
+
end
|
191
|
+
|
192
|
+
if attributes.has_key?(:'LeftMargin')
|
193
|
+
self.left_margin = attributes[:'LeftMargin']
|
194
|
+
end
|
195
|
+
|
196
|
+
if attributes.has_key?(:'TopMargin')
|
197
|
+
self.top_margin = attributes[:'TopMargin']
|
198
|
+
end
|
199
|
+
|
200
|
+
if attributes.has_key?(:'RightMargin')
|
201
|
+
self.right_margin = attributes[:'RightMargin']
|
202
|
+
end
|
203
|
+
|
204
204
|
end
|
205
205
|
|
206
206
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -223,21 +223,21 @@ module AsposePdfCloud
|
|
223
223
|
self.class == o.class &&
|
224
224
|
links == o.links &&
|
225
225
|
background == o.background &&
|
226
|
-
bottom_margin == o.bottom_margin &&
|
227
226
|
horizontal_alignment == o.horizontal_alignment &&
|
228
|
-
left_margin == o.left_margin &&
|
229
227
|
opacity == o.opacity &&
|
230
|
-
right_margin == o.right_margin &&
|
231
228
|
rotate == o.rotate &&
|
232
229
|
rotate_angle == o.rotate_angle &&
|
233
|
-
top_margin == o.top_margin &&
|
234
|
-
vertical_alignment == o.vertical_alignment &&
|
235
230
|
x_indent == o.x_indent &&
|
236
231
|
y_indent == o.y_indent &&
|
237
232
|
zoom == o.zoom &&
|
238
233
|
text_alignment == o.text_alignment &&
|
239
234
|
value == o.value &&
|
240
|
-
text_state == o.text_state
|
235
|
+
text_state == o.text_state &&
|
236
|
+
vertical_alignment == o.vertical_alignment &&
|
237
|
+
bottom_margin == o.bottom_margin &&
|
238
|
+
left_margin == o.left_margin &&
|
239
|
+
top_margin == o.top_margin &&
|
240
|
+
right_margin == o.right_margin
|
241
241
|
end
|
242
242
|
|
243
243
|
# @see the `==` method
|
@@ -249,7 +249,7 @@ module AsposePdfCloud
|
|
249
249
|
# Calculates hash code according to all attributes.
|
250
250
|
# @return [Fixnum] Hash code
|
251
251
|
def hash
|
252
|
-
[links, background,
|
252
|
+
[links, background, horizontal_alignment, opacity, rotate, rotate_angle, x_indent, y_indent, zoom, text_alignment, value, text_state, vertical_alignment, bottom_margin, left_margin, top_margin, right_margin].hash
|
253
253
|
end
|
254
254
|
|
255
255
|
# Builds the object from hash
|
data/test/pdf_tests.rb
CHANGED
@@ -21,6 +21,7 @@ SOFTWARE.
|
|
21
21
|
|
22
22
|
require 'minitest/autorun'
|
23
23
|
require 'minitest/unit'
|
24
|
+
require 'base64'
|
24
25
|
|
25
26
|
require_relative '../lib/aspose_pdf_cloud'
|
26
27
|
|
@@ -354,6 +355,121 @@ class PdfTests < Minitest::Test
|
|
354
355
|
assert(response, 'Failed to delete table.')
|
355
356
|
end
|
356
357
|
|
358
|
+
def test_post_page_tables
|
359
|
+
file_name = '4pages.pdf'
|
360
|
+
upload_file(file_name)
|
361
|
+
|
362
|
+
page_number = 1
|
363
|
+
|
364
|
+
opts = {
|
365
|
+
:folder => @temp_folder
|
366
|
+
}
|
367
|
+
|
368
|
+
table = __draw_table
|
369
|
+
|
370
|
+
response = @pdf_api.post_page_tables(file_name, page_number, [table], opts)
|
371
|
+
assert(response, 'Failed to add tables.')
|
372
|
+
end
|
373
|
+
|
374
|
+
def test_put_table
|
375
|
+
file_name = 'PdfWithTable.pdf'
|
376
|
+
upload_file(file_name)
|
377
|
+
|
378
|
+
opts = {
|
379
|
+
:folder => @temp_folder
|
380
|
+
}
|
381
|
+
|
382
|
+
tables_response = @pdf_api.get_document_tables(file_name, opts)
|
383
|
+
assert(tables_response, 'Failed to read document tables.')
|
384
|
+
table_id = tables_response[0].tables.list[0].id
|
385
|
+
|
386
|
+
table = __draw_table
|
387
|
+
|
388
|
+
response = @pdf_api.put_table(file_name, table_id, table, opts)
|
389
|
+
assert(response, 'Failed to update table.')
|
390
|
+
end
|
391
|
+
|
392
|
+
def __draw_table
|
393
|
+
|
394
|
+
text_state = TextState.new
|
395
|
+
text_state.font = 'Arial'
|
396
|
+
text_state.font_size = 10
|
397
|
+
text_state.foreground_color = Color.new({:A => 0xFF, :R => 0, :G => 0xFF, :B => 0})
|
398
|
+
text_state.background_color = Color.new({:A => 0xFF, :R => 0xFF, :G => 0, :B => 0})
|
399
|
+
text_state.font_style = FontStyles::BOLD
|
400
|
+
|
401
|
+
num_of_cols = 5
|
402
|
+
num_of_rows = 5
|
403
|
+
|
404
|
+
table = Table.new
|
405
|
+
table.rows = Array.new(num_of_rows)
|
406
|
+
|
407
|
+
col_widths = '';
|
408
|
+
(1..num_of_cols).each do
|
409
|
+
col_widths += ' 30'
|
410
|
+
end
|
411
|
+
|
412
|
+
table.column_widths = col_widths
|
413
|
+
|
414
|
+
table.default_cell_text_state = text_state
|
415
|
+
|
416
|
+
border_table_border = GraphInfo.new
|
417
|
+
|
418
|
+
border_table_border.color = Color.new({:A => 0xFF, :R => 0, :G => 0xFF, :B => 0xFF})
|
419
|
+
border_table_border.line_width = 1
|
420
|
+
|
421
|
+
border_info = BorderInfo.new
|
422
|
+
border_info.top = border_table_border
|
423
|
+
border_info.right = border_table_border
|
424
|
+
border_info.bottom = border_table_border
|
425
|
+
border_info.left = border_table_border
|
426
|
+
|
427
|
+
table.default_cell_border = border_info
|
428
|
+
table.top = 100
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
(0..(num_of_rows - 1)).each do |r|
|
433
|
+
row = Row.new
|
434
|
+
row.cells = Array.new(num_of_cols)
|
435
|
+
|
436
|
+
(0..(num_of_rows - 1)).each do |c|
|
437
|
+
cell = Cell.new
|
438
|
+
cell.background_color = Color.new({:A => 0xFF, :R => 0xFF, :G => 0, :B => 0xFF})
|
439
|
+
cell.default_cell_text_state = text_state
|
440
|
+
cell.paragraphs = Array.new(1)
|
441
|
+
cell.paragraphs[0] = TextRect.new({:Text => 'value'})
|
442
|
+
|
443
|
+
# change properties on cell
|
444
|
+
|
445
|
+
if c == 1
|
446
|
+
cell.default_cell_text_state.foreground_color = Color.new({:A => 0xFF, :R => 0xFF, :G => 0, :B => 0xFF})
|
447
|
+
|
448
|
+
# change properties on cell AFTER first clearing and re-adding paragraphs
|
449
|
+
elsif c == 2
|
450
|
+
cell.paragraphs[0] = TextRect.new({:Text => 'y'})
|
451
|
+
cell.default_cell_text_state.foreground_color = Color.new({:A => 0xFF, :R => 0, :G => 0, :B => 0xFF})
|
452
|
+
|
453
|
+
#change properties on paragraph
|
454
|
+
elsif c == 3
|
455
|
+
cell.paragraphs[0].text_state = text_state
|
456
|
+
cell.paragraphs[0].text_state.foreground_color = Color.new({:A => 0xFF, :R => 0, :G => 0, :B => 0xFF})
|
457
|
+
|
458
|
+
# change properties on paragraph AFTER first clearing and re-adding paragraphs
|
459
|
+
elsif c == 4
|
460
|
+
cell.paragraphs[0] = TextRect.new({:Text => 'y'})
|
461
|
+
cell.paragraphs[0].text_state = text_state
|
462
|
+
cell.paragraphs[0].text_state.foreground_color = Color.new({:A => 0xFF, :R => 0, :G => 0, :B => 0xFF})
|
463
|
+
end
|
464
|
+
|
465
|
+
row.cells[c] = cell
|
466
|
+
end
|
467
|
+
table.rows[r] = row
|
468
|
+
end
|
469
|
+
table
|
470
|
+
end
|
471
|
+
|
472
|
+
|
357
473
|
# Stamp Annotations Tests
|
358
474
|
|
359
475
|
def test_get_document_stamp_annotations
|
@@ -1453,6 +1569,140 @@ class PdfTests < Minitest::Test
|
|
1453
1569
|
end
|
1454
1570
|
|
1455
1571
|
|
1572
|
+
# Header and Footer Tests
|
1573
|
+
|
1574
|
+
def test_post_document_text_header
|
1575
|
+
name = '4pages.pdf'
|
1576
|
+
upload_file(name)
|
1577
|
+
|
1578
|
+
text_state = TextState.new
|
1579
|
+
text_state.font_size = 14
|
1580
|
+
text_state.font = 'Arial Bold'
|
1581
|
+
text_state.foreground_color = Color.new({:A => 0xFF, :R => 0, :G => 0xFF, :B => 0})
|
1582
|
+
text_state.background_color = Color.new({:A => 0xFF, :R => 0xFF, :G => 0, :B => 0})
|
1583
|
+
text_state.font_style = FontStyles::BOLD
|
1584
|
+
|
1585
|
+
header = TextHeader.new
|
1586
|
+
header.background = true
|
1587
|
+
header.left_margin = 1
|
1588
|
+
header.right_margin = 2
|
1589
|
+
header.top_margin = 20
|
1590
|
+
header.horizontal_alignment = HorizontalAlignment::CENTER
|
1591
|
+
header.opacity = 1
|
1592
|
+
header.rotate = Rotation::NONE
|
1593
|
+
header.rotate_angle = 0
|
1594
|
+
header.x_indent = 0
|
1595
|
+
header.y_indent = 0
|
1596
|
+
header.zoom = 1
|
1597
|
+
header.text_alignment = HorizontalAlignment::CENTER
|
1598
|
+
header.value = 'Header'
|
1599
|
+
header.text_state = text_state
|
1600
|
+
|
1601
|
+
opts = {
|
1602
|
+
:folder => @temp_folder,
|
1603
|
+
:start_page_number => 2,
|
1604
|
+
:end_page_number => 3
|
1605
|
+
}
|
1606
|
+
response = @pdf_api.post_document_text_header(name, header, opts)
|
1607
|
+
assert(response, 'Failed to add text header.')
|
1608
|
+
end
|
1609
|
+
|
1610
|
+
def test_post_document_text_footer
|
1611
|
+
name = '4pages.pdf'
|
1612
|
+
upload_file(name)
|
1613
|
+
|
1614
|
+
text_state = TextState.new
|
1615
|
+
text_state.font_size = 14
|
1616
|
+
text_state.font = 'Arial Bold'
|
1617
|
+
text_state.foreground_color = Color.new({:A => 0xFF, :R => 0, :G => 0xFF, :B => 0})
|
1618
|
+
text_state.background_color = Color.new({:A => 0xFF, :R => 0xFF, :G => 0, :B => 0})
|
1619
|
+
text_state.font_style = FontStyles::BOLD
|
1620
|
+
|
1621
|
+
footer = TextFooter.new
|
1622
|
+
footer.background = true
|
1623
|
+
footer.left_margin = 1
|
1624
|
+
footer.right_margin = 2
|
1625
|
+
footer.bottom_margin = 20
|
1626
|
+
footer.horizontal_alignment = HorizontalAlignment::CENTER
|
1627
|
+
footer.opacity = 1
|
1628
|
+
footer.rotate = Rotation::NONE
|
1629
|
+
footer.rotate_angle = 0
|
1630
|
+
footer.x_indent = 0
|
1631
|
+
footer.y_indent = 0
|
1632
|
+
footer.zoom = 1
|
1633
|
+
footer.text_alignment = HorizontalAlignment::CENTER
|
1634
|
+
footer.value = 'Footer'
|
1635
|
+
footer.text_state = text_state
|
1636
|
+
|
1637
|
+
opts = {
|
1638
|
+
:folder => @temp_folder,
|
1639
|
+
:start_page_number => 2,
|
1640
|
+
:end_page_number => 3
|
1641
|
+
}
|
1642
|
+
response = @pdf_api.post_document_text_footer(name, footer, opts)
|
1643
|
+
assert(response, 'Failed to add text footer.')
|
1644
|
+
end
|
1645
|
+
|
1646
|
+
def test_post_document_image_header
|
1647
|
+
name = '4pages.pdf'
|
1648
|
+
upload_file(name)
|
1649
|
+
|
1650
|
+
image = 'Koala.jpg'
|
1651
|
+
upload_file(image)
|
1652
|
+
|
1653
|
+
header = ImageHeader.new
|
1654
|
+
header.background = true
|
1655
|
+
header.left_margin = 1
|
1656
|
+
header.right_margin = 2
|
1657
|
+
header.top_margin = 20
|
1658
|
+
header.horizontal_alignment = HorizontalAlignment::CENTER
|
1659
|
+
header.opacity = 1
|
1660
|
+
header.rotate = Rotation::NONE
|
1661
|
+
header.rotate_angle = 0
|
1662
|
+
header.x_indent = 0
|
1663
|
+
header.y_indent = 0
|
1664
|
+
header.zoom = 0.1
|
1665
|
+
header.file_name = @temp_folder + '/' + image
|
1666
|
+
|
1667
|
+
opts = {
|
1668
|
+
:folder => @temp_folder,
|
1669
|
+
:start_page_number => 2,
|
1670
|
+
:end_page_number => 3
|
1671
|
+
}
|
1672
|
+
response = @pdf_api.post_document_image_header(name, header, opts)
|
1673
|
+
assert(response, 'Failed to add image header.')
|
1674
|
+
end
|
1675
|
+
|
1676
|
+
def test_post_document_image_footer
|
1677
|
+
name = '4pages.pdf'
|
1678
|
+
upload_file(name)
|
1679
|
+
|
1680
|
+
image = 'Koala.jpg'
|
1681
|
+
upload_file(image)
|
1682
|
+
|
1683
|
+
footer = ImageFooter.new
|
1684
|
+
footer.background = true
|
1685
|
+
footer.left_margin = 1
|
1686
|
+
footer.right_margin = 2
|
1687
|
+
footer.bottom_margin = 20
|
1688
|
+
footer.horizontal_alignment = HorizontalAlignment::CENTER
|
1689
|
+
footer.opacity = 1
|
1690
|
+
footer.rotate = Rotation::NONE
|
1691
|
+
footer.rotate_angle = 0
|
1692
|
+
footer.x_indent = 0
|
1693
|
+
footer.y_indent = 0
|
1694
|
+
footer.zoom = 0.1
|
1695
|
+
footer.file_name = @temp_folder + '/' + image
|
1696
|
+
|
1697
|
+
opts = {
|
1698
|
+
:folder => @temp_folder,
|
1699
|
+
:start_page_number => 2,
|
1700
|
+
:end_page_number => 3
|
1701
|
+
}
|
1702
|
+
response = @pdf_api.post_document_image_footer(name, footer, opts)
|
1703
|
+
assert(response, 'Failed to add image footer.')
|
1704
|
+
end
|
1705
|
+
|
1456
1706
|
# Text Annotations Tests
|
1457
1707
|
|
1458
1708
|
def test_get_document_text_annotations
|
@@ -2450,20 +2700,106 @@ class PdfTests < Minitest::Test
|
|
2450
2700
|
end
|
2451
2701
|
|
2452
2702
|
|
2453
|
-
#
|
2703
|
+
# Encrypt Decrypt Tests
|
2704
|
+
|
2705
|
+
def test_put_encrypt_document
|
2706
|
+
file_name = '4pages.pdf'
|
2707
|
+
upload_file(file_name)
|
2708
|
+
|
2709
|
+
out_path = @temp_folder + '/' + file_name
|
2710
|
+
user_password = 'user $^Password!&'
|
2711
|
+
owner_password = 'owner\//? $12^Password!&'
|
2712
|
+
|
2713
|
+
opts = {
|
2714
|
+
:file => ::File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
2715
|
+
}
|
2716
|
+
|
2717
|
+
response = @pdf_api.put_encrypt_document(out_path, Base64.encode64(user_password),
|
2718
|
+
Base64.encode64(owner_password), CryptoAlgorithm::AE_SX128, opts)
|
2719
|
+
assert(response, 'Failed to encrypt document.')
|
2720
|
+
end
|
2721
|
+
|
2722
|
+
def test_post_encrypt_document_in_storage
|
2723
|
+
file_name = '4pages.pdf'
|
2724
|
+
upload_file(file_name)
|
2725
|
+
|
2726
|
+
user_password = 'user $^Password!&'
|
2727
|
+
owner_password = 'owner\//? $12^Password!&'
|
2728
|
+
|
2729
|
+
opts = {
|
2730
|
+
:folder => @temp_folder
|
2731
|
+
}
|
2454
2732
|
|
2455
|
-
|
2456
|
-
|
2733
|
+
response = @pdf_api.post_encrypt_document_in_storage(file_name, Base64.encode64(user_password),
|
2734
|
+
Base64.encode64(owner_password), CryptoAlgorithm::AE_SX128, opts)
|
2735
|
+
assert(response, 'Failed to encrypt document.')
|
2736
|
+
end
|
2737
|
+
|
2738
|
+
def test_put_decrypt_document
|
2739
|
+
file_name = '4pagesEncrypted.pdf'
|
2457
2740
|
upload_file(file_name)
|
2458
2741
|
|
2742
|
+
out_path = @temp_folder + '/' + file_name
|
2743
|
+
user_password = 'user $^Password!&'
|
2744
|
+
|
2745
|
+
opts = {
|
2746
|
+
:file => ::File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
2747
|
+
}
|
2748
|
+
|
2749
|
+
response = @pdf_api.put_decrypt_document(out_path, Base64.encode64(user_password), opts)
|
2750
|
+
assert(response, 'Failed to decrypt document.')
|
2751
|
+
end
|
2752
|
+
|
2753
|
+
def test_post_decrypt_document_in_storage
|
2754
|
+
file_name = '4pagesEncrypted.pdf'
|
2755
|
+
upload_file(file_name)
|
2756
|
+
|
2757
|
+
user_password = 'user $^Password!&'
|
2758
|
+
|
2459
2759
|
opts = {
|
2460
2760
|
:folder => @temp_folder
|
2461
2761
|
}
|
2462
2762
|
|
2463
|
-
response = @pdf_api.
|
2464
|
-
assert(response, 'Failed to
|
2763
|
+
response = @pdf_api.post_decrypt_document_in_storage(file_name, Base64.encode64(user_password), opts)
|
2764
|
+
assert(response, 'Failed to decrypt document.')
|
2465
2765
|
end
|
2466
2766
|
|
2767
|
+
def test_put_change_password_document
|
2768
|
+
file_name = '4pagesEncrypted.pdf'
|
2769
|
+
upload_file(file_name)
|
2770
|
+
|
2771
|
+
out_path = @temp_folder + '/' + file_name
|
2772
|
+
|
2773
|
+
owner_password = 'owner\//? $12^Password!&'
|
2774
|
+
new_user_password = 'user new\//? $12^Password!&'
|
2775
|
+
new_owner_password = 'owner new\//? $12^Password!&'
|
2776
|
+
|
2777
|
+
opts = {
|
2778
|
+
:file => ::File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
2779
|
+
}
|
2780
|
+
|
2781
|
+
response = @pdf_api.put_change_password_document(out_path, Base64.encode64(owner_password),
|
2782
|
+
Base64.encode64(new_user_password), Base64.encode64(new_owner_password), opts)
|
2783
|
+
assert(response, 'Failed to change document password.')
|
2784
|
+
end
|
2785
|
+
|
2786
|
+
def test_post_change_password_document_in_storage
|
2787
|
+
file_name = '4pagesEncrypted.pdf'
|
2788
|
+
upload_file(file_name)
|
2789
|
+
|
2790
|
+
|
2791
|
+
owner_password = 'owner\//? $12^Password!&'
|
2792
|
+
new_user_password = 'user new\//? $12^Password!&'
|
2793
|
+
new_owner_password = 'owner new\//? $12^Password!&'
|
2794
|
+
|
2795
|
+
opts = {
|
2796
|
+
:folder => @temp_folder
|
2797
|
+
}
|
2798
|
+
|
2799
|
+
response = @pdf_api.post_change_password_document_in_storage(file_name, Base64.encode64(owner_password),
|
2800
|
+
Base64.encode64(new_user_password), Base64.encode64(new_owner_password), opts)
|
2801
|
+
assert(response, 'Failed to change document password.')
|
2802
|
+
end
|
2467
2803
|
|
2468
2804
|
# Convert Tests
|
2469
2805
|
|
@@ -2942,6 +3278,41 @@ class PdfTests < Minitest::Test
|
|
2942
3278
|
assert(response, 'Filed to convert PDF to Xml.')
|
2943
3279
|
end
|
2944
3280
|
|
3281
|
+
def test_get_pdf_in_storage_to_xlsx
|
3282
|
+
file_name = '4pages.pdf'
|
3283
|
+
upload_file(file_name)
|
3284
|
+
|
3285
|
+
opts = {
|
3286
|
+
:folder => @temp_folder
|
3287
|
+
}
|
3288
|
+
|
3289
|
+
response = @pdf_api.get_pdf_in_storage_to_xlsx(file_name, opts)
|
3290
|
+
assert(response, 'Filed to convert PDF to XLS.')
|
3291
|
+
end
|
3292
|
+
|
3293
|
+
def test_put_pdf_in_storage_to_xlsx
|
3294
|
+
file_name = '4pages.pdf'
|
3295
|
+
upload_file(file_name)
|
3296
|
+
res_file = 'result.xlsx'
|
3297
|
+
|
3298
|
+
opts = {
|
3299
|
+
:folder => @temp_folder
|
3300
|
+
}
|
3301
|
+
response = @pdf_api.put_pdf_in_storage_to_xlsx(file_name, @temp_folder + '/' + res_file, opts)
|
3302
|
+
assert(response, 'Filed to convert PDF to XLS.')
|
3303
|
+
end
|
3304
|
+
|
3305
|
+
def test_put_pdf_in_request_to_xlsx
|
3306
|
+
file_name = '4pages.pdf'
|
3307
|
+
|
3308
|
+
res_file = 'result.xlsx'
|
3309
|
+
|
3310
|
+
opts = {
|
3311
|
+
:file => ::File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
3312
|
+
}
|
3313
|
+
response = @pdf_api.put_pdf_in_request_to_xlsx(@temp_folder + '/' + res_file, opts)
|
3314
|
+
assert(response, 'Filed to convert PDF to XLS.')
|
3315
|
+
end
|
2945
3316
|
|
2946
3317
|
# Convert to PDF Tests
|
2947
3318
|
|
@@ -3606,6 +3977,37 @@ class PdfTests < Minitest::Test
|
|
3606
3977
|
assert(response, 'Failed to delete Stamp.')
|
3607
3978
|
end
|
3608
3979
|
|
3980
|
+
def test_post_document_page_number_stamps
|
3981
|
+
name = '4pages.pdf'
|
3982
|
+
upload_file(name)
|
3983
|
+
|
3984
|
+
|
3985
|
+
opts = {
|
3986
|
+
:folder => @temp_folder,
|
3987
|
+
:start_page_number => 2,
|
3988
|
+
:end_page_number => 3
|
3989
|
+
}
|
3990
|
+
|
3991
|
+
stamp = PageNumberStamp.new
|
3992
|
+
stamp.background = true
|
3993
|
+
stamp.left_margin = 1
|
3994
|
+
stamp.right_margin = 2
|
3995
|
+
stamp.top_margin = 3
|
3996
|
+
stamp.bottom_margin = 4
|
3997
|
+
stamp.horizontal_alignment = HorizontalAlignment::CENTER
|
3998
|
+
stamp.vertical_alignment = VerticalAlignment::BOTTOM
|
3999
|
+
stamp.opacity = 1
|
4000
|
+
stamp.rotate = Rotation::NONE
|
4001
|
+
stamp.rotate_angle = 0
|
4002
|
+
stamp.x_indent = 0
|
4003
|
+
stamp.y_indent = 0
|
4004
|
+
stamp.zoom = 1
|
4005
|
+
stamp.starting_number = 3
|
4006
|
+
stamp.value = 'Page #'
|
4007
|
+
|
4008
|
+
response = @pdf_api.post_document_page_number_stamps(name, stamp, opts)
|
4009
|
+
assert(response, 'Failed to add Page number stamp.')
|
4010
|
+
end
|
3609
4011
|
|
3610
4012
|
# Images Tests
|
3611
4013
|
|