pdf4me 1.0.1 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{LICENSE → LICENSE.txt} +6 -6
- data/README.md +124 -395
- data/lib/pdf4me.rb +40 -110
- data/lib/pdf4me/actions/complex_action.rb +64 -0
- data/lib/pdf4me/actions/convert_file_to_pdf.rb +30 -0
- data/lib/pdf4me/actions/convert_to_pdf.rb +14 -0
- data/lib/pdf4me/actions/create_pdf_a.rb +29 -0
- data/lib/pdf4me/actions/create_thumbnail.rb +55 -0
- data/lib/pdf4me/actions/extract_pages.rb +49 -0
- data/lib/pdf4me/actions/merge_two_pdfs.rb +34 -0
- data/lib/pdf4me/actions/optimize.rb +10 -0
- data/lib/pdf4me/actions/optimize_by_profile.rb +42 -0
- data/lib/pdf4me/actions/split_by_page_nr.rb +55 -0
- data/lib/pdf4me/actions/text_stamp.rb +63 -0
- data/lib/pdf4me/actions/wrapper_action.rb +65 -0
- data/lib/pdf4me/client.rb +87 -0
- data/lib/pdf4me/configuration.rb +9 -88
- data/lib/pdf4me/exceptions.rb +26 -0
- data/lib/pdf4me/models/base.rb +26 -0
- data/lib/pdf4me/models/convert_to_pdf_action.rb +26 -246
- data/lib/pdf4me/models/convert_to_pdf_res.rb +5 -185
- data/lib/pdf4me/models/doc_log.rb +12 -257
- data/lib/pdf4me/models/doc_metadata.rb +13 -282
- data/lib/pdf4me/models/document.rb +14 -282
- data/lib/pdf4me/models/notification.rb +8 -191
- data/lib/pdf4me/models/optimize_action.rb +72 -508
- data/lib/pdf4me/models/optimize_res.rb +5 -195
- data/lib/pdf4me/models/page.rb +12 -254
- data/lib/pdf4me/utils/assigner.rb +10 -0
- data/lib/pdf4me/utils/serializer.rb +43 -0
- data/lib/pdf4me/version.rb +1 -13
- data/spec/actions/create_pdf_a_spec.rb +21 -0
- data/spec/actions/wrapper_action_spec.rb +24 -0
- data/spec/files/4.pdf +0 -0
- data/spec/spec_helper.rb +17 -100
- metadata +70 -421
- data/Gemfile +0 -7
- data/Rakefile +0 -8
- data/docs/ActionFlow.md +0 -8
- data/docs/ApiUsageRes.md +0 -11
- data/docs/ArchiveConfig.md +0 -11
- data/docs/ArchiveJobReq.md +0 -12
- data/docs/ArchiveJobRes.md +0 -9
- data/docs/Color.md +0 -10
- data/docs/ConvertApi.md +0 -102
- data/docs/ConvertToPdf.md +0 -10
- data/docs/ConvertToPdfAction.md +0 -10
- data/docs/ConvertToPdfRes.md +0 -8
- data/docs/CreateImages.md +0 -10
- data/docs/CreateImagesRes.md +0 -8
- data/docs/CreatePdfA.md +0 -10
- data/docs/CreatePdfARes.md +0 -8
- data/docs/CustomCMSConfig.md +0 -23
- data/docs/DocAction.md +0 -8
- data/docs/DocLog.md +0 -12
- data/docs/DocMetadata.md +0 -16
- data/docs/Document.md +0 -16
- data/docs/DocumentApi.md +0 -203
- data/docs/DropDocumentReq.md +0 -20
- data/docs/DropDocumentRes.md +0 -15
- data/docs/ExecutionTrigger.md +0 -10
- data/docs/Extract.md +0 -10
- data/docs/ExtractAction.md +0 -9
- data/docs/ExtractApi.md +0 -102
- data/docs/ExtractRes.md +0 -8
- data/docs/GetDocumentListRes.md +0 -13
- data/docs/GetDocumentReq.md +0 -14
- data/docs/GetDocumentRes.md +0 -14
- data/docs/IFormFile.md +0 -13
- data/docs/Image.md +0 -15
- data/docs/ImageAction.md +0 -30
- data/docs/ImageApi.md +0 -107
- data/docs/Job.md +0 -10
- data/docs/JobApi.md +0 -197
- data/docs/JobConfig.md +0 -18
- data/docs/JobConfigRes.md +0 -8
- data/docs/KeyValuePairStringObject.md +0 -9
- data/docs/KeyValuePairStringString.md +0 -9
- data/docs/ManagementApi.md +0 -92
- data/docs/Merge.md +0 -10
- data/docs/MergeAction.md +0 -8
- data/docs/MergeApi.md +0 -102
- data/docs/MergeRes.md +0 -8
- data/docs/Notification.md +0 -9
- data/docs/OcrAction.md +0 -12
- data/docs/OcrApi.md +0 -57
- data/docs/Optimize.md +0 -10
- data/docs/OptimizeAction.md +0 -35
- data/docs/OptimizeApi.md +0 -103
- data/docs/OptimizeRes.md +0 -9
- data/docs/Page.md +0 -14
- data/docs/PageSelection.md +0 -10
- data/docs/Pdf4meAction.md +0 -12
- data/docs/Pdf4meDocument.md +0 -32
- data/docs/Pdf4meException.md +0 -8
- data/docs/PdfAAction.md +0 -14
- data/docs/PdfAApi.md +0 -102
- data/docs/PdfFont.md +0 -9
- data/docs/Pricing.md +0 -13
- data/docs/ProduceDocuments.md +0 -14
- data/docs/ProduceDocumentsRes.md +0 -8
- data/docs/ProduceOutput.md +0 -8
- data/docs/RGBSet.md +0 -10
- data/docs/RecognizeDocument.md +0 -10
- data/docs/RecognizeDocumentRes.md +0 -9
- data/docs/Rectangle.md +0 -11
- data/docs/Rotate.md +0 -10
- data/docs/RunJobRes.md +0 -10
- data/docs/SignatureConfig.md +0 -7
- data/docs/Split.md +0 -10
- data/docs/SplitAction.md +0 -11
- data/docs/SplitApi.md +0 -103
- data/docs/SplitRes.md +0 -8
- data/docs/Stamp.md +0 -10
- data/docs/StampAction.md +0 -22
- data/docs/StampApi.md +0 -110
- data/docs/StampRes.md +0 -8
- data/docs/StorageFolder.md +0 -10
- data/docs/Text.md +0 -17
- data/docs/Transform.md +0 -13
- data/docs/Translate.md +0 -9
- data/docs/UserFingerprint.md +0 -9
- data/docs/VersionRes.md +0 -8
- data/docs/java.md +0 -425
- data/lib/pdf4me/api/convert_api.rb +0 -130
- data/lib/pdf4me/api/document_api.rb +0 -218
- data/lib/pdf4me/api/extract_api.rb +0 -131
- data/lib/pdf4me/api/image_api.rb +0 -139
- data/lib/pdf4me/api/job_api.rb +0 -223
- data/lib/pdf4me/api/management_api.rb +0 -117
- data/lib/pdf4me/api/merge_api.rb +0 -131
- data/lib/pdf4me/api/ocr_api.rb +0 -74
- data/lib/pdf4me/api/optimize_api.rb +0 -139
- data/lib/pdf4me/api/pdf_a_api.rb +0 -134
- data/lib/pdf4me/api/split_api.rb +0 -135
- data/lib/pdf4me/api/stamp_api.rb +0 -159
- data/lib/pdf4me/api_client.rb +0 -380
- data/lib/pdf4me/api_error.rb +0 -38
- data/lib/pdf4me/models/action_flow.rb +0 -190
- data/lib/pdf4me/models/api_usage_res.rb +0 -219
- data/lib/pdf4me/models/archive_config.rb +0 -226
- data/lib/pdf4me/models/archive_job_req.rb +0 -249
- data/lib/pdf4me/models/archive_job_res.rb +0 -207
- data/lib/pdf4me/models/color.rb +0 -206
- data/lib/pdf4me/models/convert_to_pdf.rb +0 -209
- data/lib/pdf4me/models/create_images.rb +0 -209
- data/lib/pdf4me/models/create_images_res.rb +0 -189
- data/lib/pdf4me/models/create_pdf_a.rb +0 -209
- data/lib/pdf4me/models/create_pdf_a_res.rb +0 -189
- data/lib/pdf4me/models/custom_cms_config.rb +0 -323
- data/lib/pdf4me/models/doc_action.rb +0 -190
- data/lib/pdf4me/models/drop_document_req.rb +0 -348
- data/lib/pdf4me/models/drop_document_res.rb +0 -260
- data/lib/pdf4me/models/execution_trigger.rb +0 -206
- data/lib/pdf4me/models/extract.rb +0 -207
- data/lib/pdf4me/models/extract_action.rb +0 -201
- data/lib/pdf4me/models/extract_res.rb +0 -188
- data/lib/pdf4me/models/get_document_list_res.rb +0 -237
- data/lib/pdf4me/models/get_document_req.rb +0 -243
- data/lib/pdf4me/models/get_document_res.rb +0 -246
- data/lib/pdf4me/models/i_form_file.rb +0 -235
- data/lib/pdf4me/models/image.rb +0 -300
- data/lib/pdf4me/models/image_action.rb +0 -513
- data/lib/pdf4me/models/job.rb +0 -213
- data/lib/pdf4me/models/job_config.rb +0 -298
- data/lib/pdf4me/models/job_config_res.rb +0 -193
- data/lib/pdf4me/models/key_value_pair_string_object.rb +0 -197
- data/lib/pdf4me/models/key_value_pair_string_string.rb +0 -197
- data/lib/pdf4me/models/merge.rb +0 -209
- data/lib/pdf4me/models/merge_action.rb +0 -190
- data/lib/pdf4me/models/merge_res.rb +0 -188
- data/lib/pdf4me/models/ocr_action.rb +0 -259
- data/lib/pdf4me/models/optimize.rb +0 -209
- data/lib/pdf4me/models/page_selection.rb +0 -246
- data/lib/pdf4me/models/pdf4me_action.rb +0 -259
- data/lib/pdf4me/models/pdf4me_document.rb +0 -511
- data/lib/pdf4me/models/pdf4me_exception.rb +0 -189
- data/lib/pdf4me/models/pdf_a_action.rb +0 -297
- data/lib/pdf4me/models/pdf_font.rb +0 -213
- data/lib/pdf4me/models/pricing.rb +0 -278
- data/lib/pdf4me/models/produce_documents.rb +0 -251
- data/lib/pdf4me/models/produce_documents_res.rb +0 -191
- data/lib/pdf4me/models/produce_output.rb +0 -221
- data/lib/pdf4me/models/recognize_document.rb +0 -209
- data/lib/pdf4me/models/recognize_document_res.rb +0 -198
- data/lib/pdf4me/models/rectangle.rb +0 -215
- data/lib/pdf4me/models/rgb_set.rb +0 -206
- data/lib/pdf4me/models/rotate.rb +0 -221
- data/lib/pdf4me/models/run_job_res.rb +0 -215
- data/lib/pdf4me/models/signature_config.rb +0 -179
- data/lib/pdf4me/models/split.rb +0 -207
- data/lib/pdf4me/models/split_action.rb +0 -219
- data/lib/pdf4me/models/split_res.rb +0 -190
- data/lib/pdf4me/models/stamp.rb +0 -209
- data/lib/pdf4me/models/stamp_action.rb +0 -387
- data/lib/pdf4me/models/stamp_res.rb +0 -189
- data/lib/pdf4me/models/storage_folder.rb +0 -239
- data/lib/pdf4me/models/text.rb +0 -320
- data/lib/pdf4me/models/transform.rb +0 -263
- data/lib/pdf4me/models/translate.rb +0 -207
- data/lib/pdf4me/models/user_fingerprint.rb +0 -197
- data/lib/pdf4me/models/version_res.rb +0 -188
- data/pdf4me.gemspec +0 -47
- data/spec/api/convert_api_spec.rb +0 -60
- data/spec/api/document_api_spec.rb +0 -83
- data/spec/api/extract_api_spec.rb +0 -60
- data/spec/api/image_api_spec.rb +0 -62
- data/spec/api/job_api_spec.rb +0 -82
- data/spec/api/management_api_spec.rb +0 -57
- data/spec/api/merge_api_spec.rb +0 -60
- data/spec/api/ocr_api_spec.rb +0 -47
- data/spec/api/optimize_api_spec.rb +0 -60
- data/spec/api/pdf_a_api_spec.rb +0 -60
- data/spec/api/split_api_spec.rb +0 -60
- data/spec/api/stamp_api_spec.rb +0 -63
- data/spec/api_client_spec.rb +0 -226
- data/spec/configuration_spec.rb +0 -42
- data/spec/models/action_flow_spec.rb +0 -42
- data/spec/models/api_usage_res_spec.rb +0 -60
- data/spec/models/archive_config_spec.rb +0 -60
- data/spec/models/archive_job_req_spec.rb +0 -66
- data/spec/models/archive_job_res_spec.rb +0 -48
- data/spec/models/color_spec.rb +0 -54
- data/spec/models/convert_to_pdf_action_spec.rb +0 -62
- data/spec/models/convert_to_pdf_res_spec.rb +0 -42
- data/spec/models/convert_to_pdf_spec.rb +0 -54
- data/spec/models/create_images_res_spec.rb +0 -42
- data/spec/models/create_images_spec.rb +0 -54
- data/spec/models/create_pdf_a_res_spec.rb +0 -42
- data/spec/models/create_pdf_a_spec.rb +0 -54
- data/spec/models/custom_cms_config_spec.rb +0 -132
- data/spec/models/doc_action_spec.rb +0 -42
- data/spec/models/doc_log_spec.rb +0 -70
- data/spec/models/doc_metadata_spec.rb +0 -90
- data/spec/models/document_spec.rb +0 -90
- data/spec/models/drop_document_req_spec.rb +0 -118
- data/spec/models/drop_document_res_spec.rb +0 -84
- data/spec/models/execution_trigger_spec.rb +0 -54
- data/spec/models/extract_action_spec.rb +0 -48
- data/spec/models/extract_res_spec.rb +0 -42
- data/spec/models/extract_spec.rb +0 -54
- data/spec/models/get_document_list_res_spec.rb +0 -72
- data/spec/models/get_document_req_spec.rb +0 -78
- data/spec/models/get_document_res_spec.rb +0 -78
- data/spec/models/i_form_file_spec.rb +0 -72
- data/spec/models/image_action_spec.rb +0 -206
- data/spec/models/image_spec.rb +0 -88
- data/spec/models/job_config_res_spec.rb +0 -42
- data/spec/models/job_config_spec.rb +0 -102
- data/spec/models/job_spec.rb +0 -54
- data/spec/models/key_value_pair_string_object_spec.rb +0 -48
- data/spec/models/key_value_pair_string_string_spec.rb +0 -48
- data/spec/models/merge_action_spec.rb +0 -42
- data/spec/models/merge_res_spec.rb +0 -42
- data/spec/models/merge_spec.rb +0 -54
- data/spec/models/notification_spec.rb +0 -48
- data/spec/models/ocr_action_spec.rb +0 -70
- data/spec/models/optimize_action_spec.rb +0 -228
- data/spec/models/optimize_res_spec.rb +0 -48
- data/spec/models/optimize_spec.rb +0 -54
- data/spec/models/page_selection_spec.rb +0 -58
- data/spec/models/page_spec.rb +0 -78
- data/spec/models/pdf4me_action_spec.rb +0 -70
- data/spec/models/pdf4me_document_spec.rb +0 -202
- data/spec/models/pdf4me_exception_spec.rb +0 -42
- data/spec/models/pdf_a_action_spec.rb +0 -86
- data/spec/models/pdf_font_spec.rb +0 -48
- data/spec/models/pricing_spec.rb +0 -80
- data/spec/models/produce_documents_res_spec.rb +0 -42
- data/spec/models/produce_documents_spec.rb +0 -78
- data/spec/models/produce_output_spec.rb +0 -46
- data/spec/models/recognize_document_res_spec.rb +0 -48
- data/spec/models/recognize_document_spec.rb +0 -54
- data/spec/models/rectangle_spec.rb +0 -60
- data/spec/models/rgb_set_spec.rb +0 -54
- data/spec/models/rotate_spec.rb +0 -54
- data/spec/models/run_job_res_spec.rb +0 -54
- data/spec/models/signature_config_spec.rb +0 -36
- data/spec/models/split_action_spec.rb +0 -60
- data/spec/models/split_res_spec.rb +0 -42
- data/spec/models/split_spec.rb +0 -54
- data/spec/models/stamp_action_spec.rb +0 -142
- data/spec/models/stamp_res_spec.rb +0 -42
- data/spec/models/stamp_spec.rb +0 -54
- data/spec/models/storage_folder_spec.rb +0 -58
- data/spec/models/text_spec.rb +0 -104
- data/spec/models/transform_spec.rb +0 -72
- data/spec/models/translate_spec.rb +0 -48
- data/spec/models/user_fingerprint_spec.rb +0 -48
- data/spec/models/version_res_spec.rb +0 -42
data/lib/pdf4me.rb
CHANGED
@@ -1,124 +1,54 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'active_model'
|
2
|
+
require 'faraday'
|
3
|
+
require 'json'
|
4
|
+
require 'logger'
|
5
|
+
require 'pry'
|
6
|
+
require 'uri'
|
7
|
+
require 'typhoeus'
|
8
|
+
require 'date'
|
3
9
|
|
4
|
-
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
-
|
6
|
-
OpenAPI spec version: v1
|
7
|
-
|
8
|
-
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.3.0
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
# Common files
|
14
|
-
require 'pdf4me/api_client'
|
15
|
-
require 'pdf4me/api_error'
|
16
10
|
require 'pdf4me/version'
|
17
11
|
require 'pdf4me/configuration'
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
require 'pdf4me/
|
23
|
-
require 'pdf4me/
|
24
|
-
|
25
|
-
require 'pdf4me/
|
26
|
-
require 'pdf4me/
|
12
|
+
require 'pdf4me/client'
|
13
|
+
require 'pdf4me/exceptions'
|
14
|
+
|
15
|
+
#utils
|
16
|
+
require 'pdf4me/utils/assigner'
|
17
|
+
require 'pdf4me/utils/serializer'
|
18
|
+
|
19
|
+
require 'pdf4me/actions/wrapper_action'
|
20
|
+
require 'pdf4me/actions/optimize_by_profile'
|
21
|
+
require 'pdf4me/actions/convert_file_to_pdf'
|
22
|
+
require 'pdf4me/actions/extract_pages'
|
23
|
+
require 'pdf4me/actions/create_thumbnail'
|
24
|
+
require 'pdf4me/actions/merge_two_pdfs'
|
25
|
+
require 'pdf4me/actions/create_pdf_a'
|
26
|
+
require 'pdf4me/actions/split_by_page_nr'
|
27
|
+
require 'pdf4me/actions/text_stamp'
|
28
|
+
|
29
|
+
# complex operations
|
30
|
+
require 'pdf4me/actions/complex_action'
|
31
|
+
require 'pdf4me/actions/convert_to_pdf'
|
32
|
+
require 'pdf4me/actions/optimize'
|
33
|
+
|
34
|
+
# models
|
35
|
+
require 'pdf4me/models/base'
|
36
|
+
require 'pdf4me/models/document'
|
27
37
|
require 'pdf4me/models/convert_to_pdf_action'
|
38
|
+
require 'pdf4me/models/notification'
|
28
39
|
require 'pdf4me/models/convert_to_pdf_res'
|
29
|
-
require 'pdf4me/models/create_images'
|
30
|
-
require 'pdf4me/models/create_images_res'
|
31
|
-
require 'pdf4me/models/create_pdf_a'
|
32
|
-
require 'pdf4me/models/create_pdf_a_res'
|
33
|
-
require 'pdf4me/models/custom_cms_config'
|
34
|
-
require 'pdf4me/models/doc_action'
|
35
40
|
require 'pdf4me/models/doc_log'
|
36
41
|
require 'pdf4me/models/doc_metadata'
|
37
|
-
require 'pdf4me/models/
|
38
|
-
require 'pdf4me/models/drop_document_req'
|
39
|
-
require 'pdf4me/models/drop_document_res'
|
40
|
-
require 'pdf4me/models/execution_trigger'
|
41
|
-
require 'pdf4me/models/extract'
|
42
|
-
require 'pdf4me/models/extract_action'
|
43
|
-
require 'pdf4me/models/extract_res'
|
44
|
-
require 'pdf4me/models/get_document_list_res'
|
45
|
-
require 'pdf4me/models/get_document_req'
|
46
|
-
require 'pdf4me/models/get_document_res'
|
47
|
-
require 'pdf4me/models/i_form_file'
|
48
|
-
require 'pdf4me/models/image'
|
49
|
-
require 'pdf4me/models/image_action'
|
50
|
-
require 'pdf4me/models/job'
|
51
|
-
require 'pdf4me/models/job_config'
|
52
|
-
require 'pdf4me/models/job_config_res'
|
53
|
-
require 'pdf4me/models/key_value_pair_string_object'
|
54
|
-
require 'pdf4me/models/key_value_pair_string_string'
|
55
|
-
require 'pdf4me/models/merge'
|
56
|
-
require 'pdf4me/models/merge_action'
|
57
|
-
require 'pdf4me/models/merge_res'
|
58
|
-
require 'pdf4me/models/notification'
|
59
|
-
require 'pdf4me/models/ocr_action'
|
60
|
-
require 'pdf4me/models/optimize'
|
42
|
+
require 'pdf4me/models/page'
|
61
43
|
require 'pdf4me/models/optimize_action'
|
62
44
|
require 'pdf4me/models/optimize_res'
|
63
|
-
require 'pdf4me/models/page'
|
64
|
-
require 'pdf4me/models/page_selection'
|
65
|
-
require 'pdf4me/models/pdf4me_action'
|
66
|
-
require 'pdf4me/models/pdf4me_document'
|
67
|
-
require 'pdf4me/models/pdf4me_exception'
|
68
|
-
require 'pdf4me/models/pdf_a_action'
|
69
|
-
require 'pdf4me/models/pdf_font'
|
70
|
-
require 'pdf4me/models/pricing'
|
71
|
-
require 'pdf4me/models/produce_documents'
|
72
|
-
require 'pdf4me/models/produce_documents_res'
|
73
|
-
require 'pdf4me/models/produce_output'
|
74
|
-
require 'pdf4me/models/rgb_set'
|
75
|
-
require 'pdf4me/models/recognize_document'
|
76
|
-
require 'pdf4me/models/recognize_document_res'
|
77
|
-
require 'pdf4me/models/rectangle'
|
78
|
-
require 'pdf4me/models/rotate'
|
79
|
-
require 'pdf4me/models/run_job_res'
|
80
|
-
require 'pdf4me/models/signature_config'
|
81
|
-
require 'pdf4me/models/split'
|
82
|
-
require 'pdf4me/models/split_action'
|
83
|
-
require 'pdf4me/models/split_res'
|
84
|
-
require 'pdf4me/models/stamp'
|
85
|
-
require 'pdf4me/models/stamp_action'
|
86
|
-
require 'pdf4me/models/stamp_res'
|
87
|
-
require 'pdf4me/models/storage_folder'
|
88
|
-
require 'pdf4me/models/text'
|
89
|
-
require 'pdf4me/models/transform'
|
90
|
-
require 'pdf4me/models/translate'
|
91
|
-
require 'pdf4me/models/user_fingerprint'
|
92
|
-
require 'pdf4me/models/version_res'
|
93
|
-
|
94
|
-
# APIs
|
95
|
-
require 'pdf4me/api/convert_api'
|
96
|
-
require 'pdf4me/api/document_api'
|
97
|
-
require 'pdf4me/api/extract_api'
|
98
|
-
require 'pdf4me/api/image_api'
|
99
|
-
require 'pdf4me/api/job_api'
|
100
|
-
require 'pdf4me/api/management_api'
|
101
|
-
require 'pdf4me/api/merge_api'
|
102
|
-
require 'pdf4me/api/ocr_api'
|
103
|
-
require 'pdf4me/api/optimize_api'
|
104
|
-
require 'pdf4me/api/pdf_a_api'
|
105
|
-
require 'pdf4me/api/split_api'
|
106
|
-
require 'pdf4me/api/stamp_api'
|
107
45
|
|
108
46
|
module Pdf4me
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
# end
|
115
|
-
# If no block given, return the default Configuration object.
|
116
|
-
def configure
|
117
|
-
if block_given?
|
118
|
-
yield(Configuration.default)
|
119
|
-
else
|
120
|
-
Configuration.default
|
121
|
-
end
|
47
|
+
def self.configure
|
48
|
+
if block_given?
|
49
|
+
yield(Configuration.default)
|
50
|
+
else
|
51
|
+
Configuration.default
|
122
52
|
end
|
123
53
|
end
|
124
54
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class ComplexAction
|
3
|
+
attr_reader :client
|
4
|
+
|
5
|
+
def client
|
6
|
+
@client ||= Client.default
|
7
|
+
end
|
8
|
+
|
9
|
+
def assign_attributes(attributes = {})
|
10
|
+
attributes.to_h.each do |key, value|
|
11
|
+
writer_method = "#{key}="
|
12
|
+
send(writer_method, value) if respond_to?(writer_method)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(attributes = {})
|
17
|
+
assign_attributes(attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
return unless valid?
|
22
|
+
response = client.post(
|
23
|
+
path,
|
24
|
+
serialize_attributes.to_json
|
25
|
+
)
|
26
|
+
Pdf4me.const_get("#{self.class.name}Res").from_response(response)
|
27
|
+
end
|
28
|
+
|
29
|
+
def valid?
|
30
|
+
valid_objects? && valid_instances?
|
31
|
+
end
|
32
|
+
|
33
|
+
def errors
|
34
|
+
errors = attributes.map do |attribute|
|
35
|
+
send(attribute).errors.full_messages
|
36
|
+
end
|
37
|
+
errors.flatten
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
42
|
+
def attributes
|
43
|
+
self.class::ATTRIBUTES
|
44
|
+
end
|
45
|
+
|
46
|
+
def valid_objects?
|
47
|
+
attributes.all? do |value|
|
48
|
+
send(value).class.name == "pdf4me/#{value}".classify
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def valid_instances?
|
53
|
+
attributes.all? do |attribute|
|
54
|
+
send(attribute).valid?
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def serialize_attributes
|
59
|
+
attributes.each_with_object({}) do |attribute, hash|
|
60
|
+
hash[attribute.camelize(:lower)] = send(attribute).attributes
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class ConvertFileToPdf < WrapperAction
|
3
|
+
attr_accessor(
|
4
|
+
:file,
|
5
|
+
:save_path
|
6
|
+
)
|
7
|
+
validates_presence_of(
|
8
|
+
:file,
|
9
|
+
:save_path
|
10
|
+
)
|
11
|
+
|
12
|
+
def path
|
13
|
+
'/Convert/ConvertFileToPdf'
|
14
|
+
end
|
15
|
+
|
16
|
+
def save_path
|
17
|
+
@save_path ||= File.join(File.dirname(file), "#{File.basename(file, ".*")}.pdf")
|
18
|
+
end
|
19
|
+
|
20
|
+
def call_api
|
21
|
+
client.multipart_post(
|
22
|
+
path,
|
23
|
+
file_name: File.basename(file),
|
24
|
+
file: File.open(file, 'rb'),
|
25
|
+
) do |request|
|
26
|
+
download(request, save_path)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class ConvertToPdf < ComplexAction
|
3
|
+
ATTRIBUTES = %w|document convert_to_pdf_action notification|
|
4
|
+
attr_accessor *ATTRIBUTES
|
5
|
+
|
6
|
+
def path
|
7
|
+
'/Convert/ConvertToPdf'
|
8
|
+
end
|
9
|
+
|
10
|
+
def notification
|
11
|
+
@notification || Pdf4me::Notification.new
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class CreatePdfA < WrapperAction
|
3
|
+
attr_accessor(
|
4
|
+
:file,
|
5
|
+
:compliance
|
6
|
+
)
|
7
|
+
validates_presence_of(
|
8
|
+
:compliance,
|
9
|
+
:file
|
10
|
+
)
|
11
|
+
validates_inclusion_of(
|
12
|
+
:compliance,
|
13
|
+
in: %w|pdfA1b pdfA1a pdfA2b pdfA2u pdfA2a pdfA3b pdfA3u pdfA3a|,
|
14
|
+
message: 'is invalid. It should be any of pdfA1b, pdfA1a, pdfA2b, pdfA2u, pdfA2a, pdfA3b, pdfA3u, pdfA3a'
|
15
|
+
)
|
16
|
+
|
17
|
+
def path
|
18
|
+
'/PdfA/CreatePdfA'
|
19
|
+
end
|
20
|
+
|
21
|
+
def call_api
|
22
|
+
client.multipart_post(
|
23
|
+
path,
|
24
|
+
file: File.open(file, 'rb'),
|
25
|
+
pdfCompliance: compliance
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class CreateThumbnail < WrapperAction
|
3
|
+
attr_accessor(
|
4
|
+
:file,
|
5
|
+
:width,
|
6
|
+
:page_number,
|
7
|
+
:image_format,
|
8
|
+
:save_path
|
9
|
+
)
|
10
|
+
|
11
|
+
validates_presence_of(
|
12
|
+
:file,
|
13
|
+
:page_number,
|
14
|
+
:width,
|
15
|
+
:image_format,
|
16
|
+
:save_path
|
17
|
+
)
|
18
|
+
|
19
|
+
validates_inclusion_of(
|
20
|
+
:image_format,
|
21
|
+
in: %w|jpg jpeg bmp gif jb2 jp2 jpf jpx png tif tiff"|,
|
22
|
+
message: 'is invalid - should be one of jpg, jpeg, bmp, gif, jb2, jp2, jpf, jpx, png, tif, tiff'
|
23
|
+
)
|
24
|
+
validates_numericality_of :page_number, :width
|
25
|
+
|
26
|
+
def path
|
27
|
+
'/Image/CreateThumbnail'
|
28
|
+
end
|
29
|
+
|
30
|
+
def defaults
|
31
|
+
{
|
32
|
+
width: 100,
|
33
|
+
image_format: 'png',
|
34
|
+
page_number: 1
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def save_path
|
39
|
+
@save_path ||= File.join(File.dirname(file), "#{File.basename(file, ".*")}-thumbnail.#{image_format}")
|
40
|
+
end
|
41
|
+
|
42
|
+
def call_api
|
43
|
+
client.multipart_post(
|
44
|
+
path,
|
45
|
+
file: File.open(file, 'rb'),
|
46
|
+
pageNr: page_number,
|
47
|
+
width: width,
|
48
|
+
imageFormat: image_format
|
49
|
+
) do |request|
|
50
|
+
download(request, save_path)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class ExtractPages < WrapperAction
|
3
|
+
attr_accessor(
|
4
|
+
:file,
|
5
|
+
:save_path,
|
6
|
+
:pages
|
7
|
+
)
|
8
|
+
validates_presence_of(
|
9
|
+
:file,
|
10
|
+
:save_path
|
11
|
+
)
|
12
|
+
|
13
|
+
validate :page_attributes
|
14
|
+
|
15
|
+
def pages=(value)
|
16
|
+
@pages = Array(value)
|
17
|
+
end
|
18
|
+
|
19
|
+
def path
|
20
|
+
'/Extract/ExtractPages'
|
21
|
+
end
|
22
|
+
|
23
|
+
def save_path
|
24
|
+
@save_path ||= File.join(File.dirname(file), "extracted_pages.pdf")
|
25
|
+
end
|
26
|
+
|
27
|
+
def call_api
|
28
|
+
client.multipart_post(
|
29
|
+
path,
|
30
|
+
file: File.open(file, 'rb'),
|
31
|
+
pageNrs: pages.join(',')
|
32
|
+
) do |request|
|
33
|
+
download(request, save_path)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def page_attributes
|
40
|
+
if pages.empty?
|
41
|
+
errors.add(:pages, 'must be valid numeric value')
|
42
|
+
end
|
43
|
+
|
44
|
+
unless pages.all? {|i| i.is_a?(Integer) }
|
45
|
+
errors.add(:pages, 'contains values that are not numbers')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class MergeTwoPdfs < WrapperAction
|
3
|
+
attr_accessor(
|
4
|
+
:file1,
|
5
|
+
:file2,
|
6
|
+
:save_path
|
7
|
+
)
|
8
|
+
validates_presence_of(
|
9
|
+
:file1,
|
10
|
+
:file2
|
11
|
+
)
|
12
|
+
|
13
|
+
def path
|
14
|
+
'/Merge/Merge2Pdfs'
|
15
|
+
end
|
16
|
+
|
17
|
+
def save_path
|
18
|
+
@save_path ||= File.join(
|
19
|
+
File.dirname(file1),
|
20
|
+
"Merged-#{File.basename(file1, ".*")}-#{File.basename(file2, ".*")}.pdf"
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def call_api
|
25
|
+
client.multipart_post(
|
26
|
+
path,
|
27
|
+
file1: File.open(file1, 'rb'),
|
28
|
+
file2: File.open(file2, 'rb'),
|
29
|
+
) do |request|
|
30
|
+
download(request, save_path)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|