pdf4me 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5cab03031af5c80c55ae0c20a0bd35ea2da1566
4
- data.tar.gz: 39616938411754524c95e452ac15328cda1771e7
3
+ metadata.gz: db3d182d3b4af74c5ff907eb49e4285a1cecfb43
4
+ data.tar.gz: 371372c8ca58d1dd7fb5c44692298b81b0dd98b0
5
5
  SHA512:
6
- metadata.gz: 7809803d64511e1abb269457fedfa97ba27b1774b0ac55970ac88408cc0b5d97d2697c90f79d7f2814521fec505ded8140489f4a0eae5622c051e949b10a1079
7
- data.tar.gz: 871941878cfca1d14d6497053bcc1f7e34b2d8ff9f120ca9badac0622a3128bec2a1ee45646d314f27d1c404b1348e125cf6de46e79b2cc1908114d392e8eef4
6
+ metadata.gz: 42dffb34be3838d87978197c9fc32f65717a1b7654977c1ffdd44dd54c3c408b11f488959154142304f53e30e8587015c08d58524d9dfd2fc3ed00444478246a
7
+ data.tar.gz: b0850f533a3839c904ffa9296c28b1f20f4a5507cc39898a3783a98aee0896f162c7ae01a33733f1ea2f24ca2838084c39f16e01a26790eaccccc52951969319
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ ## Note
2
+ This documention is for Gem version 2.x.x, for documentation of Version 1.x.x, please refer the following [README](https://github.com/pdf4me/pdf4me-clientapi-ruby/tree/1-0-stable)
1
3
  # pdf4me
2
4
 
3
5
  **Pdf4me** is a PDF utility tool for Ruby and other languages.
@@ -157,16 +159,13 @@ a.run
157
159
 
158
160
 
159
161
  ## 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.
162
+ > These methods are more complex than the Basic Wrapper methods.
161
163
  >
162
164
  > By default all the Advanced methods run in blocking mode -
163
165
  > i.e you wait for the server to send you the response.
164
166
  >
165
167
  > 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.
168
+ then please configure the notification at the dashboard
170
169
  >
171
170
  >See Pdf4me-Developer page to configure the webhook on application level.
172
171
 
@@ -176,7 +175,7 @@ defined on the application/api level.
176
175
  `convert_file_to_pdf`. The request is instantiated as a hash with the `:req` key,
177
176
  that takes in `Pdf4me::ConvertToPdf` model.
178
177
 
179
- > The action takes three different models `:document`, `:convert_to_pdf_action` and `:notification` and returns
178
+ > The action takes two different models `:document`, `:convert_to_pdf_action` and returns
180
179
  `Pdf4me::ConvertToPdfRes`
181
180
 
182
181
  > To get more information regarding the models, please refer the provided [model definition](https://pdf4medoc.blob.core.windows.net/doc/index.html?java#converttopdfreq)
@@ -189,8 +188,7 @@ that takes in `Pdf4me::ConvertToPdf` model.
189
188
  doc_data: Base64.encode64(File.open(file_path, 'rb', &:read)),
190
189
  name: "TestDocToConvert.docx"
191
190
  ),
192
- convert_to_pdf_action: Pdf4me::ConvertToPdfAction.new,
193
- notification: Pdf4me::Notification.new(get_notification: true) # async, set false to invoke blocking mode.
191
+ convert_to_pdf_action: Pdf4me::ConvertToPdfAction.new
194
192
  )
195
193
  response = action.run
196
194
 
@@ -204,7 +202,7 @@ that takes in `Pdf4me::ConvertToPdf` model.
204
202
 
205
203
  > Given a PDF document, Optimize the document and return `Pdf4me::OptimizeRes`
206
204
  >
207
- > `:optimize` takes three different models `document`, `optimize_action` and `notification`
205
+ > `:optimize` takes two different models `document` and `optimize_action`
208
206
  >
209
207
  > `Pdf4me::OptimizeAction` takes multiple arguments, important amongst them being `profile`
210
208
  > * profile, valid values are `default`, `web`, `print`, `max`, `mRC`
@@ -234,10 +232,9 @@ that takes in `Pdf4me::ConvertToPdf` model.
234
232
  ### extract
235
233
  > Extract out pages from PDF. You can choose from the pages you want to get.
236
234
 
237
- > `extract` takes three model arguments
235
+ > `extract` takes two model arguments
238
236
  > * `extract_action`
239
237
  > * `document`
240
- > * `notification` - non mandatory
241
238
 
242
239
  > 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
240
 
@@ -250,8 +247,7 @@ that takes in `Pdf4me::ConvertToPdf` model.
250
247
  ),
251
248
  extract_action: Pdf4me::ExtractAction.new(
252
249
  extract_pages: [1, 2, 5]
253
- ),
254
- notification: Pdf4me::Notification.new(get_notification: true) # async
250
+ )
255
251
  )
256
252
  response = action.run
257
253
 
@@ -265,10 +261,9 @@ that takes in `Pdf4me::ConvertToPdf` model.
265
261
  > Creates images from the PDF Document. This is useful if you want to create thumbnails for the PDF.<br>
266
262
  > The options are highly configurable to get the desired output.
267
263
  > The output would be a base64 encoded object that you have to save.
268
- > `create_images` takes three different arguments.
264
+ > `create_images` takes two different arguments.
269
265
  > * `document`
270
266
  > * `image_action`
271
- > * `notification` - non mandatory
272
267
 
273
268
  > Each model has their own set of attributes and hence can be configured further.
274
269
  The full documentation of model attributes are available at [model definition](https://pdf4medoc.blob.core.windows.net/doc/index.html?curl#createimagesreq)
@@ -305,10 +300,9 @@ The full documentation of model attributes are available at [model definition](h
305
300
 
306
301
  ### merge
307
302
  > Merges two or more PDF and gives MergeRes, a Base64 Encoded file
308
- > `merge` takes three model arguments
303
+ > `merge` takes two model arguments
309
304
  > * `documents` - An Array of `Pdf4me::Document`
310
305
  > * `merge_action` - `Pdf4me::MergeAction` model - non mandatory
311
- > * `notification` - `Pdf4me::Notification` model - non mandatory
312
306
 
313
307
  > 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
308
 
@@ -341,10 +335,9 @@ The full documentation of model attributes are available at [model definition](h
341
335
 
342
336
  ### pdf_a
343
337
  > Creates PDF/A Documents from normal PDF document.
344
- > `pdf_a` takes three model arguments.
338
+ > `pdf_a` takes two model arguments.
345
339
  > * `document` - a valid instance of `Pdf4me::Document`
346
340
  > * `pdf_a_action` - a valid instance of `Pdf4me::PdfAAction`
347
- > * `notification` - a valid instance of `Pdf4me::Notification` - non mandatory
348
341
  >
349
342
  > 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
343
  ```ruby
@@ -373,10 +366,9 @@ The full documentation of model attributes are available at [model definition](h
373
366
 
374
367
  ### split
375
368
  > Given a PDF, split the PDF into parts
376
- > `split` takes up three models
369
+ > `split` takes up two models
377
370
  > * `document` - a valid instance of `Pdf4me::Document`
378
371
  > * `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
372
  >
381
373
  > 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
374
 
@@ -406,10 +398,9 @@ The full documentation of model attributes are available at [model definition](h
406
398
  > You can stamp either a text or image to PDF, There are two separate methods defined to help you with stamping
407
399
  > - Stamp PDF with image
408
400
  > - Stamp PDF with Text
409
- > `stamp` takes three model arguments
401
+ > `stamp` takes two model arguments
410
402
  * `document` - a valid instance of `Pdf4me::Document`
411
403
  > * `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
404
  >
414
405
  > 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
406
 
@@ -422,8 +413,10 @@ The full documentation of model attributes are available at [model definition](h
422
413
  ),
423
414
  stamp_action: Pdf4me::StampAction.new(
424
415
  image: Pdf4me::Image.new(
425
- image_data: Base64.encode64(File.open(image_path, 'rb', &:read))
426
- )
416
+ image_data: Base64.encode64(File.open(image_path, 'rb', &:read)),
417
+ recetangle: Pdf4me::Rectangle.new(width: 200, height: 200)
418
+ ),
419
+
427
420
  )
428
421
  )
429
422
  response = action.run
@@ -68,7 +68,7 @@ require 'pdf4me/models/text'
68
68
  require 'pdf4me/models/transform'
69
69
  require 'pdf4me/models/translate'
70
70
  require 'pdf4me/models/image'
71
-
71
+ require 'pdf4me/models/rectangle'
72
72
 
73
73
 
74
74
  module Pdf4me
@@ -1,6 +1,5 @@
1
1
  module Pdf4me
2
2
  class ComplexAction
3
- attr_accessor :notification
4
3
  attr_reader :client
5
4
 
6
5
  def client
@@ -38,10 +37,6 @@ module Pdf4me
38
37
  errors.flatten
39
38
  end
40
39
 
41
- def notification
42
- @notification || Pdf4me::Notification.new
43
- end
44
-
45
40
  protected
46
41
 
47
42
  def attributes
@@ -16,19 +16,17 @@ module Pdf4me
16
16
 
17
17
  def valid_objects?
18
18
  documents.is_a?(Array) &&
19
- merge_action.is_a?(Pdf4me::MergeAction) &&
20
- notification.is_a?(Pdf4me::Notification)
19
+ merge_action.is_a?(Pdf4me::MergeAction)
21
20
  end
22
21
 
23
22
  def valid_instances?
24
- notification.valid? && merge_action.valid?
23
+ merge_action.valid?
25
24
  end
26
25
 
27
26
  def serialize_attributes
28
27
  {
29
28
  documents: documents.map { |document| document.attributes },
30
- merge_action: merge_action.attributes,
31
- notification: notification.attributes
29
+ merge_action: merge_action.attributes
32
30
  }
33
31
  end
34
32
  end
@@ -32,7 +32,6 @@ module Pdf4me
32
32
  end
33
33
 
34
34
  def post(path, params)
35
- logger.debug(params)
36
35
  request = Typhoeus::Request.new(
37
36
  request_url(path),
38
37
  method: :post,
@@ -41,7 +40,7 @@ module Pdf4me
41
40
  'Accept': 'application/json',
42
41
  'Content-Type': 'application/json',
43
42
  'Authorization': "Basic #{config.token}",
44
- 'User-Agent': "Pdf4meClient/#{VERSION}/ruby"
43
+ 'User-Agent': "Pdf4me/ruby/#{VERSION}"
45
44
  },
46
45
  timeout: 0,
47
46
  ssl_verifypeer: true,
@@ -65,7 +64,7 @@ module Pdf4me
65
64
  'Accept': 'application/octet-stream',
66
65
  'Content-Type': 'multipart/form-data',
67
66
  'Authorization': "Basic #{config.token}",
68
- 'User-Agent': "Pdf4meClient/#{VERSION}/ruby"
67
+ 'User-Agent': "Pdf4me/ruby/#{VERSION}"
69
68
  },
70
69
  timeout: 0,
71
70
  ssl_verifypeer: true,
@@ -13,5 +13,9 @@ module Pdf4me
13
13
  }
14
14
  attr_accessor *ATTRIBUTES.keys
15
15
  validates_presence_of :doc_data
16
+
17
+ def inspect
18
+ "#<#{self.class}:0x#{object_id.to_s(16)}>"
19
+ end
16
20
  end
17
21
  end
@@ -2,10 +2,27 @@ module Pdf4me
2
2
  class Image < Base
3
3
  ATTRIBUTES = {
4
4
  image_data: 'String',
5
- image_type: 'String'
5
+ image_type: 'String',
6
+ rectangle: 'Rectangle',
7
+ file_name: 'String',
8
+ compression: 'String',
9
+ rotate: 'Rotate',
10
+ translate: 'Translate',
11
+ transform: 'Transform'
6
12
  }
7
13
  attr_accessor *ATTRIBUTES.keys
8
14
 
9
15
  validates_presence_of :image_data
16
+ validates_inclusion_of :compression, in: %w|cCITTFax flate dCT|
17
+
18
+ def inspect
19
+ "#<#{self.class}:0x#{object_id.to_s(16)}>"
20
+ end
21
+
22
+ def defaults
23
+ {
24
+ compression: 'flate'
25
+ }
26
+ end
10
27
  end
11
28
  end
@@ -0,0 +1,15 @@
1
+ module Pdf4me
2
+ class Rectangle < Base
3
+ ATTRIBUTES = {
4
+ x: 'Integer',
5
+ y: 'Integer',
6
+ width: 'Integer',
7
+ height: 'Integer'
8
+ }
9
+
10
+ attr_accessor *ATTRIBUTES.keys
11
+ validates_presence_of :width, :height
12
+ end
13
+ end
14
+
15
+
@@ -1,3 +1,3 @@
1
1
  module Pdf4me
2
- VERSION = "2.0.4"
2
+ VERSION = "2.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdf4me
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - arpanlepcha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-14 00:00:00.000000000 Z
11
+ date: 2018-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -176,6 +176,7 @@ files:
176
176
  - lib/pdf4me/models/pdf_a_action.rb
177
177
  - lib/pdf4me/models/pdf_a_res.rb
178
178
  - lib/pdf4me/models/pdf_font.rb
179
+ - lib/pdf4me/models/rectangle.rb
179
180
  - lib/pdf4me/models/rgb_set.rb
180
181
  - lib/pdf4me/models/rotate.rb
181
182
  - lib/pdf4me/models/split_action.rb
@@ -258,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
259
  version: '0'
259
260
  requirements: []
260
261
  rubyforge_project:
261
- rubygems_version: 2.6.11
262
+ rubygems_version: 2.5.1
262
263
  signing_key:
263
264
  specification_version: 4
264
265
  summary: Pdf4me Ruby Gem