aspose_pdf_cloud 18.7.0 → 18.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/aspose_pdf_cloud.gemspec +53 -49
- data/lib/aspose_pdf_cloud.rb +150 -145
- data/lib/aspose_pdf_cloud/api/pdf_api.rb +12907 -11705
- data/lib/aspose_pdf_cloud/api_client.rb +2 -2
- data/lib/aspose_pdf_cloud/api_error.rb +47 -47
- data/lib/aspose_pdf_cloud/configuration.rb +175 -185
- data/lib/aspose_pdf_cloud/models/annotation.rb +332 -260
- data/lib/aspose_pdf_cloud/models/annotation_flags.rb +52 -0
- data/lib/aspose_pdf_cloud/models/annotation_info.rb +342 -0
- data/lib/aspose_pdf_cloud/models/annotation_state.rb +49 -0
- data/lib/aspose_pdf_cloud/models/annotation_type.rb +69 -0
- data/lib/aspose_pdf_cloud/models/{annotations.rb → annotations_info.rb} +211 -211
- data/lib/aspose_pdf_cloud/models/{annotations_response.rb → annotations_info_response.rb} +222 -222
- data/lib/aspose_pdf_cloud/models/antialiasing_processing_type.rb +43 -43
- data/lib/aspose_pdf_cloud/models/append_document.rb +233 -228
- data/lib/aspose_pdf_cloud/models/{saa_spose_response.rb → aspose_response.rb} +213 -213
- data/lib/aspose_pdf_cloud/models/attachment.rb +270 -270
- data/lib/aspose_pdf_cloud/models/attachment_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/attachments.rb +211 -211
- data/lib/aspose_pdf_cloud/models/attachments_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/color.rb +244 -244
- data/lib/aspose_pdf_cloud/models/color_depth.rb +45 -45
- data/lib/aspose_pdf_cloud/models/compression_type.rb +46 -46
- data/lib/aspose_pdf_cloud/models/doc_format.rb +43 -43
- data/lib/aspose_pdf_cloud/models/doc_recognition_mode.rb +43 -43
- data/lib/aspose_pdf_cloud/models/document.rb +220 -220
- data/lib/aspose_pdf_cloud/models/{text_item_response.rb → document_page_response.rb} +222 -222
- data/lib/aspose_pdf_cloud/models/document_pages_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/document_privilege.rb +298 -298
- data/lib/aspose_pdf_cloud/models/document_properties.rb +211 -211
- data/lib/aspose_pdf_cloud/models/document_properties_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/document_property.rb +227 -227
- data/lib/aspose_pdf_cloud/models/document_property_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/document_response.rb +233 -233
- data/lib/aspose_pdf_cloud/models/epub_recognition_mode.rb +44 -44
- data/lib/aspose_pdf_cloud/models/field.rb +254 -254
- data/lib/aspose_pdf_cloud/models/field_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/field_type.rb +45 -44
- data/lib/aspose_pdf_cloud/models/fields.rb +211 -211
- data/lib/aspose_pdf_cloud/models/fields_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/font_encoding_rules.rb +43 -43
- data/lib/aspose_pdf_cloud/models/font_saving_modes.rb +45 -45
- data/lib/aspose_pdf_cloud/models/font_styles.rb +45 -43
- data/lib/aspose_pdf_cloud/models/free_text_annotation.rb +382 -0
- data/lib/aspose_pdf_cloud/models/{annotation_response.rb → free_text_annotation_response.rb} +222 -222
- data/lib/aspose_pdf_cloud/models/{text_items.rb → free_text_annotations.rb} +211 -211
- data/lib/aspose_pdf_cloud/models/{text_items_response.rb → free_text_annotations_response.rb} +222 -222
- data/lib/aspose_pdf_cloud/models/free_text_intent.rb +44 -0
- data/lib/aspose_pdf_cloud/models/horizontal_alignment.rb +45 -44
- data/lib/aspose_pdf_cloud/models/html_document_type.rb +43 -43
- data/lib/aspose_pdf_cloud/models/html_markup_generation_modes.rb +43 -43
- data/lib/aspose_pdf_cloud/models/image.rb +250 -220
- data/lib/aspose_pdf_cloud/models/image_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/image_src_type.rb +43 -43
- data/lib/aspose_pdf_cloud/models/image_template.rb +281 -281
- data/lib/aspose_pdf_cloud/models/image_templates_request.rb +230 -230
- data/lib/aspose_pdf_cloud/models/images.rb +211 -211
- data/lib/aspose_pdf_cloud/models/images_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/justification.rb +44 -0
- data/lib/aspose_pdf_cloud/models/letters_positioning_methods.rb +43 -43
- data/lib/aspose_pdf_cloud/models/line_spacing.rb +43 -43
- data/lib/aspose_pdf_cloud/models/link.rb +228 -228
- data/lib/aspose_pdf_cloud/models/link_action_type.rb +47 -46
- data/lib/aspose_pdf_cloud/models/link_annotation.rb +254 -236
- data/lib/aspose_pdf_cloud/models/link_annotation_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/link_annotations.rb +211 -211
- data/lib/aspose_pdf_cloud/models/link_annotations_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/link_element.rb +200 -200
- data/lib/aspose_pdf_cloud/models/link_highlighting_mode.rb +46 -45
- data/lib/aspose_pdf_cloud/models/margin_info.rb +244 -244
- data/lib/aspose_pdf_cloud/models/markup_annotation.rb +342 -0
- data/lib/aspose_pdf_cloud/models/merge_documents.rb +205 -200
- data/lib/aspose_pdf_cloud/models/optimize_options.rb +293 -293
- data/lib/aspose_pdf_cloud/models/page.rb +228 -228
- data/lib/aspose_pdf_cloud/models/page_word_count.rb +218 -218
- data/lib/aspose_pdf_cloud/models/pages.rb +211 -211
- data/lib/aspose_pdf_cloud/models/paragraph.rb +303 -303
- data/lib/aspose_pdf_cloud/models/parts_embedding_modes.rb +44 -44
- data/lib/aspose_pdf_cloud/models/pdf_a_type.rb +43 -43
- data/lib/aspose_pdf_cloud/models/raster_images_saving_modes.rb +44 -44
- data/lib/aspose_pdf_cloud/models/{document_text_replace_response.rb → rectangle_pdf.rb} +244 -231
- data/lib/aspose_pdf_cloud/models/rotation.rb +45 -44
- data/lib/aspose_pdf_cloud/models/segment.rb +211 -206
- data/lib/aspose_pdf_cloud/models/shape_type.rb +44 -44
- data/lib/aspose_pdf_cloud/models/signature.rb +338 -333
- data/lib/aspose_pdf_cloud/models/signature_type.rb +44 -42
- data/lib/aspose_pdf_cloud/models/signature_verify_response.rb +223 -223
- data/lib/aspose_pdf_cloud/models/split_result.rb +200 -200
- data/lib/aspose_pdf_cloud/models/split_result_document.rb +238 -238
- data/lib/aspose_pdf_cloud/models/split_result_response.rb +223 -223
- data/lib/aspose_pdf_cloud/models/stamp.rb +413 -413
- data/lib/aspose_pdf_cloud/models/stamp_type.rb +45 -44
- data/lib/aspose_pdf_cloud/models/{tiff_export_options.rb → text_annotation.rb} +382 -348
- data/lib/aspose_pdf_cloud/models/text_annotation_response.rb +222 -0
- data/lib/aspose_pdf_cloud/models/{text_item.rb → text_annotations.rb} +211 -218
- data/lib/aspose_pdf_cloud/models/text_annotations_response.rb +222 -0
- data/lib/aspose_pdf_cloud/models/text_horizontal_alignment.rb +47 -47
- data/lib/aspose_pdf_cloud/models/text_icon.rb +52 -0
- data/lib/aspose_pdf_cloud/models/text_line.rb +215 -210
- data/lib/aspose_pdf_cloud/models/text_rect.rb +220 -220
- data/lib/aspose_pdf_cloud/models/text_rects.rb +199 -199
- data/lib/aspose_pdf_cloud/models/text_rects_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/text_replace.rb +253 -253
- data/lib/aspose_pdf_cloud/models/text_replace_list_request.rb +232 -232
- data/lib/aspose_pdf_cloud/models/text_replace_response.rb +222 -222
- data/lib/aspose_pdf_cloud/models/text_state.rb +248 -248
- data/lib/aspose_pdf_cloud/models/{text_format.rb → text_style.rb} +233 -227
- data/lib/aspose_pdf_cloud/models/vertical_alignment.rb +45 -45
- data/lib/aspose_pdf_cloud/models/word_count.rb +199 -199
- data/lib/aspose_pdf_cloud/models/word_count_response.rb +223 -223
- data/lib/aspose_pdf_cloud/models/wrap_mode.rb +44 -44
- data/lib/aspose_pdf_cloud/version.rb +24 -24
- data/test/pdf_tests.rb +1496 -1325
- data/test_data/TexExample.tex +304 -304
- metadata +24 -21
- data/.gitignore +0 -46
- data/.swagger-codegen-ignore +0 -58
- data/lib/aspose_pdf_cloud/models/http_status_code.rb +0 -87
- data/lib/aspose_pdf_cloud/models/images_list_request.rb +0 -205
- data/lib/aspose_pdf_cloud/models/page_text_replace_response.rb +0 -231
- data/lib/aspose_pdf_cloud/models/rectangle.rb +0 -244
- data/lib/aspose_pdf_cloud/models/text_format_response.rb +0 -222
- data/lib/aspose_pdf_cloud/models/text_replace_request.rb +0 -262
@@ -1,24 +1,24 @@
|
|
1
|
-
=begin
|
2
|
-
--------------------------------------------------------------------------------------------------------------------
|
3
|
-
Copyright (c) 2018 Aspose.PDF 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.
|
24
|
-
end
|
1
|
+
=begin
|
2
|
+
--------------------------------------------------------------------------------------------------------------------
|
3
|
+
Copyright (c) 2018 Aspose.PDF 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.9.0"
|
24
|
+
end
|
data/test/pdf_tests.rb
CHANGED
@@ -30,14 +30,14 @@ class PdfTests < Minitest::Test
|
|
30
30
|
|
31
31
|
|
32
32
|
def setup
|
33
|
-
# Get App key and App SID from https://
|
33
|
+
# Get App key and App SID from https://aspose.cloud
|
34
34
|
@pdf_api = PdfApi.new('app_key', 'app_sid')
|
35
35
|
|
36
36
|
@temp_folder = 'TempPdfCloud'
|
37
37
|
@test_data_folder = '../test_data/'
|
38
38
|
|
39
39
|
config = @pdf_api.api_client.config
|
40
|
-
config.host = '
|
40
|
+
config.host = 'billing.cloud.saltov.dynabic.com'
|
41
41
|
config.scheme = 'https'
|
42
42
|
end
|
43
43
|
|
@@ -54,6 +54,30 @@ class PdfTests < Minitest::Test
|
|
54
54
|
|
55
55
|
# Annotations Tests
|
56
56
|
|
57
|
+
def test_get_document_annotations
|
58
|
+
file_name = 'PdfWithAnnotations.pdf'
|
59
|
+
upload_file(file_name)
|
60
|
+
|
61
|
+
opts = {
|
62
|
+
:folder => @temp_folder
|
63
|
+
}
|
64
|
+
|
65
|
+
response = @pdf_api.get_document_annotations(file_name, opts)
|
66
|
+
assert(response, 'Failed to read document annotations.')
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_delete_document_annotations
|
70
|
+
file_name = 'PdfWithAnnotations.pdf'
|
71
|
+
upload_file(file_name)
|
72
|
+
|
73
|
+
opts = {
|
74
|
+
:folder => @temp_folder
|
75
|
+
}
|
76
|
+
|
77
|
+
response = @pdf_api.delete_document_annotations(file_name, opts)
|
78
|
+
assert(response, 'Failed to delete document annotations.')
|
79
|
+
end
|
80
|
+
|
57
81
|
def test_get_page_annotations
|
58
82
|
file_name = 'PdfWithAnnotations.pdf'
|
59
83
|
upload_file(file_name)
|
@@ -67,6 +91,237 @@ class PdfTests < Minitest::Test
|
|
67
91
|
assert(response, 'Failed to read document page annotations.')
|
68
92
|
end
|
69
93
|
|
94
|
+
def test_delete_page_annotations
|
95
|
+
file_name = 'PdfWithAnnotations.pdf'
|
96
|
+
upload_file(file_name)
|
97
|
+
|
98
|
+
page_number = 2
|
99
|
+
opts = {
|
100
|
+
:folder => @temp_folder
|
101
|
+
}
|
102
|
+
|
103
|
+
response = @pdf_api.delete_page_annotations(file_name, page_number, opts)
|
104
|
+
assert(response, 'Failed to read document page annotations.')
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_delete_annotation
|
108
|
+
file_name = 'PdfWithAnnotations.pdf'
|
109
|
+
upload_file(file_name)
|
110
|
+
|
111
|
+
|
112
|
+
opts = {
|
113
|
+
:folder => @temp_folder
|
114
|
+
}
|
115
|
+
|
116
|
+
annotations_response = @pdf_api.get_document_annotations(file_name, opts)
|
117
|
+
assert(annotations_response, 'Failed to read document annotations.')
|
118
|
+
annotation_id = annotations_response[0].annotations.list[0].id
|
119
|
+
|
120
|
+
response = @pdf_api.delete_annotation(file_name, annotation_id, opts)
|
121
|
+
assert(response, 'Failed to delete annotation.')
|
122
|
+
end
|
123
|
+
|
124
|
+
# Free Text Annotations Tests
|
125
|
+
|
126
|
+
def test_get_document_free_text_annotations
|
127
|
+
file_name = 'PdfWithAnnotations.pdf'
|
128
|
+
upload_file(file_name)
|
129
|
+
|
130
|
+
opts = {
|
131
|
+
:folder => @temp_folder
|
132
|
+
}
|
133
|
+
|
134
|
+
response = @pdf_api.get_document_free_text_annotations(file_name, opts)
|
135
|
+
assert(response, 'Failed to read document free text annotations.')
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_post_page_free_text_annotations
|
139
|
+
file_name = 'PdfWithAnnotations.pdf'
|
140
|
+
upload_file(file_name)
|
141
|
+
|
142
|
+
opts = {
|
143
|
+
:folder => @temp_folder
|
144
|
+
}
|
145
|
+
|
146
|
+
text_style = TextStyle.new
|
147
|
+
text_style.font_size = 12
|
148
|
+
text_style.font = 'Arial'
|
149
|
+
text_style.foreground_color = Color.new({:A => 0xFF, :R => 0, :G => 0xFF, :B => 0})
|
150
|
+
text_style.background_color = Color.new({:A => 0xFF, :R => 0xFF, :G => 0, :B => 0})
|
151
|
+
|
152
|
+
annotation = FreeTextAnnotation.new
|
153
|
+
annotation.name = 'Test Free Text'
|
154
|
+
annotation.text_style = text_style
|
155
|
+
annotation.rect = RectanglePdf.new({:LLX => 100, :LLY => 100, :URX => 200, :URY => 200})
|
156
|
+
annotation.flags = [AnnotationFlags::DEFAULT]
|
157
|
+
annotation.horizontal_alignment = HorizontalAlignment::CENTER
|
158
|
+
annotation.intent = FreeTextIntent::FREE_TEXT_TYPE_WRITER
|
159
|
+
annotation.rich_text = 'Rich Text'
|
160
|
+
annotation.subject = 'Text Box Subj'
|
161
|
+
annotation.z_index = 1
|
162
|
+
annotation.justification = Justification::CENTER
|
163
|
+
annotation.title = 'Title'
|
164
|
+
|
165
|
+
response = @pdf_api.post_page_free_text_annotations(file_name, 1, [annotation], opts)
|
166
|
+
assert(response, 'Failed to add free text annotations into page.')
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_get_page_free_text_annotations
|
170
|
+
file_name = 'PdfWithAnnotations.pdf'
|
171
|
+
upload_file(file_name)
|
172
|
+
|
173
|
+
page_number = 1
|
174
|
+
opts = {
|
175
|
+
:folder => @temp_folder
|
176
|
+
}
|
177
|
+
|
178
|
+
response = @pdf_api.get_page_free_text_annotations(file_name, page_number, opts)
|
179
|
+
assert(response, 'Failed to read page free text annotations.')
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_get_free_text_annotation
|
183
|
+
file_name = 'PdfWithAnnotations.pdf'
|
184
|
+
upload_file(file_name)
|
185
|
+
|
186
|
+
opts = {
|
187
|
+
:folder => @temp_folder
|
188
|
+
}
|
189
|
+
|
190
|
+
annotations_response = @pdf_api.get_document_free_text_annotations(file_name, opts)
|
191
|
+
assert(annotations_response, 'Failed to read document free text annotations.')
|
192
|
+
annotation_id = annotations_response[0].annotations.list[0].id
|
193
|
+
|
194
|
+
response = @pdf_api.get_free_text_annotation(file_name, annotation_id, opts)
|
195
|
+
assert(response, 'Failed to read page free text annotations.')
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_put_free_text_annotation
|
199
|
+
file_name = 'PdfWithAnnotations.pdf'
|
200
|
+
upload_file(file_name)
|
201
|
+
|
202
|
+
opts = {
|
203
|
+
:folder => @temp_folder
|
204
|
+
}
|
205
|
+
|
206
|
+
text_style = TextStyle.new
|
207
|
+
text_style.font_size = 12
|
208
|
+
text_style.font = 'Arial'
|
209
|
+
text_style.foreground_color = Color.new({:A => 0xFF, :R => 0, :G => 0xFF, :B => 0})
|
210
|
+
text_style.background_color = Color.new({:A => 0xFF, :R => 0xFF, :G => 0, :B => 0})
|
211
|
+
|
212
|
+
annotation = FreeTextAnnotation.new
|
213
|
+
annotation.name = 'Test Free Text'
|
214
|
+
annotation.text_style = text_style
|
215
|
+
annotation.rect = RectanglePdf.new({:LLX => 100, :LLY => 100, :URX => 200, :URY => 200})
|
216
|
+
annotation.flags = [AnnotationFlags::DEFAULT]
|
217
|
+
annotation.horizontal_alignment = HorizontalAlignment::CENTER
|
218
|
+
annotation.intent = FreeTextIntent::FREE_TEXT_TYPE_WRITER
|
219
|
+
annotation.rich_text = 'Rich Text'
|
220
|
+
annotation.subject = 'Text Box Subj'
|
221
|
+
annotation.z_index = 1
|
222
|
+
annotation.justification = Justification::CENTER
|
223
|
+
annotation.title = 'Title'
|
224
|
+
|
225
|
+
annotations_response = @pdf_api.get_document_free_text_annotations(file_name, opts)
|
226
|
+
assert(annotations_response, 'Failed to read document free text annotations.')
|
227
|
+
annotation_id = annotations_response[0].annotations.list[0].id
|
228
|
+
|
229
|
+
response = @pdf_api.put_free_text_annotation(file_name, annotation_id, annotation, opts)
|
230
|
+
assert(response, 'Failed to replace free text annotation.')
|
231
|
+
end
|
232
|
+
|
233
|
+
|
234
|
+
# Text Annotations Tests
|
235
|
+
|
236
|
+
def test_get_document_text_annotations
|
237
|
+
file_name = 'PdfWithAnnotations.pdf'
|
238
|
+
upload_file(file_name)
|
239
|
+
|
240
|
+
opts = {
|
241
|
+
:folder => @temp_folder
|
242
|
+
}
|
243
|
+
|
244
|
+
response = @pdf_api.get_document_text_annotations(file_name, opts)
|
245
|
+
assert(response, 'Failed to read document text annotations.')
|
246
|
+
end
|
247
|
+
|
248
|
+
def test_post_page_text_annotations
|
249
|
+
file_name = 'PdfWithAnnotations.pdf'
|
250
|
+
upload_file(file_name)
|
251
|
+
|
252
|
+
opts = {
|
253
|
+
:folder => @temp_folder
|
254
|
+
}
|
255
|
+
|
256
|
+
annotation = TextAnnotation.new
|
257
|
+
annotation.name = 'Test Free Text'
|
258
|
+
annotation.rect = RectanglePdf.new({:LLX => 100, :LLY => 100, :URX => 200, :URY => 200})
|
259
|
+
annotation.flags = [AnnotationFlags::DEFAULT]
|
260
|
+
annotation.horizontal_alignment = HorizontalAlignment::CENTER
|
261
|
+
annotation.rich_text = 'Rich Text'
|
262
|
+
annotation.subject = 'Text Box Subj'
|
263
|
+
annotation.z_index = 1
|
264
|
+
annotation.state = AnnotationState::UNDEFINED
|
265
|
+
|
266
|
+
response = @pdf_api.post_page_text_annotations(file_name, 1, [annotation], opts)
|
267
|
+
assert(response, 'Failed to add text annotations into page.')
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_get_page_text_annotations
|
271
|
+
file_name = 'PdfWithAnnotations.pdf'
|
272
|
+
upload_file(file_name)
|
273
|
+
|
274
|
+
page_number = 1
|
275
|
+
opts = {
|
276
|
+
:folder => @temp_folder
|
277
|
+
}
|
278
|
+
|
279
|
+
response = @pdf_api.get_page_text_annotations(file_name, page_number, opts)
|
280
|
+
assert(response, 'Failed to read page text annotations.')
|
281
|
+
end
|
282
|
+
|
283
|
+
def test_get_text_annotation
|
284
|
+
file_name = 'PdfWithAnnotations.pdf'
|
285
|
+
upload_file(file_name)
|
286
|
+
|
287
|
+
opts = {
|
288
|
+
:folder => @temp_folder
|
289
|
+
}
|
290
|
+
|
291
|
+
annotations_response = @pdf_api.get_document_text_annotations(file_name, opts)
|
292
|
+
assert(annotations_response, 'Failed to read document text annotations.')
|
293
|
+
annotation_id = annotations_response[0].annotations.list[0].id
|
294
|
+
|
295
|
+
response = @pdf_api.get_text_annotation(file_name, annotation_id, opts)
|
296
|
+
assert(response, 'Failed to read page text annotations.')
|
297
|
+
end
|
298
|
+
|
299
|
+
def test_put_text_annotation
|
300
|
+
file_name = 'PdfWithAnnotations.pdf'
|
301
|
+
upload_file(file_name)
|
302
|
+
|
303
|
+
opts = {
|
304
|
+
:folder => @temp_folder
|
305
|
+
}
|
306
|
+
|
307
|
+
annotation = TextAnnotation.new
|
308
|
+
annotation.name = 'Test Free Text'
|
309
|
+
annotation.rect = RectanglePdf.new({:LLX => 100, :LLY => 100, :URX => 200, :URY => 200})
|
310
|
+
annotation.flags = [AnnotationFlags::DEFAULT]
|
311
|
+
annotation.horizontal_alignment = HorizontalAlignment::CENTER
|
312
|
+
annotation.rich_text = 'Rich Text'
|
313
|
+
annotation.subject = 'Text Box Subj'
|
314
|
+
annotation.z_index = 1
|
315
|
+
annotation.state = AnnotationState::UNDEFINED
|
316
|
+
|
317
|
+
annotations_response = @pdf_api.get_document_text_annotations(file_name, opts)
|
318
|
+
assert(annotations_response, 'Failed to read document text annotations.')
|
319
|
+
annotation_id = annotations_response[0].annotations.list[0].id
|
320
|
+
|
321
|
+
response = @pdf_api.put_text_annotation(file_name, annotation_id, annotation, opts)
|
322
|
+
assert(response, 'Failed to replace text annotation.')
|
323
|
+
end
|
324
|
+
|
70
325
|
|
71
326
|
# Append Tests
|
72
327
|
|
@@ -169,2220 +424,2136 @@ class PdfTests < Minitest::Test
|
|
169
424
|
end
|
170
425
|
|
171
426
|
|
172
|
-
#
|
427
|
+
# Convert Tests
|
173
428
|
|
174
|
-
def
|
429
|
+
def test_get_pdf_in_storage_to_doc
|
175
430
|
file_name = '4pages.pdf'
|
176
431
|
upload_file(file_name)
|
177
432
|
|
178
433
|
opts = {
|
179
|
-
:result_file => '4pages.tiff',
|
180
|
-
:brightness => 0.6,
|
181
|
-
:compression => CompressionType::CCITT4,
|
182
|
-
:color_depth => ColorDepth::FORMAT1BPP,
|
183
|
-
:left_margin => 0,
|
184
|
-
:right_margin => 0,
|
185
|
-
:top_margin => 0,
|
186
|
-
:bottom_margin => 0,
|
187
|
-
:orientation => ShapeType::PORTRAIT,
|
188
|
-
:skip_blank_pages => true,
|
189
|
-
:width => 1200,
|
190
|
-
:height => 1600,
|
191
|
-
:x_resolution => 200,
|
192
|
-
:y_resolution => 200,
|
193
|
-
:page_index => 2,
|
194
|
-
:page_count=> 2,
|
195
434
|
:folder => @temp_folder
|
196
435
|
}
|
197
436
|
|
198
|
-
response = @pdf_api.
|
199
|
-
assert(response, '
|
437
|
+
response = @pdf_api.get_pdf_in_storage_to_doc(file_name, opts)
|
438
|
+
assert(response, 'Filed to convert PDF to DOC.')
|
200
439
|
end
|
201
440
|
|
202
|
-
|
203
|
-
def test_put_document_save_as_tiff_using_body_params
|
441
|
+
def test_put_pdf_in_storage_to_doc
|
204
442
|
file_name = '4pages.pdf'
|
205
443
|
upload_file(file_name)
|
206
|
-
|
207
|
-
export_options = TiffExportOptions.new
|
208
|
-
export_options.result_file = '4pages.tiff'
|
209
|
-
export_options.brightness = 0.6
|
210
|
-
export_options.compression = CompressionType::CCITT4
|
211
|
-
export_options.color_depth = ColorDepth::FORMAT1BPP
|
212
|
-
export_options.left_margin = 0
|
213
|
-
export_options.right_margin = 0
|
214
|
-
export_options.top_margin = 0
|
215
|
-
export_options.bottom_margin = 0
|
216
|
-
export_options.orientation = ShapeType::PORTRAIT
|
217
|
-
export_options.skip_blank_pages = true
|
218
|
-
export_options.width = 1200
|
219
|
-
export_options.height = 1600
|
220
|
-
export_options.x_resolution = 200
|
221
|
-
export_options.y_resolution = 200
|
222
|
-
export_options.page_index = 2
|
223
|
-
export_options.page_count = 2
|
444
|
+
res_file = 'result.doc'
|
224
445
|
|
225
446
|
opts = {
|
226
|
-
:export_options => export_options,
|
227
447
|
:folder => @temp_folder
|
228
448
|
}
|
229
|
-
|
230
|
-
response
|
231
|
-
assert(response, 'Failed to save document as Tiff image')
|
449
|
+
response = @pdf_api.put_pdf_in_storage_to_doc(file_name, @temp_folder + '/' + res_file, opts)
|
450
|
+
assert(response, 'Filed to convert PDF to DOC.')
|
232
451
|
end
|
233
452
|
|
234
|
-
|
235
|
-
# Document Tests
|
236
|
-
|
237
|
-
def test_get_document
|
453
|
+
def test_put_pdf_in_request_to_doc
|
238
454
|
file_name = '4pages.pdf'
|
239
|
-
|
455
|
+
|
456
|
+
res_file = 'result.doc'
|
240
457
|
|
241
458
|
opts = {
|
242
|
-
:
|
459
|
+
:file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
460
|
+
# :file => @test_data_folder + file_name
|
243
461
|
}
|
244
|
-
|
245
|
-
response
|
246
|
-
assert(response, 'Failed to read common document info.')
|
462
|
+
response = @pdf_api.put_pdf_in_request_to_tiff(@temp_folder + '/' + res_file, opts)
|
463
|
+
assert(response, 'Filed to convert PDF to DOC.')
|
247
464
|
end
|
248
465
|
|
249
|
-
|
250
|
-
def test_post_optimize_document
|
466
|
+
def test_get_pdf_in_storage_to_pdf_a
|
251
467
|
file_name = '4pages.pdf'
|
252
468
|
upload_file(file_name)
|
253
469
|
|
254
|
-
optimize_options = OptimizeOptions.new
|
255
|
-
optimize_options.allow_reuse_page_content = false
|
256
|
-
optimize_options.compress_images = true
|
257
|
-
optimize_options.image_quality = 100
|
258
|
-
optimize_options.link_duplcate_streams = true
|
259
|
-
optimize_options.remove_unused_objects = true
|
260
|
-
optimize_options.remove_unused_streams = true
|
261
|
-
optimize_options.unembed_fonts = true
|
262
|
-
|
263
470
|
opts = {
|
264
|
-
|
265
|
-
:folder => @temp_folder
|
471
|
+
:folder => @temp_folder
|
266
472
|
}
|
267
473
|
|
268
|
-
response = @pdf_api.
|
269
|
-
assert(response, '
|
474
|
+
response = @pdf_api.get_pdf_in_storage_to_pdf_a(file_name, PdfAType::PDFA1_A, opts)
|
475
|
+
assert(response, 'Filed to convert PDF to PDFA.')
|
270
476
|
end
|
271
477
|
|
272
|
-
|
273
|
-
def test_post_split_document
|
478
|
+
def test_put_pdf_in_storage_to_pdf_a
|
274
479
|
file_name = '4pages.pdf'
|
275
480
|
upload_file(file_name)
|
481
|
+
res_file = 'result.pdf'
|
276
482
|
|
277
483
|
opts = {
|
278
484
|
:folder => @temp_folder
|
279
485
|
}
|
280
|
-
response = @pdf_api.
|
281
|
-
assert(response, '
|
486
|
+
response = @pdf_api.put_pdf_in_storage_to_pdf_a(file_name, @temp_folder + '/' + res_file, PdfAType::PDFA1_A, opts)
|
487
|
+
assert(response, 'Filed to convert PDF to PDFA.')
|
282
488
|
end
|
283
489
|
|
490
|
+
def test_put_pdf_in_request_to_pdf_a
|
491
|
+
file_name = '4pages.pdf'
|
284
492
|
|
285
|
-
|
286
|
-
url = 'http://pdf995.com/samples/pdf.pdf'
|
287
|
-
format = 'tiff'
|
493
|
+
res_file = 'result.pdf'
|
288
494
|
|
289
495
|
opts = {
|
290
|
-
:
|
291
|
-
:url => url
|
496
|
+
:file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
292
497
|
}
|
293
|
-
|
294
|
-
response
|
295
|
-
assert(response, 'Failed to convert document from request content to format specified')
|
498
|
+
response = @pdf_api.put_pdf_in_request_to_pdf_a(@temp_folder + '/' + res_file, PdfAType::PDFA1_A, opts)
|
499
|
+
assert(response, 'Filed to convert PDF to PDFA.')
|
296
500
|
end
|
297
501
|
|
298
|
-
|
299
|
-
|
300
|
-
file_name
|
502
|
+
def test_get_pdf_in_storage_to_tiff
|
503
|
+
file_name = '4pages.pdf'
|
504
|
+
upload_file(file_name)
|
301
505
|
|
302
506
|
opts = {
|
303
507
|
:folder => @temp_folder
|
304
508
|
}
|
305
509
|
|
306
|
-
response = @pdf_api.
|
307
|
-
assert(response, '
|
510
|
+
response = @pdf_api.get_pdf_in_storage_to_tiff(file_name, opts)
|
511
|
+
assert(response, 'Filed to convert PDF to Tiff.')
|
308
512
|
end
|
309
513
|
|
310
|
-
|
311
|
-
|
312
|
-
file_name
|
313
|
-
|
314
|
-
|
315
|
-
upload_file(template_name)
|
514
|
+
def test_put_pdf_in_storage_to_tiff
|
515
|
+
file_name = '4pages.pdf'
|
516
|
+
upload_file(file_name)
|
517
|
+
res_file = 'result.tiff'
|
316
518
|
|
317
519
|
opts = {
|
318
|
-
:template_file => @temp_folder + '/' + template_name,
|
319
|
-
:template_type => 'html',
|
320
520
|
:folder => @temp_folder
|
321
521
|
}
|
322
|
-
|
323
|
-
response
|
324
|
-
assert(response, 'Failed to create document from HTML template.')
|
522
|
+
response = @pdf_api.put_pdf_in_storage_to_tiff(file_name, @temp_folder + '/' + res_file, opts)
|
523
|
+
assert(response, 'Filed to convert PDF to Tiff.')
|
325
524
|
end
|
326
525
|
|
526
|
+
def test_put_pdf_in_request_to_tiff
|
527
|
+
file_name = '4pages.pdf'
|
327
528
|
|
328
|
-
|
329
|
-
image_1 = '33539.jpg'
|
330
|
-
upload_file(image_1)
|
331
|
-
|
332
|
-
image_2 = '44781.jpg'
|
333
|
-
upload_file(image_2)
|
334
|
-
|
335
|
-
result_doc_name = 'pdffromimagesinquery.pdf'
|
336
|
-
|
337
|
-
images = ImagesListRequest.new
|
338
|
-
images.images_list = [ @temp_folder + '/' + image_1, @temp_folder + '/' + image_2]
|
529
|
+
res_file = 'result.pdf'
|
339
530
|
|
340
531
|
opts = {
|
341
|
-
:
|
342
|
-
:ocr => false,
|
343
|
-
:folder => @temp_folder
|
532
|
+
:file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
344
533
|
}
|
345
|
-
|
346
|
-
response
|
347
|
-
assert(response, 'Failed to create document from Images.')
|
534
|
+
response = @pdf_api.put_pdf_in_request_to_tiff(@temp_folder + '/' + res_file, opts)
|
535
|
+
assert(response, 'Filed to convert PDF to Tiff.')
|
348
536
|
end
|
349
537
|
|
350
|
-
|
351
|
-
|
352
|
-
def test_get_field
|
353
|
-
file_name = 'PdfWithAcroForm.pdf'
|
538
|
+
def test_get_pdf_in_storage_to_svg
|
539
|
+
file_name = '4pages.pdf'
|
354
540
|
upload_file(file_name)
|
355
541
|
|
356
542
|
opts = {
|
357
543
|
:folder => @temp_folder
|
358
544
|
}
|
359
|
-
field_name = 'textField'
|
360
545
|
|
361
|
-
response = @pdf_api.
|
362
|
-
assert(response, '
|
546
|
+
response = @pdf_api.get_pdf_in_storage_to_svg(file_name, opts)
|
547
|
+
assert(response, 'Filed to convert PDF to SVG.')
|
363
548
|
end
|
364
549
|
|
365
|
-
|
366
|
-
|
367
|
-
file_name = 'PdfWithAcroForm.pdf'
|
550
|
+
def test_put_pdf_in_storage_to_svg
|
551
|
+
file_name = '4pages.pdf'
|
368
552
|
upload_file(file_name)
|
553
|
+
res_file = 'result.svg'
|
369
554
|
|
370
555
|
opts = {
|
371
556
|
:folder => @temp_folder
|
372
557
|
}
|
373
|
-
|
374
|
-
response
|
375
|
-
assert(response, 'Failed to get document fields.')
|
558
|
+
response = @pdf_api.put_pdf_in_storage_to_svg(file_name, @temp_folder + '/' + res_file, opts)
|
559
|
+
assert(response, 'Filed to convert PDF to SVG.')
|
376
560
|
end
|
377
561
|
|
562
|
+
def test_put_pdf_in_request_to_svg
|
563
|
+
file_name = '4pages.pdf'
|
378
564
|
|
379
|
-
|
380
|
-
file_name = 'Hello_world.pdf'
|
381
|
-
upload_file(file_name)
|
382
|
-
|
383
|
-
rect = Rectangle.new
|
384
|
-
rect.x = 50
|
385
|
-
rect.y = 200
|
386
|
-
rect.width = 150
|
387
|
-
rect.height = 200
|
388
|
-
|
389
|
-
field = Field.new
|
390
|
-
field.name = 'checkboxfield'
|
391
|
-
field.values = ['1']
|
392
|
-
field.type = 'Boolean'
|
393
|
-
field.rect = rect
|
394
|
-
|
395
|
-
page_number = 1
|
565
|
+
res_file = 'result.svg'
|
396
566
|
|
397
567
|
opts = {
|
398
|
-
:
|
399
|
-
:folder => @temp_folder
|
568
|
+
:file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
400
569
|
}
|
401
|
-
|
402
|
-
response
|
403
|
-
assert(response, 'Failed to create field.')
|
570
|
+
response = @pdf_api.put_pdf_in_request_to_svg(@temp_folder + '/' + res_file, opts)
|
571
|
+
assert(response, 'Filed to convert PDF to SVG.')
|
404
572
|
end
|
405
573
|
|
406
|
-
|
407
|
-
|
408
|
-
file_name = 'PdfWithAcroForm.pdf'
|
574
|
+
def test_get_pdf_in_storage_to_xps
|
575
|
+
file_name = '4pages.pdf'
|
409
576
|
upload_file(file_name)
|
410
577
|
|
411
|
-
field_name = 'textField'
|
412
|
-
|
413
|
-
field = Field.new
|
414
|
-
field.name = field_name
|
415
|
-
field.values = ['Text field updated value.']
|
416
|
-
field.type = FieldType::TEXT
|
417
|
-
|
418
578
|
opts = {
|
419
|
-
:field => field,
|
420
579
|
:folder => @temp_folder
|
421
580
|
}
|
422
581
|
|
423
|
-
response = @pdf_api.
|
424
|
-
assert(response, '
|
582
|
+
response = @pdf_api.get_pdf_in_storage_to_xps(file_name, opts)
|
583
|
+
assert(response, 'Filed to convert PDF to XPS.')
|
425
584
|
end
|
426
585
|
|
427
|
-
|
428
|
-
|
429
|
-
file_name = 'PdfWithAcroForm.pdf'
|
586
|
+
def test_put_pdf_in_storage_to_xps
|
587
|
+
file_name = '4pages.pdf'
|
430
588
|
upload_file(file_name)
|
431
|
-
|
432
|
-
field_name = 'textField'
|
589
|
+
res_file = 'result.xps'
|
433
590
|
|
434
591
|
opts = {
|
435
592
|
:folder => @temp_folder
|
436
593
|
}
|
437
|
-
|
438
|
-
response
|
439
|
-
assert(response, 'Failed to delete fields.')
|
594
|
+
response = @pdf_api.put_pdf_in_storage_to_xps(file_name, @temp_folder + '/' + res_file, opts)
|
595
|
+
assert(response, 'Filed to convert PDF to XPS.')
|
440
596
|
end
|
441
597
|
|
598
|
+
def test_put_pdf_in_request_to_xps
|
599
|
+
file_name = '4pages.pdf'
|
442
600
|
|
443
|
-
|
444
|
-
file_name = 'PdfWithAcroForm.pdf'
|
445
|
-
upload_file(file_name)
|
601
|
+
res_file = 'result.xps'
|
446
602
|
|
447
603
|
opts = {
|
448
|
-
:
|
604
|
+
:file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
449
605
|
}
|
450
|
-
|
451
|
-
response
|
452
|
-
assert(response, 'Failed to make fields flatten.')
|
606
|
+
response = @pdf_api.put_pdf_in_request_to_xps(@temp_folder + '/' + res_file, opts)
|
607
|
+
assert(response, 'Filed to convert PDF to XPS.')
|
453
608
|
end
|
454
609
|
|
455
|
-
|
456
|
-
# Fragments And Segments Tests
|
457
|
-
|
458
|
-
def test_get_fragment
|
610
|
+
def test_get_pdf_in_storage_to_xls
|
459
611
|
file_name = '4pages.pdf'
|
460
612
|
upload_file(file_name)
|
461
613
|
|
462
|
-
page_number = 1
|
463
|
-
fragment_number = 1
|
464
|
-
|
465
614
|
opts = {
|
466
615
|
:folder => @temp_folder
|
467
616
|
}
|
468
617
|
|
469
|
-
response = @pdf_api.
|
470
|
-
assert(response, '
|
618
|
+
response = @pdf_api.get_pdf_in_storage_to_xls(file_name, opts)
|
619
|
+
assert(response, 'Filed to convert PDF to XLS.')
|
471
620
|
end
|
472
621
|
|
473
|
-
def
|
622
|
+
def test_put_pdf_in_storage_to_xls
|
474
623
|
file_name = '4pages.pdf'
|
475
624
|
upload_file(file_name)
|
476
|
-
|
477
|
-
page_number = 1
|
478
|
-
fragment_number = 1
|
625
|
+
res_file = 'result.xls'
|
479
626
|
|
480
627
|
opts = {
|
481
628
|
:folder => @temp_folder
|
482
629
|
}
|
483
|
-
|
484
|
-
response
|
485
|
-
assert(response, 'Failed to read page fragment text format.')
|
630
|
+
response = @pdf_api.put_pdf_in_storage_to_xls(file_name, @temp_folder + '/' + res_file, opts)
|
631
|
+
assert(response, 'Filed to convert PDF to XLS.')
|
486
632
|
end
|
487
633
|
|
488
|
-
|
489
|
-
def test_get_fragments
|
634
|
+
def test_put_pdf_in_request_to_xls
|
490
635
|
file_name = '4pages.pdf'
|
491
|
-
upload_file(file_name)
|
492
636
|
|
493
|
-
|
637
|
+
res_file = 'result.xls'
|
494
638
|
|
495
639
|
opts = {
|
496
|
-
:
|
640
|
+
:file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
497
641
|
}
|
498
|
-
response = @pdf_api.
|
499
|
-
assert(response, '
|
642
|
+
response = @pdf_api.put_pdf_in_request_to_xls(@temp_folder + '/' + res_file, opts)
|
643
|
+
assert(response, 'Filed to convert PDF to XLS.')
|
500
644
|
end
|
501
645
|
|
502
|
-
|
503
|
-
def test_get_segment
|
646
|
+
def test_get_pdf_in_storage_to_html
|
504
647
|
file_name = '4pages.pdf'
|
505
648
|
upload_file(file_name)
|
506
649
|
|
507
|
-
page_number = 1
|
508
|
-
fragment_number = 1
|
509
|
-
segment_number = 1
|
510
|
-
|
511
650
|
opts = {
|
512
651
|
:folder => @temp_folder
|
513
652
|
}
|
514
653
|
|
515
|
-
response = @pdf_api.
|
516
|
-
assert(response, '
|
654
|
+
response = @pdf_api.get_pdf_in_storage_to_html(file_name, opts)
|
655
|
+
assert(response, 'Filed to convert PDF to HTML.')
|
517
656
|
end
|
518
657
|
|
519
|
-
|
520
|
-
def test_get_segment_text_format
|
658
|
+
def test_put_pdf_in_storage_to_html
|
521
659
|
file_name = '4pages.pdf'
|
522
660
|
upload_file(file_name)
|
523
|
-
|
524
|
-
page_number = 1
|
525
|
-
fragment_number = 1
|
526
|
-
segment_number = 1
|
661
|
+
res_file = 'result.zip'
|
527
662
|
|
528
663
|
opts = {
|
529
664
|
:folder => @temp_folder
|
530
665
|
}
|
531
|
-
|
532
|
-
response
|
533
|
-
assert(response, 'Failed to read segment text format.')
|
666
|
+
response = @pdf_api.put_pdf_in_storage_to_html(file_name, @temp_folder + '/' + res_file, opts)
|
667
|
+
assert(response, 'Filed to convert PDF to HTML.')
|
534
668
|
end
|
535
669
|
|
536
|
-
|
537
|
-
def test_get_segments
|
670
|
+
def test_put_pdf_in_request_to_html
|
538
671
|
file_name = '4pages.pdf'
|
539
|
-
upload_file(file_name)
|
540
672
|
|
541
|
-
|
542
|
-
fragment_number = 1
|
673
|
+
res_file = 'result.zip'
|
543
674
|
|
544
675
|
opts = {
|
545
|
-
:
|
676
|
+
:file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
546
677
|
}
|
547
|
-
|
548
|
-
response
|
549
|
-
assert(response, 'Failed to read fragment segments.')
|
678
|
+
response = @pdf_api.put_pdf_in_request_to_html(@temp_folder + '/' + res_file, opts)
|
679
|
+
assert(response, 'Filed to convert PDF to HTML.')
|
550
680
|
end
|
551
681
|
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
def test_get_image
|
556
|
-
file_name = 'PdfWithImages2.pdf'
|
682
|
+
def test_get_pdf_in_storage_to_epub
|
683
|
+
file_name = '4pages.pdf'
|
557
684
|
upload_file(file_name)
|
558
685
|
|
559
|
-
page_number = 1
|
560
|
-
image_number = 1
|
561
686
|
opts = {
|
562
687
|
:folder => @temp_folder
|
563
688
|
}
|
564
689
|
|
565
|
-
response = @pdf_api.
|
566
|
-
assert(response, '
|
690
|
+
response = @pdf_api.get_pdf_in_storage_to_epub(file_name, opts)
|
691
|
+
assert(response, 'Filed to convert PDF to EPUB.')
|
567
692
|
end
|
568
693
|
|
569
|
-
def
|
570
|
-
file_name = '
|
694
|
+
def test_put_pdf_in_storage_to_epub
|
695
|
+
file_name = '4pages.pdf'
|
571
696
|
upload_file(file_name)
|
697
|
+
res_file = 'result.epub'
|
572
698
|
|
573
|
-
page_number = 1
|
574
|
-
image_number = 1
|
575
699
|
opts = {
|
576
|
-
:format => 'jpeg',
|
577
|
-
:height => 100,
|
578
|
-
:width => 100,
|
579
700
|
:folder => @temp_folder
|
580
701
|
}
|
581
|
-
|
582
|
-
response
|
583
|
-
assert(response, 'Failed to read document image by number.')
|
702
|
+
response = @pdf_api.put_pdf_in_storage_to_epub(file_name, @temp_folder + '/' + res_file, opts)
|
703
|
+
assert(response, 'Filed to convert PDF to EPUB.')
|
584
704
|
end
|
585
705
|
|
586
|
-
def
|
587
|
-
file_name = '
|
588
|
-
|
706
|
+
def test_put_pdf_in_request_to_epub
|
707
|
+
file_name = '4pages.pdf'
|
708
|
+
|
709
|
+
res_file = 'result.epub'
|
589
710
|
|
590
|
-
page_number = 1
|
591
711
|
opts = {
|
592
|
-
:
|
712
|
+
:file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
593
713
|
}
|
594
|
-
|
595
|
-
response
|
596
|
-
assert(response, 'Failed to read document images.')
|
714
|
+
response = @pdf_api.put_pdf_in_request_to_epub(@temp_folder + '/' + res_file, opts)
|
715
|
+
assert(response, 'Filed to convert PDF to EPUB.')
|
597
716
|
end
|
598
717
|
|
599
|
-
|
600
|
-
|
601
|
-
file_name = 'PdfWithImages2.pdf'
|
718
|
+
def test_get_pdf_in_storage_to_pptx
|
719
|
+
file_name = '4pages.pdf'
|
602
720
|
upload_file(file_name)
|
603
721
|
|
604
|
-
image_file_name = 'Koala.jpg'
|
605
|
-
upload_file(image_file_name)
|
606
|
-
|
607
|
-
page_number = 1
|
608
|
-
image_number = 1
|
609
722
|
opts = {
|
610
|
-
:image_file => @temp_folder + '/' + image_file_name,
|
611
723
|
:folder => @temp_folder
|
612
724
|
}
|
613
725
|
|
614
|
-
response = @pdf_api.
|
615
|
-
assert(response, '
|
726
|
+
response = @pdf_api.get_pdf_in_storage_to_pptx(file_name, opts)
|
727
|
+
assert(response, 'Filed to convert PDF to PPTX.')
|
616
728
|
end
|
617
729
|
|
618
|
-
def
|
619
|
-
file_name = '
|
730
|
+
def test_put_pdf_in_storage_to_pptx
|
731
|
+
file_name = '4pages.pdf'
|
620
732
|
upload_file(file_name)
|
733
|
+
res_file = 'result.pptx'
|
621
734
|
|
622
|
-
image_file_name = 'Koala.jpg'
|
623
|
-
page_number = 1
|
624
|
-
image_number = 1
|
625
735
|
opts = {
|
626
|
-
:image => File.open(@test_data_folder + image_file_name, 'r') { |io| io.read(io.size) },
|
627
736
|
:folder => @temp_folder
|
628
737
|
}
|
629
|
-
response = @pdf_api.
|
630
|
-
assert(response, '
|
738
|
+
response = @pdf_api.put_pdf_in_storage_to_pptx(file_name, @temp_folder + '/' + res_file, opts)
|
739
|
+
assert(response, 'Filed to convert PDF to PPTX.')
|
631
740
|
end
|
632
741
|
|
633
|
-
def test_put_images_extract_as_jpeg
|
634
|
-
name = "PdfWithImages2.pdf"
|
635
|
-
upload_file(name)
|
636
|
-
page_number = 1
|
637
742
|
|
638
|
-
|
743
|
+
def test_put_pdf_in_request_to_pptx
|
744
|
+
file_name = '4pages.pdf'
|
745
|
+
|
746
|
+
res_file = 'result.pptx'
|
747
|
+
|
639
748
|
opts = {
|
640
|
-
:
|
641
|
-
:folder => @temp_folder
|
749
|
+
:file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
642
750
|
}
|
643
|
-
response = @pdf_api.
|
644
|
-
assert(response, '
|
751
|
+
response = @pdf_api.put_pdf_in_request_to_pptx(@temp_folder + '/' + res_file, opts)
|
752
|
+
assert(response, 'Filed to convert PDF to PPTX.')
|
645
753
|
end
|
646
754
|
|
647
|
-
def
|
648
|
-
|
649
|
-
upload_file(
|
650
|
-
page_number = 1
|
755
|
+
def test_get_pdf_in_storage_to_la_te_x
|
756
|
+
file_name = '4pages.pdf'
|
757
|
+
upload_file(file_name)
|
651
758
|
|
652
|
-
dest_folder = "extract_tiff"
|
653
759
|
opts = {
|
654
|
-
:dest_folder => @temp_folder + '/' + dest_folder,
|
655
760
|
:folder => @temp_folder
|
656
761
|
}
|
657
|
-
|
658
|
-
|
762
|
+
|
763
|
+
response = @pdf_api.get_pdf_in_storage_to_la_te_x(file_name, opts)
|
764
|
+
assert(response, 'Filed to convert PDF to LaTex.')
|
659
765
|
end
|
660
766
|
|
661
|
-
def
|
662
|
-
|
663
|
-
upload_file(
|
664
|
-
|
767
|
+
def test_put_pdf_in_storage_to_la_te_x
|
768
|
+
file_name = '4pages.pdf'
|
769
|
+
upload_file(file_name)
|
770
|
+
res_file = 'result.latex'
|
665
771
|
|
666
|
-
dest_folder = "extract_gif"
|
667
772
|
opts = {
|
668
|
-
:dest_folder => @temp_folder + '/' + dest_folder,
|
669
773
|
:folder => @temp_folder
|
670
774
|
}
|
671
|
-
response = @pdf_api.
|
672
|
-
assert(response, '
|
775
|
+
response = @pdf_api.put_pdf_in_storage_to_la_te_x(file_name, @temp_folder + '/' + res_file, opts)
|
776
|
+
assert(response, 'Filed to convert PDF to LaTeX.')
|
673
777
|
end
|
674
778
|
|
675
|
-
def test_put_images_extract_as_png
|
676
|
-
name = "PdfWithImages2.pdf"
|
677
|
-
upload_file(name)
|
678
|
-
page_number = 1
|
679
779
|
|
680
|
-
|
780
|
+
def test_put_pdf_in_request_to_la_te_x
|
781
|
+
file_name = '4pages.pdf'
|
782
|
+
|
783
|
+
res_file = 'result.latex'
|
784
|
+
|
681
785
|
opts = {
|
682
|
-
:
|
683
|
-
:folder => @temp_folder
|
786
|
+
:file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
684
787
|
}
|
685
|
-
response = @pdf_api.
|
686
|
-
assert(response, '
|
788
|
+
response = @pdf_api.put_pdf_in_request_to_la_te_x(@temp_folder + '/' + res_file, opts)
|
789
|
+
assert(response, 'Filed to convert PDF to LaTeX.')
|
687
790
|
end
|
688
791
|
|
689
|
-
|
690
|
-
|
691
|
-
def test_get_page_link_annotation_by_index
|
692
|
-
file_name = 'PdfWithLinks.pdf'
|
792
|
+
def test_get_pdf_in_storage_to_mobi_xml
|
793
|
+
file_name = '4pages.pdf'
|
693
794
|
upload_file(file_name)
|
694
795
|
|
695
|
-
page_number = 1
|
696
|
-
link_index = 1
|
697
796
|
opts = {
|
698
797
|
:folder => @temp_folder
|
699
798
|
}
|
700
799
|
|
701
|
-
response = @pdf_api.
|
702
|
-
assert(response, '
|
800
|
+
response = @pdf_api.get_pdf_in_storage_to_mobi_xml(file_name, opts)
|
801
|
+
assert(response, 'Filed to convert PDF to Moby Xml.')
|
703
802
|
end
|
704
803
|
|
705
|
-
def
|
706
|
-
file_name = '
|
804
|
+
def test_put_pdf_in_storage_to_mobi_xml
|
805
|
+
file_name = '4pages.pdf'
|
707
806
|
upload_file(file_name)
|
807
|
+
res_file = 'result.mobi'
|
708
808
|
|
709
|
-
page_number = 1
|
710
809
|
opts = {
|
711
810
|
:folder => @temp_folder
|
712
811
|
}
|
713
|
-
|
714
|
-
response
|
715
|
-
assert(response, 'Failed to read document page link annotations.')
|
812
|
+
response = @pdf_api.put_pdf_in_storage_to_mobi_xml(file_name, @temp_folder + '/' + res_file, opts)
|
813
|
+
assert(response, 'Filed to convert PDF to Moby Xml.')
|
716
814
|
end
|
717
815
|
|
718
816
|
|
719
|
-
|
817
|
+
def test_put_pdf_in_request_to_mobi_xml
|
818
|
+
file_name = '4pages.pdf'
|
720
819
|
|
721
|
-
|
722
|
-
file_name_list = ['4pages.pdf', 'PdfWithImages2.pdf', 'marketing.pdf']
|
723
|
-
file_name_list.each { |file_name| upload_file(file_name)}
|
820
|
+
res_file = 'result.mobi'
|
724
821
|
|
725
|
-
|
726
|
-
|
727
|
-
|
822
|
+
opts = {
|
823
|
+
:file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
824
|
+
}
|
825
|
+
response = @pdf_api.put_pdf_in_request_to_mobi_xml(@temp_folder + '/' + res_file, opts)
|
826
|
+
assert(response, 'Filed to convert PDF to Moby Xml.')
|
827
|
+
end
|
728
828
|
|
729
|
-
|
730
|
-
|
829
|
+
def test_get_xfa_pdf_in_storage_to_acro_form
|
830
|
+
file_name = 'PdfWithXfaForm.pdf'
|
831
|
+
upload_file(file_name)
|
731
832
|
|
732
833
|
opts = {
|
733
|
-
:merge_documents => merge_documents,
|
734
834
|
:folder => @temp_folder
|
735
835
|
}
|
736
836
|
|
737
|
-
response = @pdf_api.
|
738
|
-
assert(response, '
|
837
|
+
response = @pdf_api.get_xfa_pdf_in_storage_to_acro_form(file_name, opts)
|
838
|
+
assert(response, 'Filed to convert Xfa PDF to Acro form.')
|
739
839
|
end
|
740
840
|
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
def test_delete_page
|
745
|
-
file_name = '4pages.pdf'
|
841
|
+
def test_put_xfa_pdf_in_storage_to_acro_form
|
842
|
+
file_name = 'PdfWithXfaForm.pdf'
|
746
843
|
upload_file(file_name)
|
844
|
+
res_file = 'result.pdf'
|
747
845
|
|
748
|
-
page_number = 1
|
749
846
|
opts = {
|
750
847
|
:folder => @temp_folder
|
751
848
|
}
|
752
|
-
|
753
|
-
response
|
754
|
-
assert(response, 'Failed to delete document page by its number.')
|
849
|
+
response = @pdf_api.put_xfa_pdf_in_storage_to_acro_form(file_name, @temp_folder + '/' + res_file, opts)
|
850
|
+
assert(response, 'Filed to convert Xfa PDF to Acro form.')
|
755
851
|
end
|
756
852
|
|
757
853
|
|
758
|
-
def
|
759
|
-
file_name = '
|
760
|
-
|
854
|
+
def test_put_xfa_pdf_in_request_to_acro_form
|
855
|
+
file_name = 'PdfWithXfaForm.pdf'
|
856
|
+
|
857
|
+
res_file = 'result.pdf'
|
761
858
|
|
762
|
-
page_number = 3
|
763
859
|
opts = {
|
764
|
-
:
|
860
|
+
:file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
765
861
|
}
|
766
|
-
|
767
|
-
response
|
768
|
-
assert(response, 'Failed to get document page by its number.')
|
862
|
+
response = @pdf_api.put_xfa_pdf_in_request_to_acro_form(@temp_folder + '/' + res_file, opts)
|
863
|
+
assert(response, 'Filed to convert Xfa PDF to Acro form.')
|
769
864
|
end
|
770
865
|
|
771
|
-
|
866
|
+
|
867
|
+
def test_get_pdf_in_storage_to_xml
|
772
868
|
file_name = '4pages.pdf'
|
773
869
|
upload_file(file_name)
|
774
870
|
|
775
|
-
page_number = 3
|
776
871
|
opts = {
|
777
|
-
:format => 'jpeg',
|
778
|
-
:width => 100,
|
779
|
-
:height => 100,
|
780
872
|
:folder => @temp_folder
|
781
873
|
}
|
782
874
|
|
783
|
-
response = @pdf_api.
|
784
|
-
assert(response, '
|
875
|
+
response = @pdf_api.get_pdf_in_storage_to_xml(file_name, opts)
|
876
|
+
assert(response, 'Filed to convert PDF to Xml.')
|
785
877
|
end
|
786
878
|
|
787
|
-
def
|
879
|
+
def test_put_pdf_in_storage_to_xml
|
788
880
|
file_name = '4pages.pdf'
|
789
881
|
upload_file(file_name)
|
882
|
+
res_file = 'result.xml'
|
790
883
|
|
791
884
|
opts = {
|
792
885
|
:folder => @temp_folder
|
793
886
|
}
|
794
|
-
|
795
|
-
response
|
796
|
-
assert(response, 'Failed to read document pages info.')
|
887
|
+
response = @pdf_api.put_pdf_in_storage_to_xml(file_name, @temp_folder + '/' + res_file, opts)
|
888
|
+
assert(response, 'Filed to convert PDF to Xml.')
|
797
889
|
end
|
798
890
|
|
799
891
|
|
800
|
-
def
|
892
|
+
def test_put_pdf_in_request_to_xml
|
801
893
|
file_name = '4pages.pdf'
|
802
|
-
|
894
|
+
|
895
|
+
res_file = 'result.xml'
|
803
896
|
|
804
897
|
opts = {
|
805
|
-
:
|
898
|
+
:file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
806
899
|
}
|
807
|
-
|
808
|
-
response
|
809
|
-
assert(response, 'Failed to get number of words per document page.')
|
900
|
+
response = @pdf_api.put_pdf_in_request_to_xml(@temp_folder + '/' + res_file, opts)
|
901
|
+
assert(response, 'Filed to convert PDF to Xml.')
|
810
902
|
end
|
811
903
|
|
812
904
|
|
813
|
-
|
814
|
-
file_name = '4pages.pdf'
|
815
|
-
upload_file(file_name)
|
905
|
+
# Convert to PDF Tests
|
816
906
|
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
page_number = 1
|
821
|
-
new_index = 1
|
907
|
+
def test_get_epub_in_storage_to_pdf
|
908
|
+
file_name = '4pages.epub'
|
909
|
+
upload_file(file_name)
|
822
910
|
|
823
|
-
|
824
|
-
|
911
|
+
src_path = @temp_folder + '/' + file_name
|
912
|
+
response = @pdf_api.get_epub_in_storage_to_pdf(src_path)
|
913
|
+
assert(response, 'Failed to convert epub to pdf.')
|
825
914
|
end
|
826
915
|
|
827
|
-
|
828
|
-
|
829
|
-
file_name = '4pages.pdf'
|
916
|
+
def test_put_epub_in_storage_to_pdf
|
917
|
+
file_name = '4pages.epub'
|
830
918
|
upload_file(file_name)
|
919
|
+
result_name = 'fromEpub.pdf'
|
831
920
|
|
921
|
+
src_path = @temp_folder + '/' + file_name
|
832
922
|
opts = {
|
833
|
-
:
|
923
|
+
:dst_folder => @temp_folder
|
834
924
|
}
|
835
|
-
|
836
|
-
response
|
837
|
-
assert(response, 'Failed to add new page to end of the document.')
|
925
|
+
response = @pdf_api.put_epub_in_storage_to_pdf(result_name, src_path, opts)
|
926
|
+
assert(response, 'Failed to convert epub to pdf.')
|
838
927
|
end
|
839
928
|
|
840
|
-
def
|
841
|
-
|
842
|
-
upload_file(file_name)
|
843
|
-
|
844
|
-
stamp_file_name = 'Penguins.jpg'
|
845
|
-
upload_file(stamp_file_name)
|
929
|
+
def test_get_web_in_storage_to_pdf
|
930
|
+
url = 'http://google.com'
|
846
931
|
|
847
|
-
|
932
|
+
response = @pdf_api.get_web_in_storage_to_pdf(url)
|
933
|
+
assert(response, 'Failed to convert web page to pdf.')
|
934
|
+
end
|
848
935
|
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
stamp.background = true
|
853
|
-
stamp.width = 200
|
854
|
-
stamp.height = 200
|
855
|
-
stamp.x_indent = 100
|
856
|
-
stamp.y_indent = 100
|
936
|
+
def test_put_web_in_storage_to_pdf
|
937
|
+
url = 'http://google.com'
|
938
|
+
result_name = 'fromWeb.pdf'
|
857
939
|
|
858
940
|
opts = {
|
859
|
-
:
|
941
|
+
:dst_folder => @temp_folder
|
860
942
|
}
|
861
|
-
|
862
|
-
response
|
863
|
-
assert(response, 'Failed to add page stamp.')
|
943
|
+
response = @pdf_api.put_web_in_storage_to_pdf(result_name, url, opts)
|
944
|
+
assert(response, 'Failed to convert web page to pdf.')
|
864
945
|
end
|
865
946
|
|
866
947
|
|
867
|
-
|
868
|
-
|
869
|
-
def test_put_add_text
|
870
|
-
file_name = '4pages.pdf'
|
948
|
+
def test_get_la_te_x_in_storage_to_pdf
|
949
|
+
file_name = 'TexExample.tex'
|
871
950
|
upload_file(file_name)
|
872
951
|
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
rectangle.y = 100
|
878
|
-
rectangle.width = 200
|
879
|
-
rectangle.height = 200
|
880
|
-
|
881
|
-
foreground_color = Color.new
|
882
|
-
foreground_color.a = 0x00
|
883
|
-
foreground_color.r = 0x00
|
884
|
-
foreground_color.g = 0xFF
|
885
|
-
foreground_color.b = 0x00
|
886
|
-
|
887
|
-
background_color = Color.new
|
888
|
-
background_color.a = 0x00
|
889
|
-
background_color.r = 0xFF
|
890
|
-
background_color.g = 0x00
|
891
|
-
background_color.b = 0x00
|
892
|
-
|
893
|
-
text_state = TextState.new
|
894
|
-
text_state.font = 'Arial'
|
895
|
-
text_state.font_size = 10
|
896
|
-
text_state.foreground_color = foreground_color
|
897
|
-
text_state.background_color = background_color
|
898
|
-
text_state.font_style = FontStyles::BOLD
|
899
|
-
|
900
|
-
segment = Segment.new
|
901
|
-
segment.value = 'segment 1'
|
902
|
-
segment.text_state = text_state
|
903
|
-
|
904
|
-
text_line = TextLine.new
|
905
|
-
text_line.horizontal_alignment = TextHorizontalAlignment::RIGHT
|
906
|
-
text_line.segments = [segment]
|
952
|
+
src_path = @temp_folder + '/' + file_name
|
953
|
+
response = @pdf_api.get_la_te_x_in_storage_to_pdf(src_path)
|
954
|
+
assert(response, 'Failed to convert LaTeX to pdf.')
|
955
|
+
end
|
907
956
|
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
paragraph.top_margin = 20
|
913
|
-
paragraph.bottom_margin = 20
|
914
|
-
paragraph.horizontal_alignment = TextHorizontalAlignment::FULL_JUSTIFY
|
915
|
-
paragraph.line_spacing = LineSpacing::FONT_SIZE
|
916
|
-
paragraph.rotation = 10
|
917
|
-
paragraph.subsequent_lines_indent = 20
|
918
|
-
paragraph.vertical_alignment = VerticalAlignment::CENTER
|
919
|
-
paragraph.wrap_mode = WrapMode::BY_WORDS
|
920
|
-
paragraph.lines = [text_line]
|
957
|
+
def test_put_la_te_x_in_storage_to_pdf
|
958
|
+
file_name = 'TexExample.tex'
|
959
|
+
upload_file(file_name)
|
960
|
+
result_name = 'fromTex.pdf'
|
921
961
|
|
962
|
+
src_path = @temp_folder + '/' + file_name
|
922
963
|
opts = {
|
923
|
-
:
|
924
|
-
:folder => @temp_folder
|
964
|
+
:dst_folder => @temp_folder
|
925
965
|
}
|
926
|
-
|
927
|
-
response
|
928
|
-
assert(response, 'Failed to add text to the page.')
|
966
|
+
response = @pdf_api.put_la_te_x_in_storage_to_pdf(result_name, src_path, opts)
|
967
|
+
assert(response, 'Failed to convert LaTeX to pdf.')
|
929
968
|
end
|
930
969
|
|
970
|
+
def test_get_mht_in_storage_to_pdf
|
971
|
+
file_name = 'MhtExample.mht'
|
972
|
+
upload_file(file_name)
|
931
973
|
|
932
|
-
|
974
|
+
src_path = @temp_folder + '/' + file_name
|
975
|
+
response = @pdf_api.get_mht_in_storage_to_pdf(src_path)
|
976
|
+
assert(response, 'Failed to convert mht to pdf.')
|
977
|
+
end
|
933
978
|
|
934
|
-
def
|
935
|
-
file_name = '
|
979
|
+
def test_put_mht_in_storage_to_pdf
|
980
|
+
file_name = 'MhtExample.mht'
|
936
981
|
upload_file(file_name)
|
982
|
+
result_name = 'fromMht.pdf'
|
937
983
|
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
opts_1 = {
|
943
|
-
:property => property_1,
|
944
|
-
:folder => @temp_folder
|
984
|
+
src_path = @temp_folder + '/' + file_name
|
985
|
+
opts = {
|
986
|
+
:dst_folder => @temp_folder
|
945
987
|
}
|
988
|
+
response = @pdf_api.put_mht_in_storage_to_pdf(result_name, src_path, opts)
|
989
|
+
assert(response, 'Failed to convert mht to pdf.')
|
990
|
+
end
|
946
991
|
|
947
|
-
property_2 = DocumentProperty.new
|
948
|
-
property_2.name = 'prop2'
|
949
|
-
property_2.value = 'val2'
|
950
|
-
|
951
|
-
opts_2 = {
|
952
|
-
:property => property_2,
|
953
|
-
:folder => @temp_folder
|
954
|
-
}
|
955
992
|
|
956
|
-
|
957
|
-
|
993
|
+
def test_get_html_in_storage_to_pdf
|
994
|
+
file_name = 'HtmlWithImage.zip'
|
995
|
+
upload_file(file_name)
|
958
996
|
|
997
|
+
html_file_name = 'HtmlWithImage.html'
|
959
998
|
opts = {
|
960
|
-
:
|
999
|
+
:height => 650,
|
1000
|
+
:width => 250
|
961
1001
|
}
|
962
|
-
|
963
|
-
response = @pdf_api.
|
964
|
-
assert(response, 'Failed to
|
1002
|
+
src_path = @temp_folder + '/' + file_name
|
1003
|
+
response = @pdf_api.get_html_in_storage_to_pdf(src_path, html_file_name, opts)
|
1004
|
+
assert(response, 'Failed to convert html to pdf.')
|
965
1005
|
end
|
966
1006
|
|
967
|
-
|
968
|
-
|
969
|
-
file_name = 'PdfWithAcroForm.pdf'
|
1007
|
+
def test_put_html_in_storage_to_pdf
|
1008
|
+
file_name = 'HtmlWithImage.zip'
|
970
1009
|
upload_file(file_name)
|
1010
|
+
html_file_name = 'HtmlWithImage.html'
|
971
1011
|
|
972
|
-
|
973
|
-
property_1.name = 'prop1'
|
974
|
-
property_1.value = 'val1'
|
975
|
-
|
976
|
-
opts_1 = {
|
977
|
-
:property => property_1,
|
978
|
-
:folder => @temp_folder
|
979
|
-
}
|
980
|
-
|
981
|
-
@pdf_api.put_set_property(file_name, property_1.name, opts_1)
|
1012
|
+
result_name = 'fromMht.pdf'
|
982
1013
|
|
1014
|
+
src_path = @temp_folder + '/' + file_name
|
983
1015
|
opts = {
|
984
|
-
:
|
1016
|
+
:dst_folder => @temp_folder,
|
1017
|
+
:height => 650,
|
1018
|
+
:width => 250
|
985
1019
|
}
|
986
|
-
|
987
|
-
response
|
988
|
-
assert(response, 'Failed to delete document property.')
|
1020
|
+
response = @pdf_api.put_html_in_storage_to_pdf(result_name, src_path, html_file_name, opts)
|
1021
|
+
assert(response, 'Failed to convert html to pdf.')
|
989
1022
|
end
|
990
1023
|
|
991
|
-
|
992
|
-
|
993
|
-
file_name = 'PdfWithAcroForm.pdf'
|
1024
|
+
def test_get_xsl_fo_in_storage_to_pdf
|
1025
|
+
file_name = 'XslfoExample.xslfo'
|
994
1026
|
upload_file(file_name)
|
995
1027
|
|
996
|
-
|
997
|
-
|
998
|
-
|
1028
|
+
src_path = @temp_folder + '/' + file_name
|
1029
|
+
response = @pdf_api.get_xsl_fo_in_storage_to_pdf(src_path)
|
1030
|
+
assert(response, 'Failed to convert xslfo to pdf.')
|
1031
|
+
end
|
999
1032
|
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1033
|
+
def test_put_xsl_fo_in_storage_to_pdf
|
1034
|
+
file_name = 'XslfoExample.xslfo'
|
1035
|
+
upload_file(file_name)
|
1036
|
+
result_name = 'fromXslFo.pdf'
|
1037
|
+
|
1038
|
+
src_path = @temp_folder + '/' + file_name
|
1039
|
+
opts = {
|
1040
|
+
:dst_folder => @temp_folder
|
1003
1041
|
}
|
1042
|
+
response = @pdf_api.put_xsl_fo_in_storage_to_pdf(result_name, src_path, opts)
|
1043
|
+
assert(response, 'Failed to convert xslfo to pdf.')
|
1044
|
+
end
|
1004
1045
|
|
1005
|
-
property_2 = DocumentProperty.new
|
1006
|
-
property_2.name = 'prop2'
|
1007
|
-
property_2.value = 'val2'
|
1008
1046
|
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1047
|
+
def test_get_xps_in_storage_to_pdf
|
1048
|
+
file_name = 'Simple.xps'
|
1049
|
+
upload_file(file_name)
|
1050
|
+
|
1051
|
+
src_path = @temp_folder + '/' + file_name
|
1052
|
+
response = @pdf_api.get_xps_in_storage_to_pdf(src_path)
|
1053
|
+
assert(response, 'Failed to convert xps to pdf.')
|
1054
|
+
end
|
1013
1055
|
|
1014
|
-
|
1015
|
-
|
1056
|
+
def test_put_xps_in_storage_to_pdf
|
1057
|
+
file_name = 'Simple.xps'
|
1058
|
+
upload_file(file_name)
|
1059
|
+
result_name = 'fromXps.pdf'
|
1016
1060
|
|
1061
|
+
src_path = @temp_folder + '/' + file_name
|
1017
1062
|
opts = {
|
1018
|
-
:
|
1063
|
+
:dst_folder => @temp_folder
|
1019
1064
|
}
|
1020
|
-
|
1021
|
-
response
|
1022
|
-
assert(response, 'Failed to read document properties')
|
1065
|
+
response = @pdf_api.put_xps_in_storage_to_pdf(result_name, src_path, opts)
|
1066
|
+
assert(response, 'Failed to convert xps to pdf.')
|
1023
1067
|
end
|
1024
1068
|
|
1025
1069
|
|
1026
|
-
def
|
1027
|
-
file_name = '
|
1070
|
+
def test_get_svg_in_storage_to_pdf
|
1071
|
+
file_name = 'Simple.svg'
|
1028
1072
|
upload_file(file_name)
|
1029
1073
|
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
opts_1 = {
|
1035
|
-
:property => property_1,
|
1036
|
-
:folder => @temp_folder
|
1037
|
-
}
|
1074
|
+
src_path = @temp_folder + '/' + file_name
|
1075
|
+
response = @pdf_api.get_svg_in_storage_to_pdf(src_path)
|
1076
|
+
assert(response, 'Failed to convert svg to pdf.')
|
1077
|
+
end
|
1038
1078
|
|
1039
|
-
|
1079
|
+
def test_put_svg_in_storage_to_pdf
|
1080
|
+
file_name = 'Simple.svg'
|
1081
|
+
upload_file(file_name)
|
1082
|
+
result_name = 'fromSvg.pdf'
|
1040
1083
|
|
1084
|
+
src_path = @temp_folder + '/' + file_name
|
1041
1085
|
opts = {
|
1042
|
-
:
|
1086
|
+
:dst_folder => @temp_folder
|
1043
1087
|
}
|
1044
|
-
|
1045
|
-
response
|
1046
|
-
assert(response, 'Failed to read document property by name.')
|
1088
|
+
response = @pdf_api.put_svg_in_storage_to_pdf(result_name, src_path, opts)
|
1089
|
+
assert(response, 'Failed to convert svg to pdf.')
|
1047
1090
|
end
|
1048
1091
|
|
1049
|
-
|
1050
|
-
|
1051
|
-
file_name = 'PdfWithAcroForm.pdf'
|
1092
|
+
def test_get_pcl_in_storage_to_pdf
|
1093
|
+
file_name = 'template.pcl'
|
1052
1094
|
upload_file(file_name)
|
1053
1095
|
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1096
|
+
src_path = @temp_folder + '/' + file_name
|
1097
|
+
response = @pdf_api.get_pcl_in_storage_to_pdf(src_path)
|
1098
|
+
assert(response, 'Failed to convert pcl to pdf.')
|
1099
|
+
end
|
1057
1100
|
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1101
|
+
def test_put_pcl_in_storage_to_pdf
|
1102
|
+
file_name = 'template.pcl'
|
1103
|
+
upload_file(file_name)
|
1104
|
+
result_name = 'fromPcl.pdf'
|
1062
1105
|
|
1063
|
-
|
1064
|
-
|
1106
|
+
src_path = @temp_folder + '/' + file_name
|
1107
|
+
opts = {
|
1108
|
+
:dst_folder => @temp_folder
|
1109
|
+
}
|
1110
|
+
response = @pdf_api.put_pcl_in_storage_to_pdf(result_name, src_path, opts)
|
1111
|
+
assert(response, 'Failed to convert pcl to pdf.')
|
1065
1112
|
end
|
1066
1113
|
|
1067
1114
|
|
1068
|
-
|
1069
|
-
|
1070
|
-
def test_post_sign_document
|
1071
|
-
file_name = 'BlankWithSignature.pdf'
|
1115
|
+
def test_get_xml_in_storage_to_pdf
|
1116
|
+
file_name = 'template.xml'
|
1072
1117
|
upload_file(file_name)
|
1073
1118
|
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
rectangle.x = 100
|
1079
|
-
rectangle.y = 100
|
1080
|
-
rectangle.width = 400
|
1081
|
-
rectangle.height = 100
|
1119
|
+
src_path = @temp_folder + '/' + file_name
|
1120
|
+
response = @pdf_api.get_xml_in_storage_to_pdf(src_path)
|
1121
|
+
assert(response, 'Failed to convert xml to pdf.')
|
1122
|
+
end
|
1082
1123
|
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
signature.form_field_name = 'Signature1'
|
1088
|
-
signature.location = 'Ukraine'
|
1089
|
-
signature.password = 'test1234'
|
1090
|
-
signature.rectangle = rectangle
|
1091
|
-
signature.signature_path = @temp_folder + '/' + signature_file_name
|
1092
|
-
signature.signature_type = SignatureType::PKCS_7
|
1093
|
-
signature.visible = true
|
1124
|
+
def test_put_xml_in_storage_to_pdf
|
1125
|
+
file_name = 'template.xml'
|
1126
|
+
upload_file(file_name)
|
1127
|
+
result_name = 'fromXml.pdf'
|
1094
1128
|
|
1129
|
+
src_path = @temp_folder + '/' + file_name
|
1095
1130
|
opts = {
|
1096
|
-
:
|
1097
|
-
:folder => @temp_folder
|
1131
|
+
:dst_folder => @temp_folder
|
1098
1132
|
}
|
1099
|
-
|
1100
|
-
response
|
1101
|
-
assert(response, 'Failed to sign document.')
|
1133
|
+
response = @pdf_api.put_xml_in_storage_to_pdf(result_name, src_path, opts)
|
1134
|
+
assert(response, 'Failed to convert xml to pdf.')
|
1102
1135
|
end
|
1103
1136
|
|
1104
|
-
def
|
1105
|
-
file_name = '
|
1137
|
+
def test_get_ps_in_storage_to_pdf
|
1138
|
+
file_name = 'Typography.PS'
|
1106
1139
|
upload_file(file_name)
|
1107
1140
|
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
rectangle = Rectangle.new
|
1114
|
-
rectangle.x = 100
|
1115
|
-
rectangle.y = 100
|
1116
|
-
rectangle.width = 400
|
1117
|
-
rectangle.height = 100
|
1141
|
+
src_path = @temp_folder + '/' + file_name
|
1142
|
+
response = @pdf_api.get_ps_in_storage_to_pdf(src_path)
|
1143
|
+
assert(response, 'Failed to convert ps to pdf.')
|
1144
|
+
end
|
1118
1145
|
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
signature.form_field_name = 'Signature1'
|
1124
|
-
signature.location = 'Ukraine'
|
1125
|
-
signature.password = 'test1234'
|
1126
|
-
signature.rectangle = rectangle
|
1127
|
-
signature.signature_path = @temp_folder + '/' + signature_file_name
|
1128
|
-
signature.signature_type = 'PKCS7'
|
1129
|
-
signature.visible = true
|
1146
|
+
def test_put_ps_in_storage_to_pdf
|
1147
|
+
file_name = 'Typography.PS'
|
1148
|
+
upload_file(file_name)
|
1149
|
+
result_name = 'fromPs.pdf'
|
1130
1150
|
|
1151
|
+
src_path = @temp_folder + '/' + file_name
|
1131
1152
|
opts = {
|
1132
|
-
:
|
1133
|
-
:folder => @temp_folder
|
1153
|
+
:dst_folder => @temp_folder
|
1134
1154
|
}
|
1135
|
-
|
1136
|
-
response
|
1137
|
-
assert(response, 'Failed to sign page.')
|
1155
|
+
response = @pdf_api.put_ps_in_storage_to_pdf(result_name, src_path, opts)
|
1156
|
+
assert(response, 'Failed to convert ps to pdf.')
|
1138
1157
|
end
|
1139
1158
|
|
1159
|
+
def test_put_image_in_storage_to_pdf
|
1160
|
+
data_file_1 = "33539.jpg"
|
1161
|
+
upload_file(data_file_1)
|
1140
1162
|
|
1141
|
-
|
1142
|
-
|
1143
|
-
upload_file(file_name)
|
1144
|
-
|
1145
|
-
signature_file_name = 'test1234.pfx'
|
1146
|
-
upload_file(signature_file_name)
|
1163
|
+
data_file_2 = "44781.jpg"
|
1164
|
+
upload_file(data_file_2)
|
1147
1165
|
|
1148
|
-
|
1149
|
-
rectangle.x = 100
|
1150
|
-
rectangle.y = 100
|
1151
|
-
rectangle.width = 400
|
1152
|
-
rectangle.height = 100
|
1166
|
+
result_name = "result.pdf";
|
1153
1167
|
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
signature.date = '08/01/2012 12:15:00.000 PM'
|
1158
|
-
signature.form_field_name = 'Signature1'
|
1159
|
-
signature.location = 'Ukraine'
|
1160
|
-
signature.password = 'test1234'
|
1161
|
-
signature.rectangle = rectangle
|
1162
|
-
signature.signature_path = @temp_folder + '/' + signature_file_name
|
1163
|
-
signature.signature_type = SignatureType::PKCS_7
|
1164
|
-
signature.visible = true
|
1168
|
+
image_template_1 = ImageTemplate.new
|
1169
|
+
image_template_1.image_path = @temp_folder + '/' + data_file_1
|
1170
|
+
image_template_1.image_src_type = ImageSrcType::COMMON
|
1165
1171
|
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
}
|
1172
|
+
image_template_2 = ImageTemplate.new
|
1173
|
+
image_template_2.image_path = @temp_folder + '/' + data_file_2
|
1174
|
+
image_template_2.image_src_type = ImageSrcType::COMMON
|
1170
1175
|
|
1171
|
-
|
1172
|
-
|
1176
|
+
image_templates_request = ImageTemplatesRequest.new
|
1177
|
+
image_templates_request.is_ocr = true
|
1178
|
+
image_templates_request.ocr_langs = "eng"
|
1179
|
+
image_templates_request.images_list = [image_template_1, image_template_2]
|
1173
1180
|
|
1174
1181
|
opts = {
|
1175
|
-
:
|
1182
|
+
:dst_folder => @temp_folder
|
1176
1183
|
}
|
1177
|
-
|
1178
|
-
|
1184
|
+
|
1185
|
+
response = @pdf_api.put_image_in_storage_to_pdf(result_name, image_templates_request, opts)
|
1186
|
+
assert(response, 'Failed to convert images to pdf.')
|
1179
1187
|
end
|
1180
1188
|
|
1181
1189
|
|
1182
|
-
#
|
1190
|
+
# Document Tests
|
1183
1191
|
|
1184
|
-
def
|
1192
|
+
def test_get_document
|
1185
1193
|
file_name = '4pages.pdf'
|
1186
1194
|
upload_file(file_name)
|
1187
1195
|
|
1188
|
-
page_number = 1
|
1189
1196
|
opts = {
|
1190
1197
|
:folder => @temp_folder
|
1191
1198
|
}
|
1192
1199
|
|
1193
|
-
response = @pdf_api.
|
1194
|
-
assert(response, 'Failed to read
|
1200
|
+
response = @pdf_api.get_document(file_name, opts)
|
1201
|
+
assert(response, 'Failed to read common document info.')
|
1195
1202
|
end
|
1196
1203
|
|
1197
1204
|
|
1198
|
-
def
|
1205
|
+
def test_post_optimize_document
|
1199
1206
|
file_name = '4pages.pdf'
|
1200
1207
|
upload_file(file_name)
|
1201
1208
|
|
1209
|
+
optimize_options = OptimizeOptions.new
|
1210
|
+
optimize_options.allow_reuse_page_content = false
|
1211
|
+
optimize_options.compress_images = true
|
1212
|
+
optimize_options.image_quality = 100
|
1213
|
+
optimize_options.link_duplcate_streams = true
|
1214
|
+
optimize_options.remove_unused_objects = true
|
1215
|
+
optimize_options.remove_unused_streams = true
|
1216
|
+
optimize_options.unembed_fonts = true
|
1217
|
+
|
1202
1218
|
opts = {
|
1203
|
-
|
1219
|
+
:options => optimize_options,
|
1220
|
+
:folder => @temp_folder
|
1204
1221
|
}
|
1205
1222
|
|
1206
|
-
response = @pdf_api.
|
1207
|
-
assert(response, 'Failed to
|
1223
|
+
response = @pdf_api.post_optimize_document(file_name, opts)
|
1224
|
+
assert(response, 'Failed to optimize document.')
|
1208
1225
|
end
|
1209
1226
|
|
1210
1227
|
|
1211
|
-
|
1212
|
-
|
1213
|
-
def test_post_document_replace_text
|
1228
|
+
def test_post_split_document
|
1214
1229
|
file_name = '4pages.pdf'
|
1215
1230
|
upload_file(file_name)
|
1216
1231
|
|
1217
|
-
text_replace_request = TextReplaceRequest.new
|
1218
|
-
text_replace_request.old_value = 'Page'
|
1219
|
-
text_replace_request.new_value = 'p_a_g_e'
|
1220
|
-
text_replace_request.regex = false
|
1221
|
-
|
1222
1232
|
opts = {
|
1223
1233
|
:folder => @temp_folder
|
1224
1234
|
}
|
1225
|
-
|
1226
|
-
response
|
1227
|
-
assert(response, "Failed to replace document's text.")
|
1235
|
+
response = @pdf_api.post_split_document(file_name, opts)
|
1236
|
+
assert(response, 'Failed to split document to parts.')
|
1228
1237
|
end
|
1229
1238
|
|
1239
|
+
def test_put_create_empty_document
|
1240
|
+
file_name = 'empty.pdf'
|
1230
1241
|
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1242
|
+
opts = {
|
1243
|
+
:folder => @temp_folder
|
1244
|
+
}
|
1245
|
+
|
1246
|
+
response = @pdf_api.put_create_document(file_name, opts)
|
1247
|
+
assert(response, 'Failed to create new document')
|
1248
|
+
end
|
1234
1249
|
|
1235
|
-
text_replace_request_1 = TextReplaceRequest.new
|
1236
|
-
text_replace_request_1.old_value = 'First'
|
1237
|
-
text_replace_request_1.new_value = '1'
|
1238
|
-
text_replace_request_1.regex = false
|
1239
1250
|
|
1240
|
-
|
1241
|
-
text_replace_request_2.old_value = 'Page'
|
1242
|
-
text_replace_request_2.new_value = 'p_a_g_e'
|
1243
|
-
text_replace_request_2.regex = false
|
1251
|
+
# Fields Tests
|
1244
1252
|
|
1245
|
-
|
1246
|
-
|
1253
|
+
def test_get_field
|
1254
|
+
file_name = 'PdfWithAcroForm.pdf'
|
1255
|
+
upload_file(file_name)
|
1247
1256
|
|
1248
1257
|
opts = {
|
1249
1258
|
:folder => @temp_folder
|
1250
1259
|
}
|
1260
|
+
field_name = 'textField'
|
1251
1261
|
|
1252
|
-
response = @pdf_api.
|
1253
|
-
assert(response,
|
1262
|
+
response = @pdf_api.get_field(file_name, field_name, opts)
|
1263
|
+
assert(response, 'Failed to get document field by name.')
|
1254
1264
|
end
|
1255
1265
|
|
1256
1266
|
|
1257
|
-
def
|
1258
|
-
file_name = '
|
1267
|
+
def test_get_fields
|
1268
|
+
file_name = 'PdfWithAcroForm.pdf'
|
1259
1269
|
upload_file(file_name)
|
1260
1270
|
|
1261
|
-
page_number = 1
|
1262
|
-
|
1263
|
-
text_replace_request = TextReplaceRequest.new
|
1264
|
-
text_replace_request.old_value = 'Page'
|
1265
|
-
text_replace_request.new_value = 'p_a_g_e'
|
1266
|
-
text_replace_request.regex = false
|
1267
|
-
|
1268
1271
|
opts = {
|
1269
1272
|
:folder => @temp_folder
|
1270
1273
|
}
|
1271
1274
|
|
1272
|
-
response = @pdf_api.
|
1273
|
-
assert(response, 'Failed to
|
1275
|
+
response = @pdf_api.get_fields(file_name, opts)
|
1276
|
+
assert(response, 'Failed to get document fields.')
|
1274
1277
|
end
|
1275
1278
|
|
1276
1279
|
|
1277
|
-
def
|
1278
|
-
file_name = '
|
1280
|
+
def test_post_create_field
|
1281
|
+
file_name = 'Hello_world.pdf'
|
1279
1282
|
upload_file(file_name)
|
1280
1283
|
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
text_replace_request_1.regex = false
|
1284
|
+
rect = RectanglePdf.new
|
1285
|
+
rect.llx = 50
|
1286
|
+
rect.lly = 200
|
1287
|
+
rect.urx = 200
|
1288
|
+
rect.ury = 400
|
1287
1289
|
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1290
|
+
field = Field.new
|
1291
|
+
field.name = 'checkboxfield'
|
1292
|
+
field.values = ['1']
|
1293
|
+
field.type = 'Boolean'
|
1294
|
+
field.rect = rect
|
1292
1295
|
|
1293
|
-
|
1294
|
-
text_replace_list_request.text_replaces = [text_replace_request_1, text_replace_request_2]
|
1296
|
+
page_number = 1
|
1295
1297
|
|
1296
1298
|
opts = {
|
1299
|
+
:field => field,
|
1297
1300
|
:folder => @temp_folder
|
1298
1301
|
}
|
1299
1302
|
|
1300
|
-
response = @pdf_api.
|
1301
|
-
assert(response, 'Failed to
|
1303
|
+
response = @pdf_api.post_create_field(file_name, page_number, opts)
|
1304
|
+
assert(response, 'Failed to create field.')
|
1302
1305
|
end
|
1303
1306
|
|
1304
1307
|
|
1305
|
-
|
1306
|
-
|
1307
|
-
def test_put_searchable_document
|
1308
|
-
file_name = 'rusdoc.pdf'
|
1308
|
+
def test_put_update_field
|
1309
|
+
file_name = 'PdfWithAcroForm.pdf'
|
1309
1310
|
upload_file(file_name)
|
1310
1311
|
|
1312
|
+
field_name = 'textField'
|
1313
|
+
|
1314
|
+
field = Field.new
|
1315
|
+
field.name = field_name
|
1316
|
+
field.values = ['Text field updated value.']
|
1317
|
+
field.type = FieldType::TEXT
|
1318
|
+
|
1311
1319
|
opts = {
|
1312
|
-
:
|
1320
|
+
:field => field,
|
1313
1321
|
:folder => @temp_folder
|
1314
1322
|
}
|
1315
1323
|
|
1316
|
-
response = @pdf_api.
|
1317
|
-
assert(response, '
|
1324
|
+
response = @pdf_api.put_update_field(file_name, field_name, opts)
|
1325
|
+
assert(response, 'Failed to update fields.')
|
1318
1326
|
end
|
1319
1327
|
|
1320
|
-
|
1321
|
-
|
1322
|
-
file_name = 'rusdoc.pdf'
|
1328
|
+
def test_put_update_fields
|
1329
|
+
file_name = 'PdfWithAcroForm.pdf'
|
1323
1330
|
upload_file(file_name)
|
1324
1331
|
|
1325
|
-
|
1326
|
-
:folder => @temp_folder
|
1327
|
-
}
|
1332
|
+
field_name = 'textField'
|
1328
1333
|
|
1329
|
-
response = @pdf_api.put_searchable_document(file_name, opts)
|
1330
|
-
assert(response, 'Filed to make document searchable.')
|
1331
|
-
end
|
1332
1334
|
|
1333
1335
|
|
1334
|
-
|
1336
|
+
field = Field.new
|
1337
|
+
field.name = field_name
|
1338
|
+
field.values = ['Text field updated value.']
|
1339
|
+
field.type = FieldType::TEXT
|
1335
1340
|
|
1336
|
-
|
1337
|
-
|
1338
|
-
upload_file(file_name)
|
1341
|
+
fields = Fields.new
|
1342
|
+
fields.list = [field]
|
1339
1343
|
|
1340
|
-
x = 0
|
1341
|
-
y = 0
|
1342
|
-
width = 0
|
1343
|
-
height = 0
|
1344
1344
|
opts = {
|
1345
|
+
:fields => fields,
|
1345
1346
|
:folder => @temp_folder
|
1346
1347
|
}
|
1347
1348
|
|
1348
|
-
response = @pdf_api.
|
1349
|
-
assert(response, '
|
1349
|
+
response = @pdf_api.put_update_fields(file_name, opts)
|
1350
|
+
assert(response, 'Failed to update fields.')
|
1350
1351
|
end
|
1351
1352
|
|
1352
|
-
def
|
1353
|
-
file_name = '
|
1353
|
+
def test_delete_field
|
1354
|
+
file_name = 'PdfWithAcroForm.pdf'
|
1354
1355
|
upload_file(file_name)
|
1355
1356
|
|
1356
|
-
|
1357
|
-
|
1358
|
-
y = 0
|
1359
|
-
width = 0
|
1360
|
-
height = 0
|
1357
|
+
field_name = 'textField'
|
1358
|
+
|
1361
1359
|
opts = {
|
1362
|
-
:format => ['First Page', 'Second Page'],
|
1363
|
-
# :format => 'First Page',
|
1364
1360
|
:folder => @temp_folder
|
1365
1361
|
}
|
1366
1362
|
|
1367
|
-
response = @pdf_api.
|
1368
|
-
assert(response, '
|
1363
|
+
response = @pdf_api.delete_field(file_name, field_name, opts)
|
1364
|
+
assert(response, 'Failed to delete fields.')
|
1369
1365
|
end
|
1370
1366
|
|
1371
1367
|
|
1372
|
-
|
1373
|
-
|
1374
|
-
def test_post_document_text_replace_whole_doc_by_rect
|
1375
|
-
file_name = '4pages.pdf'
|
1368
|
+
def test_put_fields_flatten
|
1369
|
+
file_name = 'PdfWithAcroForm.pdf'
|
1376
1370
|
upload_file(file_name)
|
1377
1371
|
|
1378
|
-
rect = Rectangle.new
|
1379
|
-
rect.x = 100
|
1380
|
-
rect.y = 700
|
1381
|
-
rect.width = 300
|
1382
|
-
rect.height = 300
|
1383
|
-
|
1384
|
-
text_replace = TextReplace.new
|
1385
|
-
text_replace.old_value = 'Page'
|
1386
|
-
text_replace.new_value = 'p_a_g_e'
|
1387
|
-
text_replace.rect = rect
|
1388
|
-
|
1389
|
-
text_replace_list = TextReplaceListRequest.new
|
1390
|
-
text_replace_list.text_replaces = [text_replace]
|
1391
|
-
text_replace_list.start_index = 0
|
1392
|
-
text_replace_list.count_replace = 0
|
1393
|
-
|
1394
|
-
|
1395
1372
|
opts = {
|
1396
1373
|
:folder => @temp_folder
|
1397
1374
|
}
|
1398
1375
|
|
1399
|
-
response
|
1400
|
-
assert(response, '
|
1376
|
+
response = @pdf_api.put_fields_flatten(file_name, opts)
|
1377
|
+
assert(response, 'Failed to make fields flatten.')
|
1401
1378
|
end
|
1402
1379
|
|
1403
1380
|
|
1404
|
-
|
1405
|
-
file_name = '4pages.pdf'
|
1406
|
-
upload_file(file_name)
|
1407
|
-
page_number = 1
|
1408
|
-
|
1409
|
-
rect = Rectangle.new
|
1410
|
-
rect.x = 100
|
1411
|
-
rect.y = 700
|
1412
|
-
rect.width = 300
|
1413
|
-
rect.height = 300
|
1414
|
-
|
1415
|
-
text_replace = TextReplace.new
|
1416
|
-
text_replace.old_value = 'Page'
|
1417
|
-
text_replace.new_value = 'p_a_g_e'
|
1418
|
-
text_replace.rect = rect
|
1381
|
+
# Images Tests
|
1419
1382
|
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
text_replace_list.count_replace = 0
|
1383
|
+
def test_get_image
|
1384
|
+
file_name = 'PdfWithImages2.pdf'
|
1385
|
+
upload_file(file_name)
|
1424
1386
|
|
1425
1387
|
opts = {
|
1426
1388
|
:folder => @temp_folder
|
1427
1389
|
}
|
1428
1390
|
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1391
|
+
page_number = 1
|
1392
|
+
responseImages = @pdf_api.get_images(file_name, page_number, opts)
|
1393
|
+
assert(responseImages, 'Failed to read document images.')
|
1394
|
+
image_id = responseImages[0].images.list[0].id
|
1432
1395
|
|
1433
|
-
# Convert Tests
|
1434
1396
|
|
1435
|
-
|
1436
|
-
|
1397
|
+
|
1398
|
+
response = @pdf_api.get_image(file_name, image_id, opts)
|
1399
|
+
assert(response, 'Failed to read document image by image id.')
|
1400
|
+
end
|
1401
|
+
|
1402
|
+
def test_delete_image
|
1403
|
+
file_name = 'PdfWithImages2.pdf'
|
1437
1404
|
upload_file(file_name)
|
1438
1405
|
|
1439
1406
|
opts = {
|
1440
1407
|
:folder => @temp_folder
|
1441
1408
|
}
|
1442
1409
|
|
1443
|
-
|
1444
|
-
|
1410
|
+
page_number = 1
|
1411
|
+
responseImages = @pdf_api.get_images(file_name, page_number, opts)
|
1412
|
+
assert(responseImages, 'Failed to read document images.')
|
1413
|
+
image_id = responseImages[0].images.list[0].id
|
1414
|
+
|
1415
|
+
response = @pdf_api.delete_image(file_name, image_id, opts)
|
1416
|
+
assert(response, 'Failed to delete document image.')
|
1445
1417
|
end
|
1446
1418
|
|
1447
|
-
def
|
1448
|
-
file_name = '
|
1419
|
+
def test_get_images
|
1420
|
+
file_name = 'PdfWithImages2.pdf'
|
1449
1421
|
upload_file(file_name)
|
1450
|
-
res_file = 'result.doc'
|
1451
1422
|
|
1423
|
+
page_number = 1
|
1452
1424
|
opts = {
|
1453
1425
|
:folder => @temp_folder
|
1454
1426
|
}
|
1455
|
-
|
1456
|
-
|
1427
|
+
|
1428
|
+
response = @pdf_api.get_images(file_name, page_number, opts)
|
1429
|
+
assert(response, 'Failed to read page images.')
|
1457
1430
|
end
|
1458
1431
|
|
1459
|
-
def
|
1460
|
-
file_name = '
|
1432
|
+
def test_put_replace_image
|
1433
|
+
file_name = 'PdfWithImages2.pdf'
|
1434
|
+
upload_file(file_name)
|
1461
1435
|
|
1462
|
-
|
1436
|
+
image_file_name = 'Koala.jpg'
|
1437
|
+
upload_file(image_file_name)
|
1463
1438
|
|
1464
1439
|
opts = {
|
1465
|
-
:
|
1466
|
-
|
1440
|
+
:image_file_path => @temp_folder + '/' + image_file_name,
|
1441
|
+
:folder => @temp_folder
|
1467
1442
|
}
|
1468
|
-
|
1469
|
-
|
1443
|
+
|
1444
|
+
page_number = 1
|
1445
|
+
responseImages = @pdf_api.get_images(file_name, page_number, opts)
|
1446
|
+
assert(responseImages, 'Failed to read document images.')
|
1447
|
+
image_id = responseImages[0].images.list[0].id
|
1448
|
+
|
1449
|
+
response = @pdf_api.put_replace_image(file_name, image_id, opts)
|
1450
|
+
assert(response, 'Failed to replace document image.')
|
1470
1451
|
end
|
1471
1452
|
|
1472
|
-
def
|
1473
|
-
file_name = '
|
1453
|
+
def test_post_insert_image
|
1454
|
+
file_name = 'PdfWithImages2.pdf'
|
1474
1455
|
upload_file(file_name)
|
1475
1456
|
|
1457
|
+
image_file_name = 'Koala.jpg'
|
1458
|
+
upload_file(image_file_name)
|
1459
|
+
page_number = 1
|
1460
|
+
llx = 10
|
1461
|
+
lly = 10
|
1462
|
+
urx = 100
|
1463
|
+
ury = 100
|
1464
|
+
|
1476
1465
|
opts = {
|
1466
|
+
:image_file_path => @temp_folder + '/' + image_file_name,
|
1477
1467
|
:folder => @temp_folder
|
1478
1468
|
}
|
1479
1469
|
|
1480
|
-
response = @pdf_api.
|
1481
|
-
assert(response, '
|
1470
|
+
response = @pdf_api.post_insert_image(file_name, page_number, llx, lly, urx, ury, opts)
|
1471
|
+
assert(response, 'Failed to replace document image.')
|
1482
1472
|
end
|
1483
1473
|
|
1484
|
-
def
|
1485
|
-
|
1486
|
-
upload_file(
|
1487
|
-
|
1474
|
+
def test_put_images_extract_as_jpeg
|
1475
|
+
name = "PdfWithImages2.pdf"
|
1476
|
+
upload_file(name)
|
1477
|
+
page_number = 1
|
1488
1478
|
|
1479
|
+
dest_folder = "extract_jpg"
|
1489
1480
|
opts = {
|
1481
|
+
:dest_folder => @temp_folder + '/' + dest_folder,
|
1490
1482
|
:folder => @temp_folder
|
1491
1483
|
}
|
1492
|
-
response = @pdf_api.
|
1493
|
-
assert(response, '
|
1484
|
+
response = @pdf_api.put_images_extract_as_jpeg(name, page_number, opts)
|
1485
|
+
assert(response, 'Failed to extract images as jpeg.')
|
1494
1486
|
end
|
1495
1487
|
|
1496
|
-
def
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1488
|
+
def test_put_images_extract_as_tiff
|
1489
|
+
name = "PdfWithImages2.pdf"
|
1490
|
+
upload_file(name)
|
1491
|
+
page_number = 1
|
1500
1492
|
|
1493
|
+
dest_folder = "extract_tiff"
|
1501
1494
|
opts = {
|
1502
|
-
:
|
1495
|
+
:dest_folder => @temp_folder + '/' + dest_folder,
|
1496
|
+
:folder => @temp_folder
|
1503
1497
|
}
|
1504
|
-
response = @pdf_api.
|
1505
|
-
assert(response, '
|
1498
|
+
response = @pdf_api.put_images_extract_as_tiff(name, page_number, opts)
|
1499
|
+
assert(response, 'Failed to extract images as tiff.')
|
1506
1500
|
end
|
1507
1501
|
|
1508
|
-
def
|
1509
|
-
|
1510
|
-
upload_file(
|
1502
|
+
def test_put_images_extract_as_gif
|
1503
|
+
name = "PdfWithImages2.pdf"
|
1504
|
+
upload_file(name)
|
1505
|
+
page_number = 1
|
1511
1506
|
|
1507
|
+
dest_folder = "extract_gif"
|
1512
1508
|
opts = {
|
1509
|
+
:dest_folder => @temp_folder + '/' + dest_folder,
|
1513
1510
|
:folder => @temp_folder
|
1514
1511
|
}
|
1515
|
-
|
1516
|
-
response
|
1517
|
-
assert(response, 'Filed to convert PDF to Tiff.')
|
1512
|
+
response = @pdf_api.put_images_extract_as_gif(name, page_number, opts)
|
1513
|
+
assert(response, 'Failed to extract images as gif.')
|
1518
1514
|
end
|
1519
1515
|
|
1520
|
-
def
|
1521
|
-
|
1522
|
-
upload_file(
|
1523
|
-
|
1516
|
+
def test_put_images_extract_as_png
|
1517
|
+
name = "PdfWithImages2.pdf"
|
1518
|
+
upload_file(name)
|
1519
|
+
page_number = 1
|
1524
1520
|
|
1521
|
+
dest_folder = "extract_png"
|
1525
1522
|
opts = {
|
1523
|
+
:dest_folder => @temp_folder + '/' + dest_folder,
|
1526
1524
|
:folder => @temp_folder
|
1527
1525
|
}
|
1528
|
-
response = @pdf_api.
|
1529
|
-
assert(response, '
|
1526
|
+
response = @pdf_api.put_images_extract_as_png(name, page_number, opts)
|
1527
|
+
assert(response, 'Failed to extract images as png.')
|
1530
1528
|
end
|
1531
1529
|
|
1532
|
-
def
|
1533
|
-
|
1530
|
+
def test_put_image_extract_as_jpeg
|
1531
|
+
name = "PdfWithImages2.pdf"
|
1532
|
+
upload_file(name)
|
1534
1533
|
|
1535
|
-
|
1534
|
+
dest_folder = "extract_jpg"
|
1536
1535
|
|
1537
1536
|
opts = {
|
1538
|
-
:
|
1537
|
+
:dest_folder => @temp_folder + '/' + dest_folder,
|
1538
|
+
:folder => @temp_folder
|
1539
1539
|
}
|
1540
|
-
|
1541
|
-
|
1540
|
+
|
1541
|
+
page_number = 1
|
1542
|
+
responseImages = @pdf_api.get_images(name, page_number, opts)
|
1543
|
+
assert(responseImages, 'Failed to read document images.')
|
1544
|
+
image_id = responseImages[0].images.list[0].id
|
1545
|
+
|
1546
|
+
response = @pdf_api.put_image_extract_as_jpeg(name, image_id, opts)
|
1547
|
+
assert(response, 'Failed to extract image as jpeg.')
|
1542
1548
|
end
|
1543
1549
|
|
1544
|
-
def
|
1545
|
-
|
1546
|
-
upload_file(
|
1550
|
+
def test_get_image_extract_as_jpeg
|
1551
|
+
name = "PdfWithImages2.pdf"
|
1552
|
+
upload_file(name)
|
1547
1553
|
|
1548
1554
|
opts = {
|
1549
1555
|
:folder => @temp_folder
|
1550
1556
|
}
|
1551
1557
|
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
def test_put_pdf_in_storage_to_svg
|
1557
|
-
file_name = '4pages.pdf'
|
1558
|
-
upload_file(file_name)
|
1559
|
-
res_file = 'result.svg'
|
1558
|
+
page_number = 1
|
1559
|
+
responseImages = @pdf_api.get_images(name, page_number, opts)
|
1560
|
+
assert(responseImages, 'Failed to read document images.')
|
1561
|
+
image_id = responseImages[0].images.list[0].id
|
1560
1562
|
|
1561
|
-
|
1562
|
-
|
1563
|
-
}
|
1564
|
-
response = @pdf_api.put_pdf_in_storage_to_svg(file_name, @temp_folder + '/' + res_file, opts)
|
1565
|
-
assert(response, 'Filed to convert PDF to SVG.')
|
1563
|
+
response = @pdf_api.get_image_extract_as_jpeg(name, image_id, opts)
|
1564
|
+
assert(response, 'Failed to extract image as jpeg.')
|
1566
1565
|
end
|
1567
1566
|
|
1568
|
-
def
|
1569
|
-
|
1567
|
+
def test_put_image_extract_as_tiff
|
1568
|
+
name = "PdfWithImages2.pdf"
|
1569
|
+
upload_file(name)
|
1570
1570
|
|
1571
|
-
|
1571
|
+
dest_folder = "extract_tiff"
|
1572
1572
|
|
1573
1573
|
opts = {
|
1574
|
-
:
|
1574
|
+
:dest_folder => @temp_folder + '/' + dest_folder,
|
1575
|
+
:folder => @temp_folder
|
1575
1576
|
}
|
1576
|
-
|
1577
|
-
|
1577
|
+
|
1578
|
+
page_number = 1
|
1579
|
+
responseImages = @pdf_api.get_images(name, page_number, opts)
|
1580
|
+
assert(responseImages, 'Failed to read document images.')
|
1581
|
+
image_id = responseImages[0].images.list[0].id
|
1582
|
+
|
1583
|
+
response = @pdf_api.put_image_extract_as_tiff(name, image_id, opts)
|
1584
|
+
assert(response, 'Failed to extract image as tiff.')
|
1578
1585
|
end
|
1579
1586
|
|
1580
|
-
def
|
1581
|
-
|
1582
|
-
upload_file(
|
1587
|
+
def test_get_image_extract_as_tiff
|
1588
|
+
name = "PdfWithImages2.pdf"
|
1589
|
+
upload_file(name)
|
1583
1590
|
|
1584
1591
|
opts = {
|
1585
1592
|
:folder => @temp_folder
|
1586
1593
|
}
|
1587
1594
|
|
1588
|
-
|
1589
|
-
|
1595
|
+
page_number = 1
|
1596
|
+
responseImages = @pdf_api.get_images(name, page_number, opts)
|
1597
|
+
assert(responseImages, 'Failed to read document images.')
|
1598
|
+
image_id = responseImages[0].images.list[0].id
|
1599
|
+
|
1600
|
+
response = @pdf_api.get_image_extract_as_tiff(name, image_id, opts)
|
1601
|
+
assert(response, 'Failed to extract image as tiff.')
|
1590
1602
|
end
|
1591
1603
|
|
1592
|
-
def
|
1593
|
-
|
1594
|
-
upload_file(
|
1595
|
-
|
1604
|
+
def test_put_image_extract_as_gif
|
1605
|
+
name = "PdfWithImages2.pdf"
|
1606
|
+
upload_file(name)
|
1607
|
+
|
1608
|
+
dest_folder = "extract_gif"
|
1596
1609
|
|
1597
1610
|
opts = {
|
1611
|
+
:dest_folder => @temp_folder + '/' + dest_folder,
|
1598
1612
|
:folder => @temp_folder
|
1599
1613
|
}
|
1600
|
-
response = @pdf_api.put_pdf_in_storage_to_xps(file_name, @temp_folder + '/' + res_file, opts)
|
1601
|
-
assert(response, 'Filed to convert PDF to XPS.')
|
1602
|
-
end
|
1603
|
-
|
1604
|
-
def test_put_pdf_in_request_to_xps
|
1605
|
-
file_name = '4pages.pdf'
|
1606
1614
|
|
1607
|
-
|
1615
|
+
page_number = 1
|
1616
|
+
responseImages = @pdf_api.get_images(name, page_number, opts)
|
1617
|
+
assert(responseImages, 'Failed to read document images.')
|
1618
|
+
image_id = responseImages[0].images.list[0].id
|
1608
1619
|
|
1609
|
-
|
1610
|
-
|
1611
|
-
}
|
1612
|
-
response = @pdf_api.put_pdf_in_request_to_xps(@temp_folder + '/' + res_file, opts)
|
1613
|
-
assert(response, 'Filed to convert PDF to XPS.')
|
1620
|
+
response = @pdf_api.put_image_extract_as_gif(name, image_id, opts)
|
1621
|
+
assert(response, 'Failed to extract image as gif.')
|
1614
1622
|
end
|
1615
1623
|
|
1616
|
-
def
|
1617
|
-
|
1618
|
-
upload_file(
|
1624
|
+
def test_get_image_extract_as_gif
|
1625
|
+
name = "PdfWithImages2.pdf"
|
1626
|
+
upload_file(name)
|
1619
1627
|
|
1620
1628
|
opts = {
|
1621
1629
|
:folder => @temp_folder
|
1622
1630
|
}
|
1623
1631
|
|
1624
|
-
|
1625
|
-
|
1632
|
+
page_number = 1
|
1633
|
+
responseImages = @pdf_api.get_images(name, page_number, opts)
|
1634
|
+
assert(responseImages, 'Failed to read document images.')
|
1635
|
+
image_id = responseImages[0].images.list[0].id
|
1636
|
+
|
1637
|
+
response = @pdf_api.get_image_extract_as_gif(name, image_id, opts)
|
1638
|
+
assert(response, 'Failed to extract image as gif.')
|
1626
1639
|
end
|
1627
1640
|
|
1628
|
-
def
|
1629
|
-
|
1630
|
-
upload_file(
|
1631
|
-
|
1641
|
+
def test_put_image_extract_as_png
|
1642
|
+
name = "PdfWithImages2.pdf"
|
1643
|
+
upload_file(name)
|
1644
|
+
|
1645
|
+
dest_folder = "extract_png"
|
1632
1646
|
|
1633
1647
|
opts = {
|
1648
|
+
:dest_folder => @temp_folder + '/' + dest_folder,
|
1634
1649
|
:folder => @temp_folder
|
1635
1650
|
}
|
1636
|
-
response = @pdf_api.put_pdf_in_storage_to_xls(file_name, @temp_folder + '/' + res_file, opts)
|
1637
|
-
assert(response, 'Filed to convert PDF to XLS.')
|
1638
|
-
end
|
1639
|
-
|
1640
|
-
def test_put_pdf_in_request_to_xls
|
1641
|
-
file_name = '4pages.pdf'
|
1642
1651
|
|
1643
|
-
|
1652
|
+
page_number = 1
|
1653
|
+
responseImages = @pdf_api.get_images(name, page_number, opts)
|
1654
|
+
assert(responseImages, 'Failed to read document images.')
|
1655
|
+
image_id = responseImages[0].images.list[0].id
|
1644
1656
|
|
1645
|
-
|
1646
|
-
|
1647
|
-
}
|
1648
|
-
response = @pdf_api.put_pdf_in_request_to_xls(@temp_folder + '/' + res_file, opts)
|
1649
|
-
assert(response, 'Filed to convert PDF to XLS.')
|
1657
|
+
response = @pdf_api.put_image_extract_as_png(name, image_id, opts)
|
1658
|
+
assert(response, 'Failed to extract images as png.')
|
1650
1659
|
end
|
1651
1660
|
|
1652
|
-
def
|
1653
|
-
|
1654
|
-
upload_file(
|
1661
|
+
def test_get_image_extract_as_png
|
1662
|
+
name = "PdfWithImages2.pdf"
|
1663
|
+
upload_file(name)
|
1655
1664
|
|
1656
1665
|
opts = {
|
1657
1666
|
:folder => @temp_folder
|
1658
1667
|
}
|
1659
1668
|
|
1660
|
-
|
1661
|
-
|
1669
|
+
page_number = 1
|
1670
|
+
responseImages = @pdf_api.get_images(name, page_number, opts)
|
1671
|
+
assert(responseImages, 'Failed to read document images.')
|
1672
|
+
image_id = responseImages[0].images.list[0].id
|
1673
|
+
|
1674
|
+
response = @pdf_api.get_image_extract_as_png(name, image_id, opts)
|
1675
|
+
assert(response, 'Failed to extract images as png.')
|
1662
1676
|
end
|
1663
1677
|
|
1664
|
-
|
1665
|
-
|
1678
|
+
|
1679
|
+
# Links Tests
|
1680
|
+
|
1681
|
+
def test_get_page_link_annotation
|
1682
|
+
file_name = 'PdfWithLinks.pdf'
|
1666
1683
|
upload_file(file_name)
|
1667
|
-
res_file = 'result.zip'
|
1668
1684
|
|
1685
|
+
page_number = 1
|
1669
1686
|
opts = {
|
1670
1687
|
:folder => @temp_folder
|
1671
1688
|
}
|
1672
|
-
response = @pdf_api.put_pdf_in_storage_to_html(file_name, @temp_folder + '/' + res_file, opts)
|
1673
|
-
assert(response, 'Filed to convert PDF to HTML.')
|
1674
|
-
end
|
1675
|
-
|
1676
|
-
def test_put_pdf_in_request_to_html
|
1677
|
-
file_name = '4pages.pdf'
|
1678
1689
|
|
1679
|
-
|
1690
|
+
annotations_response = @pdf_api.get_page_link_annotations(file_name, page_number, opts)
|
1691
|
+
assert(annotations_response, 'Failed to read document page link annotations.')
|
1692
|
+
link_id = annotations_response[0].links.list[0].id
|
1680
1693
|
|
1681
|
-
|
1682
|
-
|
1683
|
-
}
|
1684
|
-
response = @pdf_api.put_pdf_in_request_to_html(@temp_folder + '/' + res_file, opts)
|
1685
|
-
assert(response, 'Filed to convert PDF to HTML.')
|
1694
|
+
response = @pdf_api.get_page_link_annotation(file_name, page_number, link_id, opts)
|
1695
|
+
assert(response, 'Failed to read document page link annotation.')
|
1686
1696
|
end
|
1687
1697
|
|
1688
|
-
def
|
1689
|
-
file_name = '
|
1698
|
+
def test_delete_link_annotation
|
1699
|
+
file_name = 'PdfWithLinks.pdf'
|
1690
1700
|
upload_file(file_name)
|
1691
1701
|
|
1702
|
+
page_number = 1
|
1692
1703
|
opts = {
|
1693
1704
|
:folder => @temp_folder
|
1694
1705
|
}
|
1695
1706
|
|
1696
|
-
|
1697
|
-
assert(
|
1707
|
+
annotations_response = @pdf_api.get_page_link_annotations(file_name, page_number, opts)
|
1708
|
+
assert(annotations_response, 'Failed to read document page link annotations.')
|
1709
|
+
link_id = annotations_response[0].links.list[0].id
|
1710
|
+
|
1711
|
+
response = @pdf_api.delete_link_annotation(file_name, link_id, opts)
|
1712
|
+
assert(response, 'Failed to delete link annotation.')
|
1698
1713
|
end
|
1699
1714
|
|
1700
|
-
def
|
1701
|
-
file_name = '
|
1715
|
+
def test_get_page_link_annotations
|
1716
|
+
file_name = 'PdfWithLinks.pdf'
|
1702
1717
|
upload_file(file_name)
|
1703
|
-
res_file = 'result.epub'
|
1704
1718
|
|
1719
|
+
page_number = 1
|
1705
1720
|
opts = {
|
1706
1721
|
:folder => @temp_folder
|
1707
1722
|
}
|
1708
|
-
response = @pdf_api.put_pdf_in_storage_to_epub(file_name, @temp_folder + '/' + res_file, opts)
|
1709
|
-
assert(response, 'Filed to convert PDF to EPUB.')
|
1710
|
-
end
|
1711
|
-
|
1712
|
-
def test_put_pdf_in_request_to_epub
|
1713
|
-
file_name = '4pages.pdf'
|
1714
|
-
|
1715
|
-
res_file = 'result.epub'
|
1716
1723
|
|
1717
|
-
|
1718
|
-
|
1719
|
-
}
|
1720
|
-
response = @pdf_api.put_pdf_in_request_to_epub(@temp_folder + '/' + res_file, opts)
|
1721
|
-
assert(response, 'Filed to convert PDF to EPUB.')
|
1724
|
+
response = @pdf_api.get_page_link_annotations(file_name, page_number, opts)
|
1725
|
+
assert(response, 'Failed to read document page link annotations.')
|
1722
1726
|
end
|
1723
1727
|
|
1724
|
-
def
|
1725
|
-
file_name = '
|
1728
|
+
def test_post_page_link_annotations
|
1729
|
+
file_name = 'PdfWithLinks.pdf'
|
1726
1730
|
upload_file(file_name)
|
1727
1731
|
|
1732
|
+
page_number = 1
|
1728
1733
|
opts = {
|
1729
1734
|
:folder => @temp_folder
|
1730
1735
|
}
|
1731
1736
|
|
1732
|
-
|
1733
|
-
|
1737
|
+
rect = RectanglePdf.new
|
1738
|
+
rect.llx = 100
|
1739
|
+
rect.lly = 100
|
1740
|
+
rect.urx = 500
|
1741
|
+
rect.ury = 500
|
1742
|
+
|
1743
|
+
linkAnnotation = LinkAnnotation.new
|
1744
|
+
linkAnnotation.action_type = LinkActionType::GO_TO_URI_ACTION
|
1745
|
+
linkAnnotation.action = "https://products.aspose.cloud/pdf"
|
1746
|
+
linkAnnotation.rect = rect
|
1747
|
+
|
1748
|
+
response = @pdf_api.post_page_link_annotations(file_name, page_number, [linkAnnotation], opts)
|
1749
|
+
assert(response, 'Failed to add link annotation.')
|
1734
1750
|
end
|
1735
1751
|
|
1736
|
-
def
|
1737
|
-
file_name = '
|
1752
|
+
def test_put_link_annotation
|
1753
|
+
file_name = 'PdfWithLinks.pdf'
|
1738
1754
|
upload_file(file_name)
|
1739
|
-
res_file = 'result.pptx'
|
1740
1755
|
|
1756
|
+
page_number = 1
|
1741
1757
|
opts = {
|
1742
1758
|
:folder => @temp_folder
|
1743
1759
|
}
|
1744
|
-
response = @pdf_api.put_pdf_in_storage_to_pptx(file_name, @temp_folder + '/' + res_file, opts)
|
1745
|
-
assert(response, 'Filed to convert PDF to PPTX.')
|
1746
|
-
end
|
1747
1760
|
|
1761
|
+
annotations_response = @pdf_api.get_page_link_annotations(file_name, page_number, opts)
|
1762
|
+
assert(annotations_response, 'Failed to read document page link annotations.')
|
1763
|
+
link_id = annotations_response[0].links.list[0].id
|
1748
1764
|
|
1749
|
-
|
1750
|
-
|
1765
|
+
rect = RectanglePdf.new
|
1766
|
+
rect.llx = 100
|
1767
|
+
rect.lly = 100
|
1768
|
+
rect.urx = 500
|
1769
|
+
rect.ury = 500
|
1751
1770
|
|
1752
|
-
|
1771
|
+
linkAnnotation = LinkAnnotation.new
|
1772
|
+
linkAnnotation.action_type = LinkActionType::GO_TO_URI_ACTION
|
1773
|
+
linkAnnotation.action = "https://products.aspose.cloud/pdf"
|
1774
|
+
linkAnnotation.rect = rect
|
1753
1775
|
|
1754
|
-
|
1755
|
-
|
1756
|
-
}
|
1757
|
-
response = @pdf_api.put_pdf_in_request_to_pptx(@temp_folder + '/' + res_file, opts)
|
1758
|
-
assert(response, 'Filed to convert PDF to PPTX.')
|
1776
|
+
response = @pdf_api.put_link_annotation(file_name, link_id, linkAnnotation, opts)
|
1777
|
+
assert(response, 'Failed to update link annotation.')
|
1759
1778
|
end
|
1760
1779
|
|
1761
|
-
def
|
1762
|
-
file_name = '
|
1780
|
+
def test_delete_page_link_annotations
|
1781
|
+
file_name = 'PdfWithLinks.pdf'
|
1763
1782
|
upload_file(file_name)
|
1764
1783
|
|
1784
|
+
page_number = 1
|
1765
1785
|
opts = {
|
1766
1786
|
:folder => @temp_folder
|
1767
1787
|
}
|
1768
1788
|
|
1769
|
-
response = @pdf_api.
|
1770
|
-
assert(response, '
|
1789
|
+
response = @pdf_api.delete_page_link_annotations(file_name, page_number, opts)
|
1790
|
+
assert(response, 'Failed to delete page link annotations.')
|
1771
1791
|
end
|
1772
1792
|
|
1773
|
-
def
|
1774
|
-
file_name = '
|
1793
|
+
def test_delete_document_link_annotations
|
1794
|
+
file_name = 'PdfWithLinks.pdf'
|
1775
1795
|
upload_file(file_name)
|
1776
|
-
res_file = 'result.latex'
|
1777
1796
|
|
1797
|
+
page_number = 1
|
1778
1798
|
opts = {
|
1779
1799
|
:folder => @temp_folder
|
1780
1800
|
}
|
1781
|
-
response = @pdf_api.put_pdf_in_storage_to_la_te_x(file_name, @temp_folder + '/' + res_file, opts)
|
1782
|
-
assert(response, 'Filed to convert PDF to LaTeX.')
|
1783
|
-
end
|
1784
1801
|
|
1785
|
-
|
1786
|
-
|
1787
|
-
file_name = '4pages.pdf'
|
1788
|
-
|
1789
|
-
res_file = 'result.latex'
|
1790
|
-
|
1791
|
-
opts = {
|
1792
|
-
:file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
|
1793
|
-
}
|
1794
|
-
response = @pdf_api.put_pdf_in_request_to_la_te_x(@temp_folder + '/' + res_file, opts)
|
1795
|
-
assert(response, 'Filed to convert PDF to LaTeX.')
|
1802
|
+
response = @pdf_api.delete_document_link_annotations(file_name, opts)
|
1803
|
+
assert(response, 'Failed to delete document link annotations.')
|
1796
1804
|
end
|
1797
1805
|
|
1798
|
-
def
|
1799
|
-
file_name = '
|
1806
|
+
def test_get_link_annotation
|
1807
|
+
file_name = 'PdfWithLinks.pdf'
|
1800
1808
|
upload_file(file_name)
|
1801
1809
|
|
1810
|
+
page_number = 1
|
1802
1811
|
opts = {
|
1803
1812
|
:folder => @temp_folder
|
1804
1813
|
}
|
1805
1814
|
|
1806
|
-
|
1807
|
-
assert(
|
1815
|
+
annotations_response = @pdf_api.get_page_link_annotations(file_name, page_number, opts)
|
1816
|
+
assert(annotations_response, 'Failed to read document page link annotations.')
|
1817
|
+
link_id = annotations_response[0].links.list[0].id
|
1818
|
+
|
1819
|
+
response = @pdf_api.get_link_annotation(file_name, link_id, opts)
|
1820
|
+
assert(response, 'Failed to delete link annotation.')
|
1808
1821
|
end
|
1809
1822
|
|
1810
|
-
|
1811
|
-
file_name = '4pages.pdf'
|
1812
|
-
upload_file(file_name)
|
1813
|
-
res_file = 'result.mobi'
|
1823
|
+
# Merge Tests
|
1814
1824
|
|
1815
|
-
|
1816
|
-
|
1817
|
-
}
|
1818
|
-
response = @pdf_api.put_pdf_in_storage_to_mobi_xml(file_name, @temp_folder + '/' + res_file, opts)
|
1819
|
-
assert(response, 'Filed to convert PDF to Moby Xml.')
|
1820
|
-
end
|
1825
|
+
def test_put_merge_documents
|
1826
|
+
file_name_list = ['4pages.pdf', 'PdfWithImages2.pdf', 'marketing.pdf']
|
1827
|
+
file_name_list.each { |file_name| upload_file(file_name)}
|
1821
1828
|
|
1829
|
+
result_name = 'MergingResult.pdf'
|
1822
1830
|
|
1823
|
-
|
1824
|
-
file_name = '4pages.pdf'
|
1831
|
+
file_name_list.collect! {|file_name| @temp_folder + '/' + file_name}
|
1825
1832
|
|
1826
|
-
|
1833
|
+
merge_documents = MergeDocuments.new
|
1834
|
+
merge_documents.list = file_name_list
|
1827
1835
|
|
1828
1836
|
opts = {
|
1829
|
-
:
|
1837
|
+
:merge_documents => merge_documents,
|
1838
|
+
:folder => @temp_folder
|
1830
1839
|
}
|
1831
|
-
|
1832
|
-
|
1840
|
+
|
1841
|
+
response = @pdf_api.put_merge_documents(result_name, opts)
|
1842
|
+
assert(response, 'Failed to merge a list of documents')
|
1833
1843
|
end
|
1834
1844
|
|
1835
|
-
|
1836
|
-
|
1845
|
+
|
1846
|
+
# OCR Tests
|
1847
|
+
|
1848
|
+
def test_put_searchable_document
|
1849
|
+
file_name = 'rusdoc.pdf'
|
1837
1850
|
upload_file(file_name)
|
1838
1851
|
|
1839
1852
|
opts = {
|
1853
|
+
:lang => 'rus,eng',
|
1840
1854
|
:folder => @temp_folder
|
1841
1855
|
}
|
1842
1856
|
|
1843
|
-
response = @pdf_api.
|
1844
|
-
assert(response, 'Filed to
|
1857
|
+
response = @pdf_api.put_searchable_document(file_name, opts)
|
1858
|
+
assert(response, 'Filed to make document searchable')
|
1845
1859
|
end
|
1846
1860
|
|
1847
|
-
|
1848
|
-
|
1861
|
+
|
1862
|
+
def test_put_searchable_document_with_default_lang
|
1863
|
+
file_name = 'rusdoc.pdf'
|
1849
1864
|
upload_file(file_name)
|
1850
|
-
res_file = 'result.pdf'
|
1851
1865
|
|
1852
1866
|
opts = {
|
1853
1867
|
:folder => @temp_folder
|
1854
1868
|
}
|
1855
|
-
|
1856
|
-
|
1869
|
+
|
1870
|
+
response = @pdf_api.put_searchable_document(file_name, opts)
|
1871
|
+
assert(response, 'Filed to make document searchable.')
|
1857
1872
|
end
|
1858
1873
|
|
1859
1874
|
|
1860
|
-
|
1861
|
-
file_name = 'PdfWithXfaForm.pdf'
|
1875
|
+
# Page Convert To Images Tests
|
1862
1876
|
|
1863
|
-
|
1877
|
+
def test_get_page_convert_to_tiff
|
1878
|
+
name = "4pages.pdf"
|
1879
|
+
upload_file(name)
|
1864
1880
|
|
1881
|
+
page_number = 2
|
1865
1882
|
opts = {
|
1866
|
-
:
|
1883
|
+
:folder => @temp_folder
|
1867
1884
|
}
|
1868
|
-
|
1869
|
-
|
1885
|
+
|
1886
|
+
response = @pdf_api.get_page_convert_to_tiff(name, page_number, opts)
|
1887
|
+
assert(response, 'Failed to convert page as tiff.')
|
1870
1888
|
end
|
1871
1889
|
|
1890
|
+
def test_put_page_convert_to_tiff
|
1891
|
+
name = "4pages.pdf"
|
1892
|
+
upload_file(name)
|
1893
|
+
result_file = "page.tiff"
|
1894
|
+
out_path = @temp_folder + '/' + result_file
|
1895
|
+
page_number = 2
|
1896
|
+
opts = {
|
1897
|
+
:folder => @temp_folder
|
1898
|
+
}
|
1899
|
+
response = @pdf_api.put_page_convert_to_tiff(name, page_number, out_path, opts)
|
1900
|
+
assert(response, 'Failed to convert page as tiff.')
|
1901
|
+
end
|
1872
1902
|
|
1873
|
-
def
|
1874
|
-
|
1875
|
-
upload_file(
|
1903
|
+
def test_get_page_convert_to_jpeg
|
1904
|
+
name = "4pages.pdf"
|
1905
|
+
upload_file(name)
|
1876
1906
|
|
1907
|
+
page_number = 2
|
1877
1908
|
opts = {
|
1878
1909
|
:folder => @temp_folder
|
1879
1910
|
}
|
1880
1911
|
|
1881
|
-
response = @pdf_api.
|
1882
|
-
assert(response, '
|
1912
|
+
response = @pdf_api.get_page_convert_to_jpeg(name, page_number, opts)
|
1913
|
+
assert(response, 'Failed to convert page as jpeg.')
|
1883
1914
|
end
|
1884
1915
|
|
1885
|
-
def
|
1886
|
-
|
1887
|
-
upload_file(
|
1888
|
-
|
1889
|
-
|
1916
|
+
def test_put_page_convert_to_jpeg
|
1917
|
+
name = "4pages.pdf"
|
1918
|
+
upload_file(name)
|
1919
|
+
result_file = "page.jpeg"
|
1920
|
+
out_path = @temp_folder + '/' + result_file
|
1921
|
+
page_number = 2
|
1890
1922
|
opts = {
|
1891
1923
|
:folder => @temp_folder
|
1892
1924
|
}
|
1893
|
-
response = @pdf_api.
|
1894
|
-
assert(response, '
|
1925
|
+
response = @pdf_api.put_page_convert_to_jpeg(name, page_number, out_path, opts)
|
1926
|
+
assert(response, 'Failed to convert page as jpeg.')
|
1895
1927
|
end
|
1896
1928
|
|
1929
|
+
def test_get_page_convert_to_png
|
1930
|
+
name = "4pages.pdf"
|
1931
|
+
upload_file(name)
|
1897
1932
|
|
1898
|
-
|
1899
|
-
|
1933
|
+
page_number = 2
|
1934
|
+
opts = {
|
1935
|
+
:folder => @temp_folder
|
1936
|
+
}
|
1900
1937
|
|
1901
|
-
|
1938
|
+
response = @pdf_api.get_page_convert_to_png(name, page_number, opts)
|
1939
|
+
assert(response, 'Failed to convert page as png.')
|
1940
|
+
end
|
1902
1941
|
|
1942
|
+
def test_put_page_convert_to_png
|
1943
|
+
name = "4pages.pdf"
|
1944
|
+
upload_file(name)
|
1945
|
+
result_file = "page.png"
|
1946
|
+
out_path = @temp_folder + '/' + result_file
|
1947
|
+
page_number = 2
|
1903
1948
|
opts = {
|
1904
|
-
:
|
1949
|
+
:folder => @temp_folder
|
1905
1950
|
}
|
1906
|
-
response = @pdf_api.
|
1907
|
-
assert(response, '
|
1951
|
+
response = @pdf_api.put_page_convert_to_png(name, page_number, out_path, opts)
|
1952
|
+
assert(response, 'Failed to convert page as png.')
|
1908
1953
|
end
|
1909
1954
|
|
1910
|
-
|
1955
|
+
def test_get_page_convert_to_emf
|
1956
|
+
name = "4pages.pdf"
|
1957
|
+
upload_file(name)
|
1911
1958
|
|
1912
|
-
|
1913
|
-
|
1959
|
+
page_number = 2
|
1960
|
+
opts = {
|
1961
|
+
:folder => @temp_folder
|
1962
|
+
}
|
1914
1963
|
|
1915
|
-
response = @pdf_api.
|
1916
|
-
assert(response,
|
1964
|
+
response = @pdf_api.get_page_convert_to_emf(name, page_number, opts)
|
1965
|
+
assert(response, 'Failed to convert page as emf.')
|
1917
1966
|
end
|
1918
1967
|
|
1919
|
-
def
|
1920
|
-
|
1921
|
-
upload_file(
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1968
|
+
def test_put_page_convert_to_emf
|
1969
|
+
name = "4pages.pdf"
|
1970
|
+
upload_file(name)
|
1971
|
+
result_file = "page.emf"
|
1972
|
+
out_path = @temp_folder + '/' + result_file
|
1973
|
+
page_number = 2
|
1974
|
+
opts = {
|
1975
|
+
:folder => @temp_folder
|
1976
|
+
}
|
1977
|
+
response = @pdf_api.put_page_convert_to_emf(name, page_number, out_path, opts)
|
1978
|
+
assert(response, 'Failed to convert page as emf.')
|
1926
1979
|
end
|
1927
1980
|
|
1928
|
-
|
1981
|
+
def test_get_page_convert_to_bmp
|
1982
|
+
name = "4pages.pdf"
|
1983
|
+
upload_file(name)
|
1929
1984
|
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1985
|
+
page_number = 2
|
1986
|
+
opts = {
|
1987
|
+
:folder => @temp_folder
|
1988
|
+
}
|
1933
1989
|
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1990
|
+
response = @pdf_api.get_page_convert_to_bmp(name, page_number, opts)
|
1991
|
+
assert(response, 'Failed to convert page as bmp.')
|
1992
|
+
end
|
1937
1993
|
|
1994
|
+
def test_put_page_convert_to_bmp
|
1995
|
+
name = "4pages.pdf"
|
1996
|
+
upload_file(name)
|
1997
|
+
result_file = "page.bmp"
|
1998
|
+
out_path = @temp_folder + '/' + result_file
|
1999
|
+
page_number = 2
|
1938
2000
|
opts = {
|
1939
|
-
:privileges => privileges,
|
1940
2001
|
:folder => @temp_folder
|
1941
2002
|
}
|
1942
|
-
response = @pdf_api.
|
1943
|
-
assert(response, 'Failed to
|
2003
|
+
response = @pdf_api.put_page_convert_to_bmp(name, page_number, out_path, opts)
|
2004
|
+
assert(response, 'Failed to convert page as bmp.')
|
1944
2005
|
end
|
1945
2006
|
|
1946
|
-
|
2007
|
+
def test_get_page_convert_to_gif
|
2008
|
+
name = "4pages.pdf"
|
2009
|
+
upload_file(name)
|
1947
2010
|
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
2011
|
+
page_number = 2
|
2012
|
+
opts = {
|
2013
|
+
:folder => @temp_folder
|
2014
|
+
}
|
1951
2015
|
|
1952
|
-
|
1953
|
-
response
|
1954
|
-
assert(response, 'Failed to convert epub to pdf.')
|
2016
|
+
response = @pdf_api.get_page_convert_to_gif(name, page_number, opts)
|
2017
|
+
assert(response, 'Failed to convert page as gif.')
|
1955
2018
|
end
|
1956
2019
|
|
1957
|
-
def
|
1958
|
-
|
1959
|
-
upload_file(
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
2020
|
+
def test_put_page_convert_to_gif
|
2021
|
+
name = "4pages.pdf"
|
2022
|
+
upload_file(name)
|
2023
|
+
result_file = "page.gif"
|
2024
|
+
out_path = @temp_folder + '/' + result_file
|
2025
|
+
page_number = 2
|
1963
2026
|
opts = {
|
1964
|
-
:
|
2027
|
+
:folder => @temp_folder
|
1965
2028
|
}
|
1966
|
-
response = @pdf_api.
|
1967
|
-
assert(response, 'Failed to convert
|
2029
|
+
response = @pdf_api.put_page_convert_to_gif(name, page_number, out_path, opts)
|
2030
|
+
assert(response, 'Failed to convert page as gif.')
|
1968
2031
|
end
|
1969
2032
|
|
1970
|
-
def test_get_web_in_storage_to_pdf
|
1971
|
-
url = 'http://google.com'
|
1972
2033
|
|
1973
|
-
|
1974
|
-
assert(response, 'Failed to convert web page to pdf.')
|
1975
|
-
end
|
2034
|
+
# Pages Tests
|
1976
2035
|
|
1977
|
-
def
|
1978
|
-
|
1979
|
-
|
2036
|
+
def test_delete_page
|
2037
|
+
file_name = '4pages.pdf'
|
2038
|
+
upload_file(file_name)
|
1980
2039
|
|
2040
|
+
page_number = 1
|
1981
2041
|
opts = {
|
1982
|
-
:
|
2042
|
+
:folder => @temp_folder
|
1983
2043
|
}
|
1984
|
-
|
1985
|
-
|
2044
|
+
|
2045
|
+
response = @pdf_api.delete_page(file_name, page_number, opts)
|
2046
|
+
assert(response, 'Failed to delete document page by its number.')
|
1986
2047
|
end
|
1987
2048
|
|
1988
2049
|
|
1989
|
-
def
|
1990
|
-
file_name = '
|
2050
|
+
def test_get_page
|
2051
|
+
file_name = '4pages.pdf'
|
1991
2052
|
upload_file(file_name)
|
1992
2053
|
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
2054
|
+
page_number = 3
|
2055
|
+
opts = {
|
2056
|
+
:folder => @temp_folder
|
2057
|
+
}
|
2058
|
+
|
2059
|
+
response = @pdf_api.get_page(file_name, page_number, opts)
|
2060
|
+
assert(response, 'Failed to get document page by its number.')
|
1996
2061
|
end
|
1997
2062
|
|
1998
|
-
def
|
1999
|
-
file_name = '
|
2063
|
+
def test_get_pages
|
2064
|
+
file_name = '4pages.pdf'
|
2000
2065
|
upload_file(file_name)
|
2001
|
-
result_name = 'fromTex.pdf'
|
2002
2066
|
|
2003
|
-
src_path = @temp_folder + '/' + file_name
|
2004
2067
|
opts = {
|
2005
|
-
:
|
2068
|
+
:folder => @temp_folder
|
2006
2069
|
}
|
2007
|
-
|
2008
|
-
|
2070
|
+
|
2071
|
+
response = @pdf_api.get_pages(file_name, opts)
|
2072
|
+
assert(response, 'Failed to read document pages info.')
|
2009
2073
|
end
|
2010
2074
|
|
2011
|
-
def
|
2012
|
-
file_name = '
|
2075
|
+
def test_get_words_per_page
|
2076
|
+
file_name = '4pages.pdf'
|
2013
2077
|
upload_file(file_name)
|
2014
2078
|
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2079
|
+
opts = {
|
2080
|
+
:folder => @temp_folder
|
2081
|
+
}
|
2082
|
+
|
2083
|
+
response = @pdf_api.get_words_per_page(file_name, opts)
|
2084
|
+
assert(response, 'Failed to get number of words per document page.')
|
2018
2085
|
end
|
2019
2086
|
|
2020
|
-
def
|
2021
|
-
file_name = '
|
2087
|
+
def test_post_move_page
|
2088
|
+
file_name = '4pages.pdf'
|
2022
2089
|
upload_file(file_name)
|
2023
|
-
result_name = 'fromMht.pdf'
|
2024
2090
|
|
2025
|
-
src_path = @temp_folder + '/' + file_name
|
2026
2091
|
opts = {
|
2027
|
-
:
|
2092
|
+
:folder => @temp_folder
|
2028
2093
|
}
|
2029
|
-
|
2030
|
-
|
2031
|
-
end
|
2094
|
+
page_number = 1
|
2095
|
+
new_index = 1
|
2032
2096
|
|
2097
|
+
response = @pdf_api.post_move_page(file_name, page_number, new_index, opts)
|
2098
|
+
assert(response, 'Failed to move page to new position.')
|
2099
|
+
end
|
2033
2100
|
|
2034
|
-
def
|
2035
|
-
file_name = '
|
2101
|
+
def test_put_add_new_page
|
2102
|
+
file_name = '4pages.pdf'
|
2036
2103
|
upload_file(file_name)
|
2037
2104
|
|
2038
|
-
html_file_name = 'HtmlWithImage.html'
|
2039
2105
|
opts = {
|
2040
|
-
:
|
2041
|
-
:width => 250
|
2106
|
+
:folder => @temp_folder
|
2042
2107
|
}
|
2043
|
-
|
2044
|
-
response = @pdf_api.
|
2045
|
-
assert(response, 'Failed to
|
2108
|
+
|
2109
|
+
response = @pdf_api.put_add_new_page(file_name, opts)
|
2110
|
+
assert(response, 'Failed to add new page to end of the document.')
|
2046
2111
|
end
|
2047
2112
|
|
2048
|
-
def
|
2049
|
-
file_name = '
|
2113
|
+
def test_put_page_add_stamp
|
2114
|
+
file_name = '4pages.pdf'
|
2050
2115
|
upload_file(file_name)
|
2051
|
-
html_file_name = 'HtmlWithImage.html'
|
2052
2116
|
|
2053
|
-
|
2117
|
+
stamp_file_name = 'Penguins.jpg'
|
2118
|
+
upload_file(stamp_file_name)
|
2119
|
+
|
2120
|
+
page_number = 1
|
2121
|
+
|
2122
|
+
stamp = Stamp.new
|
2123
|
+
stamp.type = StampType::IMAGE
|
2124
|
+
stamp.file_name = @temp_folder + '/' + stamp_file_name
|
2125
|
+
stamp.background = true
|
2126
|
+
stamp.width = 200
|
2127
|
+
stamp.height = 200
|
2128
|
+
stamp.x_indent = 100
|
2129
|
+
stamp.y_indent = 100
|
2054
2130
|
|
2055
|
-
src_path = @temp_folder + '/' + file_name
|
2056
2131
|
opts = {
|
2057
|
-
:
|
2058
|
-
:height => 650,
|
2059
|
-
:width => 250
|
2132
|
+
:folder => @temp_folder
|
2060
2133
|
}
|
2061
|
-
|
2062
|
-
|
2134
|
+
|
2135
|
+
response = @pdf_api.put_page_add_stamp(file_name, page_number, stamp, opts)
|
2136
|
+
assert(response, 'Failed to add page stamp.')
|
2063
2137
|
end
|
2064
2138
|
|
2065
|
-
def test_get_xsl_fo_in_storage_to_pdf
|
2066
|
-
file_name = 'XslfoExample.xslfo'
|
2067
|
-
upload_file(file_name)
|
2068
2139
|
|
2069
|
-
|
2070
|
-
response = @pdf_api.get_xsl_fo_in_storage_to_pdf(src_path)
|
2071
|
-
assert(response, 'Failed to convert xslfo to pdf.')
|
2072
|
-
end
|
2140
|
+
# Privileges Tests
|
2073
2141
|
|
2074
|
-
def
|
2075
|
-
file_name = '
|
2142
|
+
def test_put_privileges
|
2143
|
+
file_name = '4pages.pdf'
|
2076
2144
|
upload_file(file_name)
|
2077
|
-
result_name = 'fromXslFo.pdf'
|
2078
2145
|
|
2079
|
-
|
2146
|
+
privileges = DocumentPrivilege.new
|
2147
|
+
privileges.allow_copy = false
|
2148
|
+
privileges.allow_print = false
|
2149
|
+
|
2080
2150
|
opts = {
|
2081
|
-
:
|
2151
|
+
:privileges => privileges,
|
2152
|
+
:folder => @temp_folder
|
2082
2153
|
}
|
2083
|
-
response = @pdf_api.
|
2084
|
-
assert(response, 'Failed to
|
2154
|
+
response = @pdf_api.put_privileges(file_name, opts)
|
2155
|
+
assert(response, 'Failed to set pdf privileges.')
|
2085
2156
|
end
|
2086
2157
|
|
2087
2158
|
|
2088
|
-
|
2089
|
-
file_name = 'Simple.xps'
|
2090
|
-
upload_file(file_name)
|
2091
|
-
|
2092
|
-
src_path = @temp_folder + '/' + file_name
|
2093
|
-
response = @pdf_api.get_xps_in_storage_to_pdf(src_path)
|
2094
|
-
assert(response, 'Failed to convert xps to pdf.')
|
2095
|
-
end
|
2159
|
+
# Properties Tests
|
2096
2160
|
|
2097
|
-
def
|
2098
|
-
file_name = '
|
2161
|
+
def test_delete_properties
|
2162
|
+
file_name = 'PdfWithAcroForm.pdf'
|
2099
2163
|
upload_file(file_name)
|
2100
|
-
result_name = 'fromXps.pdf'
|
2101
2164
|
|
2102
|
-
|
2165
|
+
property_1 = DocumentProperty.new
|
2166
|
+
property_1.name = 'prop1'
|
2167
|
+
property_1.value = 'val1'
|
2168
|
+
|
2103
2169
|
opts = {
|
2104
|
-
:
|
2170
|
+
:folder => @temp_folder
|
2105
2171
|
}
|
2106
|
-
response = @pdf_api.put_xps_in_storage_to_pdf(result_name, src_path, opts)
|
2107
|
-
assert(response, 'Failed to convert xps to pdf.')
|
2108
|
-
end
|
2109
2172
|
|
2173
|
+
property_2 = DocumentProperty.new
|
2174
|
+
property_2.name = 'prop2'
|
2175
|
+
property_2.value = 'val2'
|
2110
2176
|
|
2111
|
-
def test_get_svg_in_storage_to_pdf
|
2112
|
-
file_name = 'Simple.svg'
|
2113
|
-
upload_file(file_name)
|
2114
2177
|
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2178
|
+
@pdf_api.put_set_property(file_name, property_1.name, property_1.value, opts)
|
2179
|
+
@pdf_api.put_set_property(file_name, property_2.name, property_2.value, opts)
|
2180
|
+
|
2181
|
+
response = @pdf_api.delete_properties(file_name, opts)
|
2182
|
+
assert(response, 'Failed to delete document properties.')
|
2118
2183
|
end
|
2119
2184
|
|
2120
|
-
|
2121
|
-
|
2185
|
+
|
2186
|
+
def test_delete_property
|
2187
|
+
file_name = 'PdfWithAcroForm.pdf'
|
2122
2188
|
upload_file(file_name)
|
2123
|
-
result_name = 'fromSvg.pdf'
|
2124
2189
|
|
2125
|
-
|
2190
|
+
property_1 = DocumentProperty.new
|
2191
|
+
property_1.name = 'prop1'
|
2192
|
+
property_1.value = 'val1'
|
2193
|
+
|
2126
2194
|
opts = {
|
2127
|
-
:
|
2195
|
+
:folder => @temp_folder
|
2128
2196
|
}
|
2129
|
-
response = @pdf_api.put_svg_in_storage_to_pdf(result_name, src_path, opts)
|
2130
|
-
assert(response, 'Failed to convert svg to pdf.')
|
2131
|
-
end
|
2132
2197
|
|
2133
|
-
|
2134
|
-
file_name = 'template.pcl'
|
2135
|
-
upload_file(file_name)
|
2198
|
+
@pdf_api.put_set_property(file_name, property_1.name, property_1.value, opts)
|
2136
2199
|
|
2137
|
-
|
2138
|
-
response
|
2139
|
-
assert(response, 'Failed to convert pcl to pdf.')
|
2200
|
+
response = @pdf_api.delete_property(file_name, property_1.name, opts)
|
2201
|
+
assert(response, 'Failed to delete document property.')
|
2140
2202
|
end
|
2141
2203
|
|
2142
|
-
|
2143
|
-
|
2204
|
+
|
2205
|
+
def test_get_document_properties
|
2206
|
+
file_name = 'PdfWithAcroForm.pdf'
|
2144
2207
|
upload_file(file_name)
|
2145
|
-
result_name = 'fromPcl.pdf'
|
2146
2208
|
|
2147
|
-
|
2209
|
+
property_1 = DocumentProperty.new
|
2210
|
+
property_1.name = 'prop1'
|
2211
|
+
property_1.value = 'val1'
|
2212
|
+
|
2148
2213
|
opts = {
|
2149
|
-
:
|
2214
|
+
:folder => @temp_folder
|
2150
2215
|
}
|
2151
|
-
response = @pdf_api.put_pcl_in_storage_to_pdf(result_name, src_path, opts)
|
2152
|
-
assert(response, 'Failed to convert pcl to pdf.')
|
2153
|
-
end
|
2154
2216
|
|
2217
|
+
property_2 = DocumentProperty.new
|
2218
|
+
property_2.name = 'prop2'
|
2219
|
+
property_2.value = 'val2'
|
2155
2220
|
|
2156
|
-
|
2157
|
-
file_name
|
2158
|
-
upload_file(file_name)
|
2221
|
+
@pdf_api.put_set_property(file_name, property_1.name, property_1.value, opts)
|
2222
|
+
@pdf_api.put_set_property(file_name, property_2.name, property_2.value, opts)
|
2159
2223
|
|
2160
|
-
|
2161
|
-
response
|
2162
|
-
assert(response, 'Failed to convert xml to pdf.')
|
2224
|
+
response = @pdf_api.get_document_properties(file_name, opts)
|
2225
|
+
assert(response, 'Failed to read document properties')
|
2163
2226
|
end
|
2164
2227
|
|
2165
|
-
|
2166
|
-
|
2228
|
+
|
2229
|
+
def test_get_document_property
|
2230
|
+
file_name = 'PdfWithAcroForm.pdf'
|
2167
2231
|
upload_file(file_name)
|
2168
|
-
result_name = 'fromXml.pdf'
|
2169
2232
|
|
2170
|
-
|
2233
|
+
property_1 = DocumentProperty.new
|
2234
|
+
property_1.name = 'prop1'
|
2235
|
+
property_1.value = 'val1'
|
2236
|
+
|
2171
2237
|
opts = {
|
2172
|
-
:
|
2238
|
+
:folder => @temp_folder
|
2173
2239
|
}
|
2174
|
-
response = @pdf_api.put_xml_in_storage_to_pdf(result_name, src_path, opts)
|
2175
|
-
assert(response, 'Failed to convert xml to pdf.')
|
2176
|
-
end
|
2177
2240
|
|
2178
|
-
|
2179
|
-
file_name = 'Typography.PS'
|
2180
|
-
upload_file(file_name)
|
2241
|
+
@pdf_api.put_set_property(file_name, property_1.name, property_1.value, opts)
|
2181
2242
|
|
2182
|
-
|
2183
|
-
response
|
2184
|
-
assert(response, 'Failed to convert ps to pdf.')
|
2243
|
+
response = @pdf_api.get_document_property(file_name, property_1.name, opts)
|
2244
|
+
assert(response, 'Failed to read document property by name.')
|
2185
2245
|
end
|
2186
2246
|
|
2187
|
-
|
2188
|
-
|
2247
|
+
|
2248
|
+
def test_put_set_property
|
2249
|
+
file_name = 'PdfWithAcroForm.pdf'
|
2189
2250
|
upload_file(file_name)
|
2190
|
-
result_name = 'fromPs.pdf'
|
2191
2251
|
|
2192
|
-
|
2252
|
+
property_name = 'prop1'
|
2253
|
+
property_value = 'val1'
|
2254
|
+
|
2193
2255
|
opts = {
|
2194
|
-
:
|
2256
|
+
:folder => @temp_folder
|
2195
2257
|
}
|
2196
|
-
|
2197
|
-
|
2258
|
+
|
2259
|
+
response = @pdf_api.put_set_property(file_name, property_name, property_value, opts)
|
2260
|
+
assert(response, 'Failed to add/update document property.')
|
2198
2261
|
end
|
2199
2262
|
|
2200
|
-
def test_put_image_in_storage_to_pdf
|
2201
|
-
data_file_1 = "33539.jpg"
|
2202
|
-
upload_file(data_file_1)
|
2203
2263
|
|
2204
|
-
|
2205
|
-
upload_file(data_file_2)
|
2264
|
+
# Sign Tests
|
2206
2265
|
|
2207
|
-
|
2266
|
+
def test_post_sign_document
|
2267
|
+
file_name = 'BlankWithSignature.pdf'
|
2268
|
+
upload_file(file_name)
|
2208
2269
|
|
2209
|
-
|
2210
|
-
|
2211
|
-
image_template_1.image_src_type = ImageSrcType::COMMON
|
2270
|
+
signature_file_name = 'test1234.pfx'
|
2271
|
+
upload_file(signature_file_name)
|
2212
2272
|
|
2213
|
-
|
2214
|
-
|
2215
|
-
|
2273
|
+
rectangle = RectanglePdf.new
|
2274
|
+
rectangle.llx = 100
|
2275
|
+
rectangle.lly = 100
|
2276
|
+
rectangle.urx = 400
|
2277
|
+
rectangle.ury = 200
|
2216
2278
|
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2279
|
+
signature = Signature.new
|
2280
|
+
signature.authority = 'Sergey Smal'
|
2281
|
+
signature.contact = 'test@mail.ru'
|
2282
|
+
signature.date = '08/01/2012 12:15:00.000 PM'
|
2283
|
+
signature.form_field_name = 'Signature1'
|
2284
|
+
signature.location = 'Ukraine'
|
2285
|
+
signature.password = 'test1234'
|
2286
|
+
signature.rectangle = rectangle
|
2287
|
+
signature.signature_path = @temp_folder + '/' + signature_file_name
|
2288
|
+
signature.signature_type = SignatureType::PKCS7
|
2289
|
+
signature.visible = true
|
2221
2290
|
|
2222
2291
|
opts = {
|
2223
|
-
:
|
2292
|
+
:signature => signature,
|
2293
|
+
:folder => @temp_folder
|
2224
2294
|
}
|
2225
2295
|
|
2226
|
-
response = @pdf_api.
|
2227
|
-
assert(response, 'Failed to
|
2296
|
+
response = @pdf_api.post_sign_document(file_name, opts)
|
2297
|
+
assert(response, 'Failed to sign document.')
|
2228
2298
|
end
|
2229
2299
|
|
2230
|
-
|
2300
|
+
def test_post_sign_page
|
2301
|
+
file_name = 'BlankWithSignature.pdf'
|
2302
|
+
upload_file(file_name)
|
2231
2303
|
|
2232
|
-
|
2233
|
-
|
2234
|
-
upload_file(name)
|
2304
|
+
signature_file_name = 'test1234.pfx'
|
2305
|
+
upload_file(signature_file_name)
|
2235
2306
|
|
2236
|
-
page_number =
|
2237
|
-
opts = {
|
2238
|
-
:folder => @temp_folder
|
2239
|
-
}
|
2307
|
+
page_number = 1
|
2240
2308
|
|
2241
|
-
|
2242
|
-
|
2243
|
-
|
2309
|
+
rectangle = RectanglePdf.new
|
2310
|
+
rectangle.llx = 100
|
2311
|
+
rectangle.lly = 100
|
2312
|
+
rectangle.urx = 400
|
2313
|
+
rectangle.ury = 200
|
2314
|
+
|
2315
|
+
signature = Signature.new
|
2316
|
+
signature.authority = 'Sergey Smal'
|
2317
|
+
signature.contact = 'test@mail.ru'
|
2318
|
+
signature.date = '08/01/2012 12:15:00.000 PM'
|
2319
|
+
signature.form_field_name = 'Signature1'
|
2320
|
+
signature.location = 'Ukraine'
|
2321
|
+
signature.password = 'test1234'
|
2322
|
+
signature.rectangle = rectangle
|
2323
|
+
signature.signature_path = @temp_folder + '/' + signature_file_name
|
2324
|
+
signature.signature_type = 'PKCS7'
|
2325
|
+
signature.visible = true
|
2244
2326
|
|
2245
|
-
def test_put_page_convert_to_tiff
|
2246
|
-
name = "4pages.pdf"
|
2247
|
-
upload_file(name)
|
2248
|
-
result_file = "page.tiff"
|
2249
|
-
out_path = @temp_folder + '/' + result_file
|
2250
|
-
page_number = 2
|
2251
2327
|
opts = {
|
2328
|
+
:signature => signature,
|
2252
2329
|
:folder => @temp_folder
|
2253
2330
|
}
|
2254
|
-
|
2255
|
-
|
2331
|
+
|
2332
|
+
response = @pdf_api.post_sign_page(file_name, page_number, opts)
|
2333
|
+
assert(response, 'Failed to sign page.')
|
2256
2334
|
end
|
2257
2335
|
|
2258
|
-
def test_get_page_convert_to_jpeg
|
2259
|
-
name = "4pages.pdf"
|
2260
|
-
upload_file(name)
|
2261
2336
|
|
2262
|
-
|
2337
|
+
def test_get_verify_signature
|
2338
|
+
file_name = 'BlankWithSignature.pdf'
|
2339
|
+
upload_file(file_name)
|
2340
|
+
|
2341
|
+
signature_file_name = 'test1234.pfx'
|
2342
|
+
upload_file(signature_file_name)
|
2343
|
+
|
2344
|
+
rectangle = RectanglePdf.new
|
2345
|
+
rectangle.llx = 100
|
2346
|
+
rectangle.lly = 100
|
2347
|
+
rectangle.urx = 400
|
2348
|
+
rectangle.ury = 200
|
2349
|
+
|
2350
|
+
signature = Signature.new
|
2351
|
+
signature.authority = 'Sergey Smal'
|
2352
|
+
signature.contact = 'test@mail.ru'
|
2353
|
+
signature.date = '08/01/2012 12:15:00.000 PM'
|
2354
|
+
signature.form_field_name = 'Signature1'
|
2355
|
+
signature.location = 'Ukraine'
|
2356
|
+
signature.password = 'test1234'
|
2357
|
+
signature.rectangle = rectangle
|
2358
|
+
signature.signature_path = @temp_folder + '/' + signature_file_name
|
2359
|
+
signature.signature_type = SignatureType::PKCS7
|
2360
|
+
signature.visible = true
|
2361
|
+
|
2263
2362
|
opts = {
|
2363
|
+
:signature => signature,
|
2264
2364
|
:folder => @temp_folder
|
2265
2365
|
}
|
2266
2366
|
|
2267
|
-
|
2268
|
-
assert(
|
2269
|
-
end
|
2367
|
+
response_sign = @pdf_api.post_sign_document(file_name, opts)
|
2368
|
+
assert(response_sign, 'Failed to sign document.')
|
2270
2369
|
|
2271
|
-
def test_put_page_convert_to_jpeg
|
2272
|
-
name = "4pages.pdf"
|
2273
|
-
upload_file(name)
|
2274
|
-
result_file = "page.jpeg"
|
2275
|
-
out_path = @temp_folder + '/' + result_file
|
2276
|
-
page_number = 2
|
2277
2370
|
opts = {
|
2278
2371
|
:folder => @temp_folder
|
2279
2372
|
}
|
2280
|
-
response = @pdf_api.
|
2281
|
-
assert(response, 'Failed to
|
2373
|
+
response = @pdf_api.get_verify_signature(file_name, signature.form_field_name, opts)
|
2374
|
+
assert(response, 'Failed to verify signature.')
|
2282
2375
|
end
|
2283
2376
|
|
2284
|
-
def test_get_page_convert_to_png
|
2285
|
-
name = "4pages.pdf"
|
2286
|
-
upload_file(name)
|
2287
2377
|
|
2288
|
-
|
2289
|
-
|
2290
|
-
|
2291
|
-
|
2378
|
+
# Text Replace Tests
|
2379
|
+
|
2380
|
+
def test_post_document_text_replace
|
2381
|
+
file_name = 'marketing.pdf'
|
2382
|
+
upload_file(file_name)
|
2383
|
+
|
2384
|
+
rect = RectanglePdf.new
|
2385
|
+
rect.llx = 100
|
2386
|
+
rect.lly = 100
|
2387
|
+
rect.urx = 300
|
2388
|
+
rect.ury = 300
|
2389
|
+
|
2390
|
+
text_replace = TextReplace.new
|
2391
|
+
text_replace.old_value = 'market'
|
2392
|
+
text_replace.new_value = 'm_a_r_k_e_t'
|
2393
|
+
text_replace.regex = false
|
2394
|
+
text_replace.rect = rect
|
2395
|
+
|
2396
|
+
text_replace_list = TextReplaceListRequest.new
|
2397
|
+
text_replace_list.text_replaces = [text_replace]
|
2398
|
+
text_replace_list.start_index = 0
|
2399
|
+
text_replace_list.count_replace = 0
|
2292
2400
|
|
2293
|
-
response = @pdf_api.get_page_convert_to_png(name, page_number, opts)
|
2294
|
-
assert(response, 'Failed to convert page as png.')
|
2295
|
-
end
|
2296
2401
|
|
2297
|
-
def test_put_page_convert_to_png
|
2298
|
-
name = "4pages.pdf"
|
2299
|
-
upload_file(name)
|
2300
|
-
result_file = "page.png"
|
2301
|
-
out_path = @temp_folder + '/' + result_file
|
2302
|
-
page_number = 2
|
2303
2402
|
opts = {
|
2304
2403
|
:folder => @temp_folder
|
2305
2404
|
}
|
2306
|
-
|
2307
|
-
|
2405
|
+
|
2406
|
+
response = @pdf_api.post_document_text_replace(file_name, text_replace_list, opts)
|
2407
|
+
assert(response, 'Filed to replace document text by rect.')
|
2308
2408
|
end
|
2309
2409
|
|
2310
|
-
def test_get_page_convert_to_emf
|
2311
|
-
name = "4pages.pdf"
|
2312
|
-
upload_file(name)
|
2313
2410
|
|
2314
|
-
|
2411
|
+
def test_post_page_text_replace_by_rect
|
2412
|
+
file_name = 'marketing.pdf'
|
2413
|
+
upload_file(file_name)
|
2414
|
+
page_number = 1
|
2415
|
+
|
2416
|
+
rect = RectanglePdf.new
|
2417
|
+
rect.llx = 100
|
2418
|
+
rect.lly = 100
|
2419
|
+
rect.urx = 300
|
2420
|
+
rect.ury = 300
|
2421
|
+
|
2422
|
+
text_replace = TextReplace.new
|
2423
|
+
text_replace.old_value = 'market'
|
2424
|
+
text_replace.new_value = 'm_a_r_k_e_t'
|
2425
|
+
text_replace.regex = false
|
2426
|
+
text_replace.rect = rect
|
2427
|
+
|
2428
|
+
text_replace_list = TextReplaceListRequest.new
|
2429
|
+
text_replace_list.text_replaces = [text_replace]
|
2430
|
+
text_replace_list.start_index = 0
|
2431
|
+
text_replace_list.count_replace = 0
|
2432
|
+
|
2315
2433
|
opts = {
|
2316
2434
|
:folder => @temp_folder
|
2317
2435
|
}
|
2318
2436
|
|
2319
|
-
response = @pdf_api.
|
2320
|
-
assert(response, '
|
2437
|
+
response = @pdf_api.post_page_text_replace(file_name, page_number, text_replace_list, opts)
|
2438
|
+
assert(response, 'Filed to replace page text by rect.')
|
2321
2439
|
end
|
2322
2440
|
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2441
|
+
|
2442
|
+
# Text Tests
|
2443
|
+
|
2444
|
+
def test_get_text
|
2445
|
+
file_name = '4pages.pdf'
|
2446
|
+
upload_file(file_name)
|
2447
|
+
|
2448
|
+
llx = 0
|
2449
|
+
lly = 0
|
2450
|
+
urx = 0
|
2451
|
+
ury = 0
|
2329
2452
|
opts = {
|
2330
2453
|
:folder => @temp_folder
|
2331
2454
|
}
|
2332
|
-
|
2333
|
-
|
2455
|
+
|
2456
|
+
response = @pdf_api.get_text(file_name, llx, lly, urx, ury, opts)
|
2457
|
+
assert(response, 'Filed to get document text.')
|
2334
2458
|
end
|
2335
2459
|
|
2336
|
-
def
|
2337
|
-
|
2338
|
-
upload_file(
|
2460
|
+
def test_get_page_text_by_two_text_on_page
|
2461
|
+
file_name = '4pages.pdf'
|
2462
|
+
upload_file(file_name)
|
2339
2463
|
|
2340
|
-
page_number =
|
2464
|
+
page_number = 1
|
2465
|
+
llx = 0
|
2466
|
+
lly = 0
|
2467
|
+
urx = 0
|
2468
|
+
ury = 0
|
2341
2469
|
opts = {
|
2470
|
+
:format => ['First Page', 'Second Page'],
|
2471
|
+
# :format => 'First Page',
|
2342
2472
|
:folder => @temp_folder
|
2343
2473
|
}
|
2344
2474
|
|
2345
|
-
response = @pdf_api.
|
2346
|
-
assert(response, '
|
2475
|
+
response = @pdf_api.get_page_text(file_name, page_number, llx, lly, urx, ury, opts)
|
2476
|
+
assert(response, 'Filed to get document text.')
|
2347
2477
|
end
|
2348
2478
|
|
2349
|
-
def
|
2350
|
-
|
2351
|
-
upload_file(
|
2352
|
-
|
2353
|
-
|
2354
|
-
|
2479
|
+
def test_put_add_text
|
2480
|
+
file_name = '4pages.pdf'
|
2481
|
+
upload_file(file_name)
|
2482
|
+
|
2483
|
+
page_number = 1
|
2484
|
+
|
2485
|
+
rectangle = RectanglePdf.new
|
2486
|
+
rectangle.llx = 100
|
2487
|
+
rectangle.lly = 100
|
2488
|
+
rectangle.urx = 200
|
2489
|
+
rectangle.ury = 200
|
2490
|
+
|
2491
|
+
foreground_color = Color.new
|
2492
|
+
foreground_color.a = 0x00
|
2493
|
+
foreground_color.r = 0x00
|
2494
|
+
foreground_color.g = 0xFF
|
2495
|
+
foreground_color.b = 0x00
|
2496
|
+
|
2497
|
+
background_color = Color.new
|
2498
|
+
background_color.a = 0x00
|
2499
|
+
background_color.r = 0xFF
|
2500
|
+
background_color.g = 0x00
|
2501
|
+
background_color.b = 0x00
|
2502
|
+
|
2503
|
+
text_state = TextState.new
|
2504
|
+
text_state.font = 'Arial'
|
2505
|
+
text_state.font_size = 10
|
2506
|
+
text_state.foreground_color = foreground_color
|
2507
|
+
text_state.background_color = background_color
|
2508
|
+
text_state.font_style = FontStyles::BOLD
|
2509
|
+
|
2510
|
+
segment = Segment.new
|
2511
|
+
segment.value = 'segment 1'
|
2512
|
+
segment.text_state = text_state
|
2513
|
+
|
2514
|
+
text_line = TextLine.new
|
2515
|
+
text_line.horizontal_alignment = TextHorizontalAlignment::RIGHT
|
2516
|
+
text_line.segments = [segment]
|
2517
|
+
|
2518
|
+
paragraph = Paragraph.new
|
2519
|
+
paragraph.rectangle = rectangle
|
2520
|
+
paragraph.left_margin = 10
|
2521
|
+
paragraph.right_margin = 10
|
2522
|
+
paragraph.top_margin = 20
|
2523
|
+
paragraph.bottom_margin = 20
|
2524
|
+
paragraph.horizontal_alignment = TextHorizontalAlignment::FULL_JUSTIFY
|
2525
|
+
paragraph.line_spacing = LineSpacing::FONT_SIZE
|
2526
|
+
paragraph.rotation = 10
|
2527
|
+
paragraph.subsequent_lines_indent = 20
|
2528
|
+
paragraph.vertical_alignment = VerticalAlignment::CENTER
|
2529
|
+
paragraph.wrap_mode = WrapMode::BY_WORDS
|
2530
|
+
paragraph.lines = [text_line]
|
2531
|
+
|
2355
2532
|
opts = {
|
2533
|
+
:paragraph => paragraph,
|
2356
2534
|
:folder => @temp_folder
|
2357
2535
|
}
|
2358
|
-
|
2359
|
-
|
2536
|
+
|
2537
|
+
response = @pdf_api.put_add_text(file_name, page_number, opts)
|
2538
|
+
assert(response, 'Failed to add text to the page.')
|
2360
2539
|
end
|
2361
2540
|
|
2362
|
-
def test_get_page_convert_to_gif
|
2363
|
-
name = "4pages.pdf"
|
2364
|
-
upload_file(name)
|
2365
2541
|
|
2366
|
-
|
2367
|
-
opts = {
|
2368
|
-
:folder => @temp_folder
|
2369
|
-
}
|
2542
|
+
# Upload & Download Tests
|
2370
2543
|
|
2371
|
-
|
2372
|
-
|
2544
|
+
def test_put_create
|
2545
|
+
file_name = '4pages.pdf'
|
2546
|
+
|
2547
|
+
response = @pdf_api.put_create(@temp_folder + '/' + file_name, File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) } )
|
2548
|
+
assert(response, "Failed to upload #{file_name} file.")
|
2373
2549
|
end
|
2374
2550
|
|
2375
|
-
def
|
2376
|
-
|
2377
|
-
upload_file(
|
2378
|
-
|
2379
|
-
|
2380
|
-
|
2381
|
-
|
2382
|
-
:folder => @temp_folder
|
2383
|
-
}
|
2384
|
-
response = @pdf_api.put_page_convert_to_gif(name, page_number, out_path, opts)
|
2385
|
-
assert(response, 'Failed to convert page as gif.')
|
2551
|
+
def test_get_download
|
2552
|
+
file_name = '4pages.pdf'
|
2553
|
+
upload_file(file_name)
|
2554
|
+
|
2555
|
+
|
2556
|
+
response = @pdf_api.get_download(@temp_folder + '/' + file_name)
|
2557
|
+
assert(response, "Failed to download #{file_name} file.")
|
2386
2558
|
end
|
2387
2559
|
end
|
2388
|
-
|