pdf4me 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +0 -0
- data/README.md +246 -15
- data/lib/pdf4me.rb +30 -0
- data/lib/pdf4me/actions/complex_action.rb +5 -0
- data/lib/pdf4me/actions/convert_file_to_pdf.rb +3 -1
- data/lib/pdf4me/actions/convert_to_pdf.rb +1 -5
- data/lib/pdf4me/actions/create_images.rb +10 -0
- data/lib/pdf4me/actions/create_pdf_a.rb +0 -0
- data/lib/pdf4me/actions/create_thumbnail.rb +3 -1
- data/lib/pdf4me/actions/extract.rb +10 -0
- data/lib/pdf4me/actions/extract_pages.rb +4 -2
- data/lib/pdf4me/actions/merge.rb +35 -0
- data/lib/pdf4me/actions/merge_two_pdfs.rb +5 -4
- data/lib/pdf4me/actions/optimize.rb +0 -0
- data/lib/pdf4me/actions/optimize_by_profile.rb +3 -1
- data/lib/pdf4me/actions/pdf_a.rb +10 -0
- data/lib/pdf4me/actions/split.rb +10 -0
- data/lib/pdf4me/actions/split_by_page_nr.rb +0 -0
- data/lib/pdf4me/actions/stamp.rb +10 -0
- data/lib/pdf4me/actions/text_stamp.rb +9 -2
- data/lib/pdf4me/actions/wrapper_action.rb +0 -0
- data/lib/pdf4me/client.rb +0 -0
- data/lib/pdf4me/configuration.rb +0 -0
- data/lib/pdf4me/exceptions.rb +0 -0
- data/lib/pdf4me/models/base.rb +5 -1
- data/lib/pdf4me/models/color.rb +10 -0
- data/lib/pdf4me/models/convert_to_pdf_action.rb +0 -0
- data/lib/pdf4me/models/convert_to_pdf_res.rb +2 -1
- data/lib/pdf4me/models/create_images_res.rb +9 -0
- data/lib/pdf4me/models/custom_cms_config.rb +23 -0
- data/lib/pdf4me/models/doc_log.rb +0 -0
- data/lib/pdf4me/models/doc_metadata.rb +0 -0
- data/lib/pdf4me/models/document.rb +0 -0
- data/lib/pdf4me/models/extract_action.rb +28 -0
- data/lib/pdf4me/models/extract_res.rb +9 -0
- data/lib/pdf4me/models/image.rb +11 -0
- data/lib/pdf4me/models/image_action.rb +110 -0
- data/lib/pdf4me/models/merge_action.rb +8 -0
- data/lib/pdf4me/models/merge_res.rb +8 -0
- data/lib/pdf4me/models/notification.rb +1 -1
- data/lib/pdf4me/models/optimize_action.rb +0 -0
- data/lib/pdf4me/models/optimize_res.rb +2 -1
- data/lib/pdf4me/models/page.rb +0 -0
- data/lib/pdf4me/models/page_selection.rb +21 -0
- data/lib/pdf4me/models/pdf_a_action.rb +33 -0
- data/lib/pdf4me/models/pdf_a_res.rb +8 -0
- data/lib/pdf4me/models/pdf_font.rb +9 -0
- data/lib/pdf4me/models/rgb_set.rb +10 -0
- data/lib/pdf4me/models/rotate.rb +12 -0
- data/lib/pdf4me/models/split_action.rb +11 -0
- data/lib/pdf4me/models/split_res.rb +8 -0
- data/lib/pdf4me/models/stamp_action.rb +60 -0
- data/lib/pdf4me/models/stamp_res.rb +8 -0
- data/lib/pdf4me/models/text.rb +37 -0
- data/lib/pdf4me/models/transform.rb +16 -0
- data/lib/pdf4me/models/translate.rb +12 -0
- data/lib/pdf4me/utils/assigner.rb +0 -0
- data/lib/pdf4me/utils/serializer.rb +2 -0
- data/lib/pdf4me/version.rb +1 -1
- data/spec/actions/complex_action_spec.rb +12 -0
- data/spec/actions/convert_file_to_pdf_spec.rb +21 -0
- data/spec/actions/convert_to_pdf_spec.rb +16 -0
- data/spec/actions/create_pdf_a_spec.rb +0 -0
- data/spec/actions/create_thumbnail_spec.rb +27 -0
- data/spec/actions/extract_pages_spec.rb +24 -0
- data/spec/actions/extract_spec.rb +16 -0
- data/spec/actions/merge_spec.rb +17 -0
- data/spec/actions/merge_two_pdfs_spec.rb +21 -0
- data/spec/actions/optimize_by_profile_spec.rb +22 -0
- data/spec/actions/optimize_spec.rb +16 -0
- data/spec/actions/pdf_a_spec.rb +16 -0
- data/spec/actions/split_by_page_nr_spec.rb +21 -0
- data/spec/actions/split_spec.rb +16 -0
- data/spec/actions/stamp_spec.rb +16 -0
- data/spec/actions/text_stamp_spec.rb +24 -0
- data/spec/actions/wrapper_action_spec.rb +0 -0
- data/spec/files/4.pdf +0 -0
- data/spec/models/base_spec.rb +9 -0
- data/spec/models/color_spec.rb +7 -0
- data/spec/models/convert_to_pdf_action_spec.rb +23 -0
- data/spec/models/convert_to_pdf_res_spec.rb +7 -0
- data/spec/models/create_images_res_spec.rb +7 -0
- data/spec/models/custom_cms_config_spec.rb +7 -0
- data/spec/models/doc_log_spec.rb +36 -0
- data/spec/models/doc_metadata_spec.rb +7 -0
- data/spec/models/document_spec.rb +12 -0
- data/spec/models/extract_action_spec.rb +7 -0
- data/spec/models/extract_res_spec.rb +7 -0
- data/spec/models/image_action_spec.rb +46 -0
- data/spec/models/merge_action_spec.rb +7 -0
- data/spec/models/merge_res_spec.rb +7 -0
- data/spec/models/notification_spec.rb +13 -0
- data/spec/models/optimize_action_spec.rb +44 -0
- data/spec/models/optimize_res_spec.rb +7 -0
- data/spec/models/page_selection_spec.rb +17 -0
- data/spec/models/page_spec.rb +7 -0
- data/spec/models/pdf_a_action_spec.rb +22 -0
- data/spec/models/pdf_a_res_spec.rb +7 -0
- data/spec/models/pdf_font_spec.rb +7 -0
- data/spec/models/rgb_set_spec.rb +7 -0
- data/spec/models/rotate_spec.rb +13 -0
- data/spec/models/split_action_spec.rb +7 -0
- data/spec/models/split_res_spec.rb +7 -0
- data/spec/models/stamp_action_spec.rb +27 -0
- data/spec/models/stamp_res_spec.rb +7 -0
- data/spec/models/text_spec.rb +22 -0
- data/spec/models/transform_spec.rb +16 -0
- data/spec/models/translate_spec.rb +12 -0
- data/spec/spec_helper.rb +0 -0
- metadata +142 -90
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5cab03031af5c80c55ae0c20a0bd35ea2da1566
|
4
|
+
data.tar.gz: 39616938411754524c95e452ac15328cda1771e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7809803d64511e1abb269457fedfa97ba27b1774b0ac55970ac88408cc0b5d97d2697c90f79d7f2814521fec505ded8140489f4a0eae5622c051e949b10a1079
|
7
|
+
data.tar.gz: 871941878cfca1d14d6497053bcc1f7e34b2d8ff9f120ca9badac0622a3128bec2a1ee45646d314f27d1c404b1348e125cf6de46e79b2cc1908114d392e8eef4
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -157,7 +157,18 @@ a.run
|
|
157
157
|
|
158
158
|
|
159
159
|
## Advanced Usage
|
160
|
-
> These methods are more complex than the Basic Wrapper methods. The development of which is still a Work in Progress. Currently there are two methods that you can use
|
160
|
+
> These methods are more complex than the Basic Wrapper methods. The development of which is still a Work in Progress. Currently there are two methods that you can use.
|
161
|
+
>
|
162
|
+
> By default all the Advanced methods run in blocking mode -
|
163
|
+
> i.e you wait for the server to send you the response.
|
164
|
+
>
|
165
|
+
> If you want to run the operation asynchronously - you will be notified by a webhook over the result -
|
166
|
+
then please set `get_notification` to `true` in `Pdf4me::Notification`.
|
167
|
+
>
|
168
|
+
> When the `Pdf4me::Notification` object is set, it will overwrite what is the default behaviour
|
169
|
+
defined on the application/api level.
|
170
|
+
>
|
171
|
+
>See Pdf4me-Developer page to configure the webhook on application level.
|
161
172
|
|
162
173
|
###convert_to_pdf
|
163
174
|
|
@@ -165,20 +176,28 @@ a.run
|
|
165
176
|
`convert_file_to_pdf`. The request is instantiated as a hash with the `:req` key,
|
166
177
|
that takes in `Pdf4me::ConvertToPdf` model.
|
167
178
|
|
168
|
-
> The action takes three different models `:document`, `:
|
179
|
+
> The action takes three different models `:document`, `:convert_to_pdf_action` and `:notification` and returns
|
169
180
|
`Pdf4me::ConvertToPdfRes`
|
170
181
|
|
182
|
+
> To get more information regarding the models, please refer the provided [model definition](https://pdf4medoc.blob.core.windows.net/doc/index.html?java#converttopdfreq)
|
183
|
+
|
171
184
|
```ruby
|
172
185
|
file_path = '/path/to/file/TestDocToConvert.docx'
|
173
186
|
|
174
|
-
|
187
|
+
action = Pdf4me::ConvertToPdf.new(
|
175
188
|
document: Pdf4me::Document.new(
|
176
189
|
doc_data: Base64.encode64(File.open(file_path, 'rb', &:read)),
|
177
190
|
name: "TestDocToConvert.docx"
|
178
191
|
),
|
179
|
-
convert_to_pdf_action: Pdf4me::ConvertToPdfAction.new
|
192
|
+
convert_to_pdf_action: Pdf4me::ConvertToPdfAction.new,
|
193
|
+
notification: Pdf4me::Notification.new(get_notification: true) # async, set false to invoke blocking mode.
|
180
194
|
)
|
181
|
-
response =
|
195
|
+
response = action.run
|
196
|
+
|
197
|
+
# saving converted file
|
198
|
+
File.open('path/to/save.pdf', 'wb') do |f|
|
199
|
+
f.write(Base64.decode64(response.document.doc_data))
|
200
|
+
end
|
182
201
|
```
|
183
202
|
|
184
203
|
###optimize
|
@@ -187,23 +206,235 @@ that takes in `Pdf4me::ConvertToPdf` model.
|
|
187
206
|
>
|
188
207
|
> `:optimize` takes three different models `document`, `optimize_action` and `notification`
|
189
208
|
>
|
190
|
-
> `Pdf4me::OptimizeAction` takes multiple arguments,
|
209
|
+
> `Pdf4me::OptimizeAction` takes multiple arguments, important amongst them being `profile`
|
191
210
|
> * profile, valid values are `default`, `web`, `print`, `max`, `mRC`
|
192
211
|
|
212
|
+
> The finer details on configuration can be found at the [model definition](https://pdf4medoc.blob.core.windows.net/doc/index.html?curl#optimizereq)
|
213
|
+
|
193
214
|
```ruby
|
194
|
-
|
215
|
+
file_path = '/path/to/file/4.pdf'
|
216
|
+
|
217
|
+
action = Pdf4me::Optimize.new(
|
218
|
+
document: Pdf4me::Document.new(
|
219
|
+
doc_data: Base64.encode64(File.open(file_path, 'rb', &:read))
|
220
|
+
),
|
221
|
+
optimize_action: Pdf4me::OptimizeAction.new(
|
222
|
+
use_profile: true,
|
223
|
+
profile: 'max'
|
224
|
+
)
|
225
|
+
)
|
226
|
+
response = action.run
|
195
227
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
228
|
+
# saving optimized file
|
229
|
+
File.open('path/to/optimized.pdf', 'wb') do |f|
|
230
|
+
f.write(Base64.decode64(response.document.doc_data))
|
231
|
+
end
|
232
|
+
```
|
233
|
+
|
234
|
+
### extract
|
235
|
+
> Extract out pages from PDF. You can choose from the pages you want to get.
|
236
|
+
|
237
|
+
> `extract` takes three model arguments
|
238
|
+
> * `extract_action`
|
239
|
+
> * `document`
|
240
|
+
> * `notification` - non mandatory
|
241
|
+
|
242
|
+
> To list all possible options for the models please refer the [model definition](https://pdf4medoc.blob.core.windows.net/doc/index.html?curl#extractreq)
|
243
|
+
|
244
|
+
```ruby
|
245
|
+
file_path = '/path/to/file/4.pdf'
|
246
|
+
|
247
|
+
action = Pdf4me::Extract.new(
|
248
|
+
document: Pdf4me::Document.new(
|
249
|
+
doc_data: Base64.encode64(File.open(file_path, 'rb', &:read))
|
250
|
+
),
|
251
|
+
extract_action: Pdf4me::ExtractAction.new(
|
252
|
+
extract_pages: [1, 2, 5]
|
253
|
+
),
|
254
|
+
notification: Pdf4me::Notification.new(get_notification: true) # async
|
203
255
|
)
|
204
|
-
|
256
|
+
response = action.run
|
257
|
+
|
258
|
+
# saving extracted pages
|
259
|
+
File.open('path/to/extracted.pdf', 'wb') do |f|
|
260
|
+
f.write(Base64.decode64(response.document.doc_data))
|
261
|
+
end
|
262
|
+
```
|
263
|
+
|
264
|
+
### create_images
|
265
|
+
> Creates images from the PDF Document. This is useful if you want to create thumbnails for the PDF.<br>
|
266
|
+
> The options are highly configurable to get the desired output.
|
267
|
+
> The output would be a base64 encoded object that you have to save.
|
268
|
+
> `create_images` takes three different arguments.
|
269
|
+
> * `document`
|
270
|
+
> * `image_action`
|
271
|
+
> * `notification` - non mandatory
|
272
|
+
|
273
|
+
> Each model has their own set of attributes and hence can be configured further.
|
274
|
+
The full documentation of model attributes are available at [model definition](https://pdf4medoc.blob.core.windows.net/doc/index.html?curl#createimagesreq)
|
275
|
+
|
276
|
+
```ruby
|
277
|
+
file_path = '/path/to/file/4.pdf'
|
278
|
+
|
279
|
+
action = Pdf4me::CreateImages.new(
|
280
|
+
document: Pdf4me::Document.new(
|
281
|
+
doc_data: Base64.encode64(File.open(file_path, 'rb', &:read))
|
282
|
+
),
|
283
|
+
image_action: Pdf4me::ImageAction.new(
|
284
|
+
page_selection: Pdf4me::PageSelection.new(
|
285
|
+
page_nrs: [1]
|
286
|
+
),
|
287
|
+
image_extension: 'png',
|
288
|
+
center: true,
|
289
|
+
fit_page: true,
|
290
|
+
bits_per_pixel: 24,
|
291
|
+
bilevel_threshold: 181,
|
292
|
+
render_options: %w(noAntialiasing),
|
293
|
+
rotate_mode: 'none',
|
294
|
+
preserve_aspect_ratio: true,
|
295
|
+
compression: 'raw'
|
296
|
+
)
|
297
|
+
)
|
298
|
+
response = action.run
|
299
|
+
|
300
|
+
# saving the extracted thumbnail
|
301
|
+
File.open('thumbnail.png', 'wb') do |f|
|
302
|
+
f.write(Base64.decode64(response.document.pages.first.thumbnail))
|
303
|
+
end
|
205
304
|
```
|
206
305
|
|
306
|
+
### merge
|
307
|
+
> Merges two or more PDF and gives MergeRes, a Base64 Encoded file
|
308
|
+
> `merge` takes three model arguments
|
309
|
+
> * `documents` - An Array of `Pdf4me::Document`
|
310
|
+
> * `merge_action` - `Pdf4me::MergeAction` model - non mandatory
|
311
|
+
> * `notification` - `Pdf4me::Notification` model - non mandatory
|
312
|
+
|
313
|
+
> To list all possible options for the models please refer the [model definition](https://pdf4medoc.blob.core.windows.net/doc/index.html?curl#mergereq)
|
314
|
+
|
315
|
+
```ruby
|
316
|
+
|
317
|
+
file_path_1 = '/path/to/file/4.pdf'
|
318
|
+
file_path_2 = '/path/to/file/3.pdf'
|
319
|
+
file_path_3 = '/path/to/file/2.pdf'
|
320
|
+
|
321
|
+
action = Pdf4me::Merge.new(
|
322
|
+
documents: [
|
323
|
+
Pdf4me::Document.new(
|
324
|
+
doc_data: Base64.encode64(File.open(file_path_1, 'rb', &:read))
|
325
|
+
),
|
326
|
+
Pdf4me::Document.new(
|
327
|
+
doc_data: Base64.encode64(File.open(file_path_2, 'rb', &:read))
|
328
|
+
),
|
329
|
+
Pdf4me::Document.new(
|
330
|
+
doc_data: Base64.encode64(File.open(file_path_3, 'rb', &:read))
|
331
|
+
)
|
332
|
+
]
|
333
|
+
)
|
334
|
+
response = action.run
|
335
|
+
|
336
|
+
# saving the merged PDF
|
337
|
+
File.open('merged.pdf', 'wb') do |f|
|
338
|
+
f.write(Base64.decode64(response.document.doc_data))
|
339
|
+
end
|
340
|
+
```
|
341
|
+
|
342
|
+
### pdf_a
|
343
|
+
> Creates PDF/A Documents from normal PDF document.
|
344
|
+
> `pdf_a` takes three model arguments.
|
345
|
+
> * `document` - a valid instance of `Pdf4me::Document`
|
346
|
+
> * `pdf_a_action` - a valid instance of `Pdf4me::PdfAAction`
|
347
|
+
> * `notification` - a valid instance of `Pdf4me::Notification` - non mandatory
|
348
|
+
>
|
349
|
+
> To list all possible options for the models please refer the [model definition](https://pdf4medoc.blob.core.windows.net/doc/index.html?curl#createpdfareq)
|
350
|
+
```ruby
|
351
|
+
file_path = '/path/to/file/4.pdf'
|
352
|
+
|
353
|
+
action = Pdf4me::PdfA.new(
|
354
|
+
document: Pdf4me::Document.new(
|
355
|
+
doc_data: Base64.encode64(File.open(file_path, 'rb', &:read))
|
356
|
+
),
|
357
|
+
pdf_a_action: Pdf4me::PdfAAction.new(
|
358
|
+
compliance: 'pdfA1a',
|
359
|
+
allowDowngrade: true,
|
360
|
+
allowUpgrade: true,
|
361
|
+
outputIntentProfile: 'sRGBColorSpace',
|
362
|
+
linearize: true
|
363
|
+
)
|
364
|
+
)
|
365
|
+
response = action.run
|
366
|
+
|
367
|
+
# saving the PDF/A document
|
368
|
+
File.open('pdf_a.pdf', 'wb') do |f|
|
369
|
+
f.write(Base64.decode64(response.document.doc_data))
|
370
|
+
end
|
371
|
+
```
|
372
|
+
|
373
|
+
|
374
|
+
### split
|
375
|
+
> Given a PDF, split the PDF into parts
|
376
|
+
> `split` takes up three models
|
377
|
+
> * `document` - a valid instance of `Pdf4me::Document`
|
378
|
+
> * `split_action` - a valid instance of `Pdf4me::SplitAction` which defines the number of parts the PDF splits into
|
379
|
+
> * `notification` - non mandatory, an instance of `Pdf4me::Notification`
|
380
|
+
>
|
381
|
+
> To list all possible options for the models please refer the [model definition](https://pdf4medoc.blob.core.windows.net/doc/index.html?curl#splitreq)
|
382
|
+
|
383
|
+
```ruby
|
384
|
+
file_path = '/path/to/file/4.pdf'
|
385
|
+
|
386
|
+
action = Pdf4me::Split.new(
|
387
|
+
document: Pdf4me::Document.new(
|
388
|
+
doc_data: Base64.encode64(File.open(file_path, 'rb', &:read)),
|
389
|
+
),
|
390
|
+
split_action: Pdf4me::SplitAction.new(
|
391
|
+
split_after_page: 3
|
392
|
+
)
|
393
|
+
)
|
394
|
+
response = action.run
|
395
|
+
|
396
|
+
# save documents
|
397
|
+
response.documents.each_with_index do |document, index|
|
398
|
+
File.open("split_#{index}.pdf", 'wb') do |f|
|
399
|
+
f.write(Base64.decode64(document.doc_data))
|
400
|
+
end
|
401
|
+
end
|
402
|
+
```
|
403
|
+
|
404
|
+
# stamp
|
405
|
+
> Stamp a PDF, based on Stamp Action.
|
406
|
+
> You can stamp either a text or image to PDF, There are two separate methods defined to help you with stamping
|
407
|
+
> - Stamp PDF with image
|
408
|
+
> - Stamp PDF with Text
|
409
|
+
> `stamp` takes three model arguments
|
410
|
+
* `document` - a valid instance of `Pdf4me::Document`
|
411
|
+
> * `stamp_action` - a valid instance of `Pdf4me::StampAction` which defines the stamp type, and position.
|
412
|
+
> * `notification` - non mandatory, an instance of `Pdf4me::Notification`
|
413
|
+
>
|
414
|
+
> To list all possible options for the models please refer the [model definition](https://pdf4medoc.blob.core.windows.net/doc/index.html?curl#stampreq)
|
415
|
+
|
416
|
+
```ruby
|
417
|
+
file_path = '/path/to/file/4.pdf'
|
418
|
+
|
419
|
+
action = Pdf4me::Stamp.new(
|
420
|
+
document: Pdf4me::Document.new(
|
421
|
+
doc_data: Base64.encode64(File.open(file_path, 'rb', &:read)),
|
422
|
+
),
|
423
|
+
stamp_action: Pdf4me::StampAction.new(
|
424
|
+
image: Pdf4me::Image.new(
|
425
|
+
image_data: Base64.encode64(File.open(image_path, 'rb', &:read))
|
426
|
+
)
|
427
|
+
)
|
428
|
+
)
|
429
|
+
response = action.run
|
430
|
+
|
431
|
+
# save stamped document
|
432
|
+
File.open('pdf_stamped.pdf', 'wb') do |f|
|
433
|
+
f.write(Base64.decode64(response.document.doc_data))
|
434
|
+
end
|
435
|
+
```
|
436
|
+
|
437
|
+
|
207
438
|
## Contributing
|
208
439
|
|
209
440
|
Bug reports and pull requests are welcome on GitHub at https://github.com/pdf4me/pdf4me-clientapi-ruby.
|
data/lib/pdf4me.rb
CHANGED
@@ -28,6 +28,12 @@ require 'pdf4me/actions/text_stamp'
|
|
28
28
|
require 'pdf4me/actions/complex_action'
|
29
29
|
require 'pdf4me/actions/convert_to_pdf'
|
30
30
|
require 'pdf4me/actions/optimize'
|
31
|
+
require 'pdf4me/actions/create_images'
|
32
|
+
require 'pdf4me/actions/extract'
|
33
|
+
require 'pdf4me/actions/merge'
|
34
|
+
require 'pdf4me/actions/pdf_a'
|
35
|
+
require 'pdf4me/actions/split'
|
36
|
+
require 'pdf4me/actions/stamp'
|
31
37
|
|
32
38
|
# models
|
33
39
|
require 'pdf4me/models/base'
|
@@ -40,6 +46,30 @@ require 'pdf4me/models/doc_metadata'
|
|
40
46
|
require 'pdf4me/models/page'
|
41
47
|
require 'pdf4me/models/optimize_action'
|
42
48
|
require 'pdf4me/models/optimize_res'
|
49
|
+
require 'pdf4me/models/color'
|
50
|
+
require 'pdf4me/models/custom_cms_config'
|
51
|
+
require 'pdf4me/models/extract_action'
|
52
|
+
require 'pdf4me/models/extract_res'
|
53
|
+
require 'pdf4me/models/image_action'
|
54
|
+
require 'pdf4me/models/create_images_res'
|
55
|
+
require 'pdf4me/models/merge_action'
|
56
|
+
require 'pdf4me/models/merge_res'
|
57
|
+
require 'pdf4me/models/page_selection'
|
58
|
+
require 'pdf4me/models/pdf_a_action'
|
59
|
+
require 'pdf4me/models/pdf_a_res'
|
60
|
+
require 'pdf4me/models/pdf_font'
|
61
|
+
require 'pdf4me/models/rgb_set'
|
62
|
+
require 'pdf4me/models/rotate'
|
63
|
+
require 'pdf4me/models/split_action'
|
64
|
+
require 'pdf4me/models/split_res'
|
65
|
+
require 'pdf4me/models/stamp_action'
|
66
|
+
require 'pdf4me/models/stamp_res'
|
67
|
+
require 'pdf4me/models/text'
|
68
|
+
require 'pdf4me/models/transform'
|
69
|
+
require 'pdf4me/models/translate'
|
70
|
+
require 'pdf4me/models/image'
|
71
|
+
|
72
|
+
|
43
73
|
|
44
74
|
module Pdf4me
|
45
75
|
def self.configure
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module Pdf4me
|
2
2
|
class ComplexAction
|
3
|
+
attr_accessor :notification
|
3
4
|
attr_reader :client
|
4
5
|
|
5
6
|
def client
|
@@ -37,6 +38,10 @@ module Pdf4me
|
|
37
38
|
errors.flatten
|
38
39
|
end
|
39
40
|
|
41
|
+
def notification
|
42
|
+
@notification || Pdf4me::Notification.new
|
43
|
+
end
|
44
|
+
|
40
45
|
protected
|
41
46
|
|
42
47
|
def attributes
|
@@ -14,7 +14,9 @@ module Pdf4me
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def save_path
|
17
|
-
@save_path ||=
|
17
|
+
@save_path ||= unless file.nil?
|
18
|
+
File.join(File.dirname(file), "#{File.basename(file, ".*")}.pdf")
|
19
|
+
end
|
18
20
|
end
|
19
21
|
|
20
22
|
def call_api
|
@@ -1,14 +1,10 @@
|
|
1
1
|
module Pdf4me
|
2
2
|
class ConvertToPdf < ComplexAction
|
3
|
-
ATTRIBUTES = %w|document convert_to_pdf_action
|
3
|
+
ATTRIBUTES = %w|document convert_to_pdf_action|
|
4
4
|
attr_accessor *ATTRIBUTES
|
5
5
|
|
6
6
|
def path
|
7
7
|
'/Convert/ConvertToPdf'
|
8
8
|
end
|
9
|
-
|
10
|
-
def notification
|
11
|
-
@notification || Pdf4me::Notification.new
|
12
|
-
end
|
13
9
|
end
|
14
10
|
end
|
File without changes
|
@@ -36,7 +36,9 @@ module Pdf4me
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def save_path
|
39
|
-
@save_path ||=
|
39
|
+
@save_path ||= unless file.nil?
|
40
|
+
File.join(File.dirname(file), "#{File.basename(file, ".*")}-thumbnail.#{image_format}")
|
41
|
+
end
|
40
42
|
end
|
41
43
|
|
42
44
|
def call_api
|
@@ -21,7 +21,9 @@ module Pdf4me
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def save_path
|
24
|
-
@save_path ||=
|
24
|
+
@save_path ||= unless file.nil?
|
25
|
+
File.join(File.dirname(file), "extracted_pages.pdf")
|
26
|
+
end
|
25
27
|
end
|
26
28
|
|
27
29
|
def call_api
|
@@ -41,7 +43,7 @@ module Pdf4me
|
|
41
43
|
errors.add(:pages, 'must be valid numeric value')
|
42
44
|
end
|
43
45
|
|
44
|
-
unless pages.all? {|i| i.is_a?(Integer) }
|
46
|
+
unless pages.all? { |i| i.is_a?(Integer) }
|
45
47
|
errors.add(:pages, 'contains values that are not numbers')
|
46
48
|
end
|
47
49
|
end
|