pdf4me 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/README.md +472 -0
- data/Rakefile +8 -0
- data/docs/ActionFlow.md +8 -0
- data/docs/ApiUsageRes.md +11 -0
- data/docs/ArchiveConfig.md +11 -0
- data/docs/ArchiveJobReq.md +12 -0
- data/docs/ArchiveJobRes.md +9 -0
- data/docs/Color.md +10 -0
- data/docs/ConvertApi.md +102 -0
- data/docs/ConvertToPdf.md +10 -0
- data/docs/ConvertToPdfAction.md +10 -0
- data/docs/ConvertToPdfRes.md +8 -0
- data/docs/CreateImages.md +10 -0
- data/docs/CreateImagesRes.md +8 -0
- data/docs/CreatePdfA.md +10 -0
- data/docs/CreatePdfARes.md +8 -0
- data/docs/CustomCMSConfig.md +23 -0
- data/docs/DocAction.md +8 -0
- data/docs/DocLog.md +12 -0
- data/docs/DocMetadata.md +16 -0
- data/docs/Document.md +16 -0
- data/docs/DocumentApi.md +203 -0
- data/docs/DropDocumentReq.md +20 -0
- data/docs/DropDocumentRes.md +15 -0
- data/docs/ExecutionTrigger.md +10 -0
- data/docs/Extract.md +10 -0
- data/docs/ExtractAction.md +9 -0
- data/docs/ExtractApi.md +102 -0
- data/docs/ExtractRes.md +8 -0
- data/docs/GetDocumentListRes.md +13 -0
- data/docs/GetDocumentReq.md +14 -0
- data/docs/GetDocumentRes.md +14 -0
- data/docs/IFormFile.md +13 -0
- data/docs/Image.md +15 -0
- data/docs/ImageAction.md +30 -0
- data/docs/ImageApi.md +107 -0
- data/docs/Job.md +10 -0
- data/docs/JobApi.md +197 -0
- data/docs/JobConfig.md +18 -0
- data/docs/JobConfigRes.md +8 -0
- data/docs/KeyValuePairStringObject.md +9 -0
- data/docs/KeyValuePairStringString.md +9 -0
- data/docs/ManagementApi.md +92 -0
- data/docs/Merge.md +10 -0
- data/docs/MergeAction.md +8 -0
- data/docs/MergeApi.md +102 -0
- data/docs/MergeRes.md +8 -0
- data/docs/Notification.md +9 -0
- data/docs/OcrAction.md +12 -0
- data/docs/OcrApi.md +57 -0
- data/docs/Optimize.md +10 -0
- data/docs/OptimizeAction.md +35 -0
- data/docs/OptimizeApi.md +103 -0
- data/docs/OptimizeRes.md +9 -0
- data/docs/Page.md +14 -0
- data/docs/PageSelection.md +10 -0
- data/docs/Pdf4meAction.md +12 -0
- data/docs/Pdf4meDocument.md +32 -0
- data/docs/Pdf4meException.md +8 -0
- data/docs/PdfAAction.md +14 -0
- data/docs/PdfAApi.md +102 -0
- data/docs/PdfFont.md +9 -0
- data/docs/Pricing.md +13 -0
- data/docs/ProduceDocuments.md +14 -0
- data/docs/ProduceDocumentsRes.md +8 -0
- data/docs/ProduceOutput.md +8 -0
- data/docs/RGBSet.md +10 -0
- data/docs/RecognizeDocument.md +10 -0
- data/docs/RecognizeDocumentRes.md +9 -0
- data/docs/Rectangle.md +11 -0
- data/docs/Rotate.md +10 -0
- data/docs/RunJobRes.md +10 -0
- data/docs/SignatureConfig.md +7 -0
- data/docs/Split.md +10 -0
- data/docs/SplitAction.md +11 -0
- data/docs/SplitApi.md +103 -0
- data/docs/SplitRes.md +8 -0
- data/docs/Stamp.md +10 -0
- data/docs/StampAction.md +22 -0
- data/docs/StampApi.md +110 -0
- data/docs/StampRes.md +8 -0
- data/docs/StorageFolder.md +10 -0
- data/docs/Text.md +17 -0
- data/docs/Transform.md +13 -0
- data/docs/Translate.md +9 -0
- data/docs/UserFingerprint.md +9 -0
- data/docs/VersionRes.md +8 -0
- data/docs/java.md +425 -0
- data/git_push.sh +55 -0
- data/lib/pdf4me.rb +124 -0
- data/lib/pdf4me/api/convert_api.rb +130 -0
- data/lib/pdf4me/api/document_api.rb +218 -0
- data/lib/pdf4me/api/extract_api.rb +131 -0
- data/lib/pdf4me/api/image_api.rb +139 -0
- data/lib/pdf4me/api/job_api.rb +223 -0
- data/lib/pdf4me/api/management_api.rb +117 -0
- data/lib/pdf4me/api/merge_api.rb +131 -0
- data/lib/pdf4me/api/ocr_api.rb +74 -0
- data/lib/pdf4me/api/optimize_api.rb +139 -0
- data/lib/pdf4me/api/pdf_a_api.rb +134 -0
- data/lib/pdf4me/api/split_api.rb +135 -0
- data/lib/pdf4me/api/stamp_api.rb +159 -0
- data/lib/pdf4me/api_client.rb +380 -0
- data/lib/pdf4me/api_error.rb +38 -0
- data/lib/pdf4me/configuration.rb +109 -0
- data/lib/pdf4me/models/action_flow.rb +190 -0
- data/lib/pdf4me/models/api_usage_res.rb +219 -0
- data/lib/pdf4me/models/archive_config.rb +226 -0
- data/lib/pdf4me/models/archive_job_req.rb +249 -0
- data/lib/pdf4me/models/archive_job_res.rb +207 -0
- data/lib/pdf4me/models/color.rb +206 -0
- data/lib/pdf4me/models/convert_to_pdf.rb +209 -0
- data/lib/pdf4me/models/convert_to_pdf_action.rb +253 -0
- data/lib/pdf4me/models/convert_to_pdf_res.rb +189 -0
- data/lib/pdf4me/models/create_images.rb +209 -0
- data/lib/pdf4me/models/create_images_res.rb +189 -0
- data/lib/pdf4me/models/create_pdf_a.rb +209 -0
- data/lib/pdf4me/models/create_pdf_a_res.rb +189 -0
- data/lib/pdf4me/models/custom_cms_config.rb +323 -0
- data/lib/pdf4me/models/doc_action.rb +190 -0
- data/lib/pdf4me/models/doc_log.rb +257 -0
- data/lib/pdf4me/models/doc_metadata.rb +285 -0
- data/lib/pdf4me/models/document.rb +285 -0
- data/lib/pdf4me/models/drop_document_req.rb +348 -0
- data/lib/pdf4me/models/drop_document_res.rb +260 -0
- data/lib/pdf4me/models/execution_trigger.rb +206 -0
- data/lib/pdf4me/models/extract.rb +207 -0
- data/lib/pdf4me/models/extract_action.rb +201 -0
- data/lib/pdf4me/models/extract_res.rb +188 -0
- data/lib/pdf4me/models/get_document_list_res.rb +237 -0
- data/lib/pdf4me/models/get_document_req.rb +243 -0
- data/lib/pdf4me/models/get_document_res.rb +246 -0
- data/lib/pdf4me/models/i_form_file.rb +235 -0
- data/lib/pdf4me/models/image.rb +300 -0
- data/lib/pdf4me/models/image_action.rb +513 -0
- data/lib/pdf4me/models/job.rb +213 -0
- data/lib/pdf4me/models/job_config.rb +298 -0
- data/lib/pdf4me/models/job_config_res.rb +193 -0
- data/lib/pdf4me/models/key_value_pair_string_object.rb +197 -0
- data/lib/pdf4me/models/key_value_pair_string_string.rb +197 -0
- data/lib/pdf4me/models/merge.rb +209 -0
- data/lib/pdf4me/models/merge_action.rb +190 -0
- data/lib/pdf4me/models/merge_res.rb +188 -0
- data/lib/pdf4me/models/notification.rb +199 -0
- data/lib/pdf4me/models/ocr_action.rb +259 -0
- data/lib/pdf4me/models/optimize.rb +209 -0
- data/lib/pdf4me/models/optimize_action.rb +514 -0
- data/lib/pdf4me/models/optimize_res.rb +199 -0
- data/lib/pdf4me/models/page.rb +258 -0
- data/lib/pdf4me/models/page_selection.rb +246 -0
- data/lib/pdf4me/models/pdf4me_action.rb +259 -0
- data/lib/pdf4me/models/pdf4me_document.rb +511 -0
- data/lib/pdf4me/models/pdf4me_exception.rb +189 -0
- data/lib/pdf4me/models/pdf_a_action.rb +297 -0
- data/lib/pdf4me/models/pdf_font.rb +213 -0
- data/lib/pdf4me/models/pricing.rb +278 -0
- data/lib/pdf4me/models/produce_documents.rb +251 -0
- data/lib/pdf4me/models/produce_documents_res.rb +191 -0
- data/lib/pdf4me/models/produce_output.rb +221 -0
- data/lib/pdf4me/models/recognize_document.rb +209 -0
- data/lib/pdf4me/models/recognize_document_res.rb +198 -0
- data/lib/pdf4me/models/rectangle.rb +215 -0
- data/lib/pdf4me/models/rgb_set.rb +206 -0
- data/lib/pdf4me/models/rotate.rb +221 -0
- data/lib/pdf4me/models/run_job_res.rb +215 -0
- data/lib/pdf4me/models/signature_config.rb +179 -0
- data/lib/pdf4me/models/split.rb +207 -0
- data/lib/pdf4me/models/split_action.rb +219 -0
- data/lib/pdf4me/models/split_res.rb +190 -0
- data/lib/pdf4me/models/stamp.rb +209 -0
- data/lib/pdf4me/models/stamp_action.rb +387 -0
- data/lib/pdf4me/models/stamp_res.rb +189 -0
- data/lib/pdf4me/models/storage_folder.rb +239 -0
- data/lib/pdf4me/models/text.rb +320 -0
- data/lib/pdf4me/models/transform.rb +263 -0
- data/lib/pdf4me/models/translate.rb +207 -0
- data/lib/pdf4me/models/user_fingerprint.rb +197 -0
- data/lib/pdf4me/models/version_res.rb +188 -0
- data/lib/pdf4me/version.rb +15 -0
- data/pdf4me.gemspec +47 -0
- data/spec/api/convert_api_spec.rb +60 -0
- data/spec/api/document_api_spec.rb +83 -0
- data/spec/api/extract_api_spec.rb +60 -0
- data/spec/api/image_api_spec.rb +62 -0
- data/spec/api/job_api_spec.rb +82 -0
- data/spec/api/management_api_spec.rb +57 -0
- data/spec/api/merge_api_spec.rb +60 -0
- data/spec/api/ocr_api_spec.rb +47 -0
- data/spec/api/optimize_api_spec.rb +60 -0
- data/spec/api/pdf_a_api_spec.rb +60 -0
- data/spec/api/split_api_spec.rb +60 -0
- data/spec/api/stamp_api_spec.rb +63 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/action_flow_spec.rb +42 -0
- data/spec/models/api_usage_res_spec.rb +60 -0
- data/spec/models/archive_config_spec.rb +60 -0
- data/spec/models/archive_job_req_spec.rb +66 -0
- data/spec/models/archive_job_res_spec.rb +48 -0
- data/spec/models/color_spec.rb +54 -0
- data/spec/models/convert_to_pdf_action_spec.rb +62 -0
- data/spec/models/convert_to_pdf_res_spec.rb +42 -0
- data/spec/models/convert_to_pdf_spec.rb +54 -0
- data/spec/models/create_images_res_spec.rb +42 -0
- data/spec/models/create_images_spec.rb +54 -0
- data/spec/models/create_pdf_a_res_spec.rb +42 -0
- data/spec/models/create_pdf_a_spec.rb +54 -0
- data/spec/models/custom_cms_config_spec.rb +132 -0
- data/spec/models/doc_action_spec.rb +42 -0
- data/spec/models/doc_log_spec.rb +70 -0
- data/spec/models/doc_metadata_spec.rb +90 -0
- data/spec/models/document_spec.rb +90 -0
- data/spec/models/drop_document_req_spec.rb +118 -0
- data/spec/models/drop_document_res_spec.rb +84 -0
- data/spec/models/execution_trigger_spec.rb +54 -0
- data/spec/models/extract_action_spec.rb +48 -0
- data/spec/models/extract_res_spec.rb +42 -0
- data/spec/models/extract_spec.rb +54 -0
- data/spec/models/get_document_list_res_spec.rb +72 -0
- data/spec/models/get_document_req_spec.rb +78 -0
- data/spec/models/get_document_res_spec.rb +78 -0
- data/spec/models/i_form_file_spec.rb +72 -0
- data/spec/models/image_action_spec.rb +206 -0
- data/spec/models/image_spec.rb +88 -0
- data/spec/models/job_config_res_spec.rb +42 -0
- data/spec/models/job_config_spec.rb +102 -0
- data/spec/models/job_spec.rb +54 -0
- data/spec/models/key_value_pair_string_object_spec.rb +48 -0
- data/spec/models/key_value_pair_string_string_spec.rb +48 -0
- data/spec/models/merge_action_spec.rb +42 -0
- data/spec/models/merge_res_spec.rb +42 -0
- data/spec/models/merge_spec.rb +54 -0
- data/spec/models/notification_spec.rb +48 -0
- data/spec/models/ocr_action_spec.rb +70 -0
- data/spec/models/optimize_action_spec.rb +228 -0
- data/spec/models/optimize_res_spec.rb +48 -0
- data/spec/models/optimize_spec.rb +54 -0
- data/spec/models/page_selection_spec.rb +58 -0
- data/spec/models/page_spec.rb +78 -0
- data/spec/models/pdf4me_action_spec.rb +70 -0
- data/spec/models/pdf4me_document_spec.rb +202 -0
- data/spec/models/pdf4me_exception_spec.rb +42 -0
- data/spec/models/pdf_a_action_spec.rb +86 -0
- data/spec/models/pdf_font_spec.rb +48 -0
- data/spec/models/pricing_spec.rb +80 -0
- data/spec/models/produce_documents_res_spec.rb +42 -0
- data/spec/models/produce_documents_spec.rb +78 -0
- data/spec/models/produce_output_spec.rb +46 -0
- data/spec/models/recognize_document_res_spec.rb +48 -0
- data/spec/models/recognize_document_spec.rb +54 -0
- data/spec/models/rectangle_spec.rb +60 -0
- data/spec/models/rgb_set_spec.rb +54 -0
- data/spec/models/rotate_spec.rb +54 -0
- data/spec/models/run_job_res_spec.rb +54 -0
- data/spec/models/signature_config_spec.rb +36 -0
- data/spec/models/split_action_spec.rb +60 -0
- data/spec/models/split_res_spec.rb +42 -0
- data/spec/models/split_spec.rb +54 -0
- data/spec/models/stamp_action_spec.rb +142 -0
- data/spec/models/stamp_res_spec.rb +42 -0
- data/spec/models/stamp_spec.rb +54 -0
- data/spec/models/storage_folder_spec.rb +58 -0
- data/spec/models/text_spec.rb +104 -0
- data/spec/models/transform_spec.rb +72 -0
- data/spec/models/translate_spec.rb +48 -0
- data/spec/models/user_fingerprint_spec.rb +48 -0
- data/spec/models/version_res_spec.rb +42 -0
- data/spec/spec_helper.rb +111 -0
- metadata +594 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 913225dfa467f836d3c11a20aff2ca56debcd92c
|
4
|
+
data.tar.gz: 37610fb0a739b216a951172a9b847f11a6b5f9d2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c311ac1567c9d7d4831e61ad770352ac33da85bb6dfcc9d1ff4cab8c008b3cb60dbc5282d292052fe24c08dbe1acbc35470788e19534544662516a7378d15e64
|
7
|
+
data.tar.gz: 76acc2bf0daf9cad1024230463291c2f5bd77ae2f105874a3647abde647b2ae689b1efe828e94c0b0841ee9d65a63cf0f8cf7f7950d1711e7754d3ace2e4edc0
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,472 @@
|
|
1
|
+
# pdf4me
|
2
|
+
|
3
|
+
**Pdf4me** is a PDF utility tool for Ruby and other languages.
|
4
|
+
The tool provides utility over common PDF related task like `merge`, `create`, `stamp` and others, which can be
|
5
|
+
found below.
|
6
|
+
|
7
|
+
## Getting Started
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```shell
|
12
|
+
gem 'pdf4me'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute
|
16
|
+
```shell
|
17
|
+
bundle install
|
18
|
+
# OR If you don't use bundler
|
19
|
+
gem install pdf4me
|
20
|
+
```
|
21
|
+
|
22
|
+
## Install from Git
|
23
|
+
|
24
|
+
You can also install from a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID.git, then add the following in the Gemfile:
|
25
|
+
|
26
|
+
gem 'pdf4me', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'
|
27
|
+
|
28
|
+
## Initializing Pdf4me
|
29
|
+
Pdf4me works with any Rack application or plain old ruby script. In any regular script the configuration of Pdf4me looks like
|
30
|
+
|
31
|
+
* Require pdf4me
|
32
|
+
* Configure pdf4me with API endpoints and credentials
|
33
|
+
* Call appropriate methods.
|
34
|
+
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
require 'pdf4me'
|
38
|
+
|
39
|
+
Pdf4me.configure do |config|
|
40
|
+
config.host = 'api-dev.pdf4me.com'
|
41
|
+
config.debugging = true
|
42
|
+
config.app_id = 'your-app-id'
|
43
|
+
config.app_secret = 'your-app-secret'
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
## Basic Usage
|
48
|
+
|
49
|
+
### convert_file_to_pdf
|
50
|
+
> Given a file, convert the file to PDF
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
api_instance = Pdf4me::ConvertApi.new
|
54
|
+
file = File.open(file_path, 'rb')
|
55
|
+
response = api_instance.convert_file_to_pdf(
|
56
|
+
file_name: 'some-name',
|
57
|
+
file: file
|
58
|
+
)
|
59
|
+
file.close
|
60
|
+
```
|
61
|
+
|
62
|
+
|
63
|
+
### convert_to_pdf
|
64
|
+
> Given a file, convert the file to PDF, with finer controls as opposed to
|
65
|
+
`convert_file_to_pdf`. The request is instantiated as a hash with the `:req` key,
|
66
|
+
that takes in `Pdf4me::ConvertToPdf` model.
|
67
|
+
|
68
|
+
> The model itself is comprised of three more models, `:document`, `:convertToPdfAction`
|
69
|
+
and `:notification`
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
api_instance = Pdf4me::ConvertApi.new
|
73
|
+
opts = {
|
74
|
+
req: Pdf4me::ConvertToPdf.new(
|
75
|
+
document: Pdf4me::Document.new(
|
76
|
+
docData: Base64.encode64(File.open(file_path, 'rb', &:read)),
|
77
|
+
),
|
78
|
+
convertToPdfAction: Pdf4me::ConvertToPdfAction.new(
|
79
|
+
options: ""
|
80
|
+
),
|
81
|
+
notification: Pdf4me::Notification.new(
|
82
|
+
getNotification: true
|
83
|
+
)
|
84
|
+
)
|
85
|
+
}
|
86
|
+
result = api_instance.convert_to_pdf(opts)
|
87
|
+
```
|
88
|
+
|
89
|
+
### extract
|
90
|
+
> Extract out pages from PDF. You can choose from the pages you want to extract
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
api_instance = Pdf4me::ExtractApi.new
|
94
|
+
|
95
|
+
opts = {
|
96
|
+
req: Pdf4me::Extract.new(
|
97
|
+
document: Pdf4me::Document.new(
|
98
|
+
docData: Base64.encode64(File.open(file_path, 'rb', &:read)),
|
99
|
+
),
|
100
|
+
extractAction: Pdf4me::ExtractAction.new(
|
101
|
+
extractPages: Array.wrap(pages)
|
102
|
+
),
|
103
|
+
notification: Pdf4me::Notification.new(
|
104
|
+
getNotification: true
|
105
|
+
)
|
106
|
+
)
|
107
|
+
}
|
108
|
+
api_instance.extract(opts)
|
109
|
+
```
|
110
|
+
|
111
|
+
|
112
|
+
### extract_pages
|
113
|
+
> Utility function on top of extract, that trades complexity for configuration.
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
api_instance = Pdf4me::ExtractApi.new
|
117
|
+
response = File.open(file_path, 'rb') do |file|
|
118
|
+
api_instance.extract_pages(
|
119
|
+
page_nrs: '2,3,4',
|
120
|
+
file: file
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
# OR
|
125
|
+
file = File.open(file_path, 'rb')
|
126
|
+
response = api_instance.extract_pages(
|
127
|
+
page_nrs: '2,3',
|
128
|
+
file: file
|
129
|
+
)
|
130
|
+
file.close
|
131
|
+
|
132
|
+
# do something with response a tempfile
|
133
|
+
FileUtils.cp(response.path, '/new/file/path.pdf')
|
134
|
+
```
|
135
|
+
|
136
|
+
### create_images
|
137
|
+
> Creates images from the PDF Document. This is useful if you want to create thumbnails for the PDF
|
138
|
+
> The options are highly configurable to get the desired output.
|
139
|
+
> The output would be a base64 encoded object that you have to save.
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
# initialize the API client
|
143
|
+
api_instance = Pdf4me::ImageApi.new
|
144
|
+
|
145
|
+
# make request hash
|
146
|
+
opts = {
|
147
|
+
req: Pdf4me::CreateImages.new(
|
148
|
+
document: Pdf4me::Document.new(
|
149
|
+
docData: Base64.encode64(File.open(file_path, 'rb', &:read)),
|
150
|
+
),
|
151
|
+
imageAction: Pdf4me::ImageAction.new(
|
152
|
+
pageSelection: Pdf4me::PageSelection.new(
|
153
|
+
pageNrs: [1,2,3]
|
154
|
+
),
|
155
|
+
imageExtension: 'png',
|
156
|
+
center: true,
|
157
|
+
fitPage: true,
|
158
|
+
bitsPerPixel: 24,
|
159
|
+
bilevelThreshold: 181,
|
160
|
+
renderOptions: %w(noAntialiasing),
|
161
|
+
rotateMode: 'none',
|
162
|
+
preserveAspectRatio: true,
|
163
|
+
compression: 'raw'
|
164
|
+
),
|
165
|
+
notification: Pdf4me::Notification.new(
|
166
|
+
getNotification: true
|
167
|
+
)
|
168
|
+
)
|
169
|
+
}
|
170
|
+
|
171
|
+
# response and save
|
172
|
+
response = api_instance.create_images(opts)
|
173
|
+
File.open(save_path, 'wb') do |f|
|
174
|
+
f.write(Base64.decode64(response.document.doc_data))
|
175
|
+
end
|
176
|
+
```
|
177
|
+
|
178
|
+
### create_thumbnail
|
179
|
+
> This is again a wrapper method on top of `:create_images`. The configuration is little less heckling
|
180
|
+
|
181
|
+
```ruby
|
182
|
+
api_instance = Pdf4me::ImageApi.new
|
183
|
+
file = File.open(file_path, 'rb')
|
184
|
+
|
185
|
+
response = api_instance.create_thumbnail(
|
186
|
+
100, # width in pixels
|
187
|
+
page_nr: "1", # for which page
|
188
|
+
image_format: "png", # image format
|
189
|
+
file: file
|
190
|
+
)
|
191
|
+
|
192
|
+
file.close
|
193
|
+
|
194
|
+
# do something with response a tempfile
|
195
|
+
FileUtils.cp(response.path, '/new/file/path.png')
|
196
|
+
````
|
197
|
+
|
198
|
+
### merge
|
199
|
+
> Merges two or more PDF and gives MergeRes, a Base64 Encoded file
|
200
|
+
|
201
|
+
```ruby
|
202
|
+
# Initialize the API client
|
203
|
+
api_instance = Pdf4me::MergeApi.new
|
204
|
+
|
205
|
+
# make request Hash
|
206
|
+
opts = {
|
207
|
+
req: Pdf4me::Merge.new(
|
208
|
+
documents: [
|
209
|
+
Pdf4me::Document.new(
|
210
|
+
docData: Base64.encode64(File.open(file_path, 'rb', &:read)),
|
211
|
+
),
|
212
|
+
Pdf4me::Document.new(
|
213
|
+
docData: Base64.encode64(File.open(file_path_2, 'rb', &:read)),
|
214
|
+
),
|
215
|
+
],
|
216
|
+
mergeAction: Pdf4me::MergeAction.new,
|
217
|
+
notification: Pdf4me::Notification.new
|
218
|
+
)
|
219
|
+
}
|
220
|
+
|
221
|
+
# make request
|
222
|
+
response = api_instance.merge(opts)
|
223
|
+
File.open(save_path, 'wb') do |f|
|
224
|
+
f.write(Base64.decode64(response.document.doc_data))
|
225
|
+
end
|
226
|
+
````
|
227
|
+
|
228
|
+
### merge2_pdfs
|
229
|
+
> Utility method that merges two pdfs
|
230
|
+
|
231
|
+
```ruby
|
232
|
+
api_instance = Pdf4me::MergeApi.new
|
233
|
+
|
234
|
+
file1 = File.open(file_path, 'rb')
|
235
|
+
file2 = File.open(file_path_2, 'rb')
|
236
|
+
|
237
|
+
response = api_instance.merge2_pdfs(
|
238
|
+
file1: file1,
|
239
|
+
file2: file2
|
240
|
+
)
|
241
|
+
|
242
|
+
file1.close
|
243
|
+
file2.close
|
244
|
+
|
245
|
+
# do something with response a tempfile
|
246
|
+
FileUtils.cp(response.path, '/new/file/path.pdf')
|
247
|
+
```
|
248
|
+
|
249
|
+
###optimize
|
250
|
+
|
251
|
+
> Given a PDF document, Optimize the document.
|
252
|
+
> `:optimize` takes multiple arguments, the arguments are
|
253
|
+
>
|
254
|
+
> * profile, valid values are `default`, `web`, `print`, `max`, `mRC`
|
255
|
+
> * dithering_mode, valid values are `none`, `floydSteinberg`, `halftone`, `pattern`, `g3Optimized`, `g4Optimized`, `atkinson`
|
256
|
+
|
257
|
+
For complete list of options, please refer the `OptimizeAction` class
|
258
|
+
|
259
|
+
```ruby
|
260
|
+
# Initialize the API client
|
261
|
+
api_instance = Pdf4me::OptimizeApi.new
|
262
|
+
|
263
|
+
# prepare Request Hash
|
264
|
+
opts = {
|
265
|
+
req: Pdf4me::Optimize.new(
|
266
|
+
document: Pdf4me::Document.new(
|
267
|
+
docData: Base64.encode64(File.open(file_path, 'rb', &:read)),
|
268
|
+
),
|
269
|
+
optimizeAction: Pdf4me::OptimizeAction.new(
|
270
|
+
profile: profile,
|
271
|
+
useProfile: true,
|
272
|
+
optimizeResources: true,
|
273
|
+
ditheringMode: dithering_mode
|
274
|
+
),
|
275
|
+
notification: Pdf4me::Notification.new(
|
276
|
+
getNotification: true
|
277
|
+
)
|
278
|
+
)
|
279
|
+
}
|
280
|
+
|
281
|
+
# make request
|
282
|
+
response = api_instance.optimize(opts)
|
283
|
+
File.open(save_path, 'wb') do |f|
|
284
|
+
f.write(Base64.decode64(response.document.doc_data))
|
285
|
+
end
|
286
|
+
|
287
|
+
```
|
288
|
+
|
289
|
+
###optimize_by_profile
|
290
|
+
> Utility function, that optimizes the PDF based on Profile as mentioned above
|
291
|
+
|
292
|
+
```ruby
|
293
|
+
api_instance = Pdf4me::OptimizeApi.new
|
294
|
+
file = File.open(file_path, 'rb')
|
295
|
+
|
296
|
+
response = api_instance.optimize_by_profile(
|
297
|
+
'print',
|
298
|
+
file: file
|
299
|
+
)
|
300
|
+
file.close
|
301
|
+
|
302
|
+
# do something with response a tempfile
|
303
|
+
FileUtils.cp(response.path, '/new/file/path.pdf')
|
304
|
+
```
|
305
|
+
|
306
|
+
### pdf_a
|
307
|
+
> Creates PDF/A Documents. There are range of options that could be passed while creating the document. The options are
|
308
|
+
> - `compliance` _string_ - Anyone of the following values `unknown`, `pdf10`, `pdf11`, `pdf12`, `pdf13`, `pdf14`, `pdfA1b`, `pdfA1a`, `pdf15`, `pdf16`, `pdf17`, `pdfA2b`, `pdfA2u`, `pdfA2a`, `pdfA3b`, `pdfA3u`, `pdfA3a`
|
309
|
+
> - `downgrade` _boolean_ `true` or `false`
|
310
|
+
> - `upgrade` _boolean_ `true` or `false`
|
311
|
+
> - `linearize` _boolean_ `true` or `false`
|
312
|
+
|
313
|
+
```ruby
|
314
|
+
api_instance = Pdf4me::PdfAApi.new
|
315
|
+
|
316
|
+
opts = {
|
317
|
+
req: Pdf4me::CreatePdfA.new(
|
318
|
+
document: Pdf4me::Document.new(
|
319
|
+
docData: Base64.encode64(File.open(file_path, 'rb', &:read)),
|
320
|
+
),
|
321
|
+
pdfAAction: Pdf4me::PdfAAction.new(
|
322
|
+
compliance: 'pdfA1a',
|
323
|
+
allowDowngrade: true,
|
324
|
+
allowUpgrade: true,
|
325
|
+
outputIntentProfile: 'sRGBColorSpace',
|
326
|
+
linearize: true
|
327
|
+
),
|
328
|
+
notification: Pdf4me::Notification.new(
|
329
|
+
getNotification: true
|
330
|
+
)
|
331
|
+
)
|
332
|
+
}
|
333
|
+
|
334
|
+
# make request
|
335
|
+
response = api_instance.pdf_a(opts)
|
336
|
+
File.open('/path/to/save.pdf', 'wb') do |f|
|
337
|
+
f.write(Base64.decode64(response.document.doc_data))
|
338
|
+
end
|
339
|
+
```
|
340
|
+
|
341
|
+
### create_pdf_a
|
342
|
+
> Utility function based on above function
|
343
|
+
|
344
|
+
```ruby
|
345
|
+
api_instance = Pdf4me::PdfAApi.new
|
346
|
+
file = File.open(file_path, 'rb')
|
347
|
+
|
348
|
+
response = api_instance.create_pdf_a(
|
349
|
+
pdf_compliance: 'pdfA1a',
|
350
|
+
file: file
|
351
|
+
)
|
352
|
+
|
353
|
+
file.close
|
354
|
+
|
355
|
+
# do something with response a tempfile
|
356
|
+
FileUtils.cp(response.path, '/new/file/path.pdf')
|
357
|
+
```
|
358
|
+
|
359
|
+
### split
|
360
|
+
> Given a PDF, split the PDF into two parts
|
361
|
+
|
362
|
+
```ruby
|
363
|
+
api_instance = Pdf4me::SplitApi.new
|
364
|
+
|
365
|
+
opts = {
|
366
|
+
req: Pdf4me::Split.new(
|
367
|
+
document: Pdf4me::Document.new(
|
368
|
+
docData: Base64.encode64(File.open(file_path, 'rb', &:read)),
|
369
|
+
),
|
370
|
+
SplitAction: Pdf4me::SplitAction.new(
|
371
|
+
splitAfterPage: 3
|
372
|
+
),
|
373
|
+
notificaiton: Pdf4me::Notification.new(
|
374
|
+
getNotification: true
|
375
|
+
)
|
376
|
+
)
|
377
|
+
}
|
378
|
+
|
379
|
+
response = api_instance.split(opts)
|
380
|
+
|
381
|
+
File.open(save_path, 'wb') do |f|
|
382
|
+
f.write(Base64.decode64(response.documents[0].doc_data))
|
383
|
+
end
|
384
|
+
|
385
|
+
File.open(save_path_2, 'wb') do |f|
|
386
|
+
f.write(Base64.decode64(response.documents[0].doc_data))
|
387
|
+
end
|
388
|
+
```
|
389
|
+
|
390
|
+
|
391
|
+
### split_by_page_nr
|
392
|
+
> Utility function to split the PDF by page number
|
393
|
+
|
394
|
+
```ruby
|
395
|
+
api_instance = Pdf4me::SplitApi.new
|
396
|
+
file = File.open(file_path, 'rb')
|
397
|
+
|
398
|
+
response = api_instance.split_by_page_nr(
|
399
|
+
2, # page_number
|
400
|
+
file: file
|
401
|
+
)
|
402
|
+
|
403
|
+
file.close
|
404
|
+
|
405
|
+
File.open(save_path, 'wb') do |f|
|
406
|
+
f.write(Base64.decode64(response.documents[0].doc_data))
|
407
|
+
end
|
408
|
+
|
409
|
+
File.open(save_path_2, 'wb') do |f|
|
410
|
+
f.write(Base64.decode64(response.documents[0].doc_data))
|
411
|
+
end
|
412
|
+
```
|
413
|
+
|
414
|
+
# stamp
|
415
|
+
> Stamp a PDF, based on Stamp Action.
|
416
|
+
> You can stamp either a text or image to PDF, There are two separate methods defined to help you with stamping
|
417
|
+
> - Stamp PDF with image
|
418
|
+
> - Stamp PDF with Text
|
419
|
+
> Depending upon the type of stamp, position, size can be configured.
|
420
|
+
|
421
|
+
```ruby
|
422
|
+
api_instance = Pdf4me::StampApi.new
|
423
|
+
|
424
|
+
opts = {
|
425
|
+
req: Pdf4me::Stamp.new(
|
426
|
+
document: Pdf4me::Document.new(
|
427
|
+
docData: Base64.encode64(File.open(file_path, 'rb', &:read)),
|
428
|
+
),
|
429
|
+
stampAction: Pdf4me::StampAction.new(
|
430
|
+
image: Pdf4me::Image.new(
|
431
|
+
imageData: Base64.encode64(File.open(image, 'rb', &:read)),
|
432
|
+
),
|
433
|
+
sizeX: stamp_width,
|
434
|
+
sizeY: stamp_length,
|
435
|
+
rotate: rotate,
|
436
|
+
alignX: align_x,
|
437
|
+
alignY: align_y,
|
438
|
+
scale: 'relToA4',
|
439
|
+
stampType: 'foreground',
|
440
|
+
alpha: opacity
|
441
|
+
),
|
442
|
+
notification: Pdf4me::Notification.new(
|
443
|
+
getNotification: true
|
444
|
+
)
|
445
|
+
)
|
446
|
+
}
|
447
|
+
|
448
|
+
response = api_instance.stamp(opts)
|
449
|
+
File.open(save_path_2, 'wb') do |f|
|
450
|
+
f.write(Base64.decode64(response.document.doc_data))
|
451
|
+
end
|
452
|
+
```
|
453
|
+
|
454
|
+
### text_stamp
|
455
|
+
> Utility function over stamp, where you can stamp a document with text
|
456
|
+
|
457
|
+
```ruby
|
458
|
+
api_instance = Pdf4me::StampApi.new
|
459
|
+
file = File.open(file_path, 'rb')
|
460
|
+
|
461
|
+
response = api_instance.text_stamp(
|
462
|
+
'right', # alignment x axis
|
463
|
+
'bottom', # alignment y axis,
|
464
|
+
text: 'Hello world, i am stamp',
|
465
|
+
pages: '1,4',
|
466
|
+
file: file
|
467
|
+
)
|
468
|
+
file.close
|
469
|
+
|
470
|
+
# do something with response a tempfile
|
471
|
+
FileUtils.cp(response.path, '/new/file/path.pdf')
|
472
|
+
```
|