dynamicpdf_api 1.1.1 → 1.2.0

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
  SHA256:
3
- metadata.gz: c4109120bdd17cb9a250a144ac5d70ab3bd76f159cde2a464ea2bb6b46277c3a
4
- data.tar.gz: 1b0c03015bd985f960553f505086efc7ebf744e7811d7d5631c1cb3d5ec1aaba
3
+ metadata.gz: 4032069e887ac6170c27e3e62b6c53937012fc0fc532bcc1ee078db7cc699279
4
+ data.tar.gz: '079b748ab778f13fe486b969f371f563456f7ad2aaebdcea1161b04be0d01d91'
5
5
  SHA512:
6
- metadata.gz: c02430211c4ca94e5e9011fecee5a5cc8117127f1a1526b03f58dd8d81746964e9a81e1ee00c00028e743a75710f5f0a110119f992602d11308001619a93db15
7
- data.tar.gz: d3d4145f7c2718dca04d42657d81b72f67ca173f12f96456fb27ec50fb4dc6c26a9b3a7447f9e2b792cfffb25ff797d51a7ad59b143488d1690646e8ddd93bfb
6
+ metadata.gz: 87516c46b99ab12217f99c0997f9b64dc65f2636d3117aae776a941208bc5c758cc3a4d48e4c2b2e4b6370ace9938b6708d77365f1c9e70a54bbdb08c0c255e9
7
+ data.tar.gz: 79cec9da77a1828a018a1865caa6f6d99c5278973c191a991e4132c2ea46d4dfa5e9f20f3524d41c21da18cca25c69296b380ad76465c597eb15d95fc9f267c4
@@ -119,6 +119,9 @@ module DynamicPDFApi
119
119
  ret_object = PdfResponse.new(out_data)
120
120
  ret_object.is_successful = true
121
121
  else
122
+ if ret_object.status_code == '401'
123
+ raise "Invalid api key specified."
124
+ end
122
125
  out_data_json = JSON.parse(out_data)
123
126
  ret_object.error_json = out_data
124
127
  ret_object.error_message = if !out_data_json['message'].nil?
@@ -53,6 +53,9 @@ module DynamicPDFApi
53
53
  if ret_object.status_code == '200'
54
54
  ret_object.is_successful = true
55
55
  else
56
+ if ret_object.status_code == '401'
57
+ raise "Invalid api key specified."
58
+ end
56
59
  out_data_json = JSON.parse(out_data)
57
60
  ret_object.error_json = out_data
58
61
  ret_object.error_message = if !out_data_json['message'].nil?
@@ -42,8 +42,9 @@ module DynamicPDFApi
42
42
  attr_accessor :image_size
43
43
 
44
44
  def initialize(resource)
45
- @resource = resource
45
+ super()
46
46
  @_endpoint_name = 'pdf-image'
47
+ @resource = resource
47
48
  end
48
49
 
49
50
  def process
@@ -184,6 +185,10 @@ module DynamicPDFApi
184
185
  rasterizer_response.status_code = response.code
185
186
  rasterizer_response.is_successful = true
186
187
  else
188
+ if rasterizer_response.status_code == '401'
189
+ raise "Invalid api key specified."
190
+ end
191
+ out_data_json = JSON.parse(out_data)
187
192
  rasterizer_response.error_json = out_data
188
193
  rasterizer_response.error_message = if !out_data_json["message"].nil?
189
194
  out_data_json["message"]
@@ -170,7 +170,7 @@ module DynamicPDFApi
170
170
  #
171
171
  def add_html(html, basepath = nil, size = nil, orientation = nil, margins = nil)
172
172
  input = nil
173
- if file.is_a?(String)
173
+ if html.is_a?(String)
174
174
  input = HtmlInput.new(HtmlResource.new(html), basepath, size, orientation, margins)
175
175
  else
176
176
  input = HtmlInput.new(resource, basepath, size, orientation, margins)
@@ -366,6 +366,9 @@ module DynamicPDFApi
366
366
  ret_object = PdfResponse.new(out_data)
367
367
  ret_object.is_successful = true
368
368
  else
369
+ if ret_object.status_code == '401'
370
+ raise "Invalid api key specified."
371
+ end
369
372
  out_data_json = JSON.parse(out_data)
370
373
  ret_object.error_json = out_data
371
374
  ret_object.error_message = if !out_data_json["message"].nil?
@@ -52,6 +52,9 @@ module DynamicPDFApi
52
52
  if ret_object.status_code == '200'
53
53
  ret_object.is_successful = true
54
54
  else
55
+ if ret_object.status_code == '401'
56
+ raise "Invalid api key specified."
57
+ end
55
58
  out_data_json = JSON.parse(out_data)
56
59
  ret_object.error_json = out_data
57
60
  ret_object.error_message = if !out_data_json['message'].nil?
@@ -1,6 +1,7 @@
1
1
  module DynamicPDFApi
2
2
  require_relative 'Endpoint'
3
3
  require_relative 'PdfTextResponse'
4
+ require_relative 'TextOrder'
4
5
 
5
6
  #
6
7
  # Represents the pdf text endpoint.
@@ -12,15 +13,15 @@ module DynamicPDFApi
12
13
  # @param resource [PdfResource] The image resource of type PdfResource.
13
14
  # @param start_page [int] The start page.
14
15
  # @param page_count [int] The page count.
16
+ # @param text_order The text extraction order.
15
17
  #
16
- def initialize(resource, start_page = 1, page_count = 0)
18
+ def initialize(resource, start_page = 1, page_count = 0, text_order = TextOrder::STREAM)
17
19
  @_endpoint_name = 'pdf-text'
18
- @start_page = 1
19
- @page_count = 0
20
20
  super()
21
21
  @resource = resource
22
22
  @start_page = start_page
23
23
  @page_count = page_count
24
+ @text_order = text_order
24
25
  end
25
26
 
26
27
  #
@@ -33,6 +34,11 @@ module DynamicPDFApi
33
34
  #
34
35
  attr_accessor :page_count
35
36
 
37
+ #
38
+ # Gets or sets the text extraction order.
39
+ #
40
+ attr_accessor :text_order
41
+
36
42
  #
37
43
  # Process the pdf resource to get pdf's text.
38
44
  # @return PdfTextResponse Returns collection of PdfTextResponse.
@@ -45,7 +51,7 @@ module DynamicPDFApi
45
51
  'Content-Type': 'application/pdf'
46
52
  }
47
53
  uri = URI.parse("#{@base_url}/v1.0/#{@_endpoint_name}")
48
- params = { 'startPage' => @start_page, 'pageCount' => @page_count }
54
+ params = { 'startPage' => @start_page, 'pageCount' => @page_count, 'textOrder' => @text_order }
49
55
  uri.query = URI.encode_www_form(params)
50
56
 
51
57
  request = Net::HTTP::Post.new(uri.request_uri, header)
@@ -69,6 +75,9 @@ module DynamicPDFApi
69
75
  if ret_object.status_code == '200'
70
76
  ret_object.is_successful = true
71
77
  else
78
+ if ret_object.status_code == '401'
79
+ raise "Invalid api key specified."
80
+ end
72
81
  out_data_json = JSON.parse(out_data)
73
82
  ret_object.error_json = out_data
74
83
  ret_object.error_message = if !out_data_json['message'].nil?
@@ -10,13 +10,13 @@ module DynamicPDFApi
10
10
  #
11
11
  # @param json_content [String] The json content
12
12
  #
13
- def initialize(json_content)
14
- @content = JSON.pretty_generate(json_content).gsub('\\\\', '\\').gsub('\"', '"').gsub('\\\r', '\r').gsub('\\\n', '\n').gsub(
15
- '\\\t', '\t'
16
- )
17
- @content = @content[1..@content.length - 2]
13
+ def initialize(json_content = nil)
14
+
15
+ @content = nil
16
+ super(json_content) unless json_content.nil?
17
+
18
+ @content = JSON.parse(json_content)
18
19
 
19
- super(json_content)
20
20
  end
21
21
 
22
22
  #
@@ -51,6 +51,9 @@ module DynamicPDFApi
51
51
  if ret_object.status_code == '200'
52
52
  ret_object.is_successful = true
53
53
  else
54
+ if ret_object.status_code == '401'
55
+ raise "Invalid api key specified."
56
+ end
54
57
  out_data_json = JSON.parse(out_data)
55
58
  ret_object.error_json = out_data
56
59
  ret_object.error_message = if !out_data_json['message'].nil?
@@ -3,13 +3,6 @@ module DynamicPDFApi
3
3
  # Represents the base class for response.
4
4
  #
5
5
  class Response
6
- def initialize
7
- @_is_successful = false
8
- @_error_message = nil
9
- @_error_id = nil
10
- @_status_code = nil
11
- @_error_json = nil
12
- end
13
6
 
14
7
  #
15
8
  # Gets the boolean, indicating the response's status.
@@ -6,18 +6,18 @@ module DynamicPDFApi
6
6
  #
7
7
  class Security
8
8
  def initialize(user_pwd = nil, owner_pwd = nil)
9
- @_user_password = user_pwd
10
- @_owner_password = owner_pwd
11
- @_allow_copy = nil
12
- @_allow_edit = nil
13
- @_allow_print = nil
14
- @_allow_update_annots_and_fields = nil
9
+ @user_password = user_pwd
10
+ @owner_password = owner_pwd
11
+ @allow_copy = nil
12
+ @allow_edit = nil
13
+ @allow_print = nil
14
+ @allow_update_annots_and_fields = nil
15
15
 
16
- @_allow_accessibility = nil
17
- @_allow_form_filling = nil
18
- @_allow_high_resolution_printing = nil
19
- @_allow_document_assembly = nil
20
- @_type = nil
16
+ @allow_accessibility = nil
17
+ @allow_form_filling = nil
18
+ @allow_high_resolution_printing = nil
19
+ @allow_document_assembly = nil
20
+ @type = nil
21
21
  end
22
22
 
23
23
  #
@@ -0,0 +1,21 @@
1
+ module DynamicPDFApi
2
+ #
3
+ #
4
+ # Specifies text extraction order.
5
+ #
6
+ #
7
+ class TextOrder
8
+ #
9
+ # Stream text extraction order.
10
+ #
11
+ STREAM = "Stream".freeze
12
+ #
13
+ # Visible text extraction order.
14
+ #
15
+ VISIBLE = "Visible".freeze
16
+ #
17
+ # VisibleExtraSpace text extraction order.
18
+ #
19
+ VISIBLE_EXTRA_SPACE = "VisibleExtraSpace".freeze
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyClient
4
- VERSION = "1.1.1"
4
+ VERSION = "1.2.0"
5
5
  end
data/lib/ruby_client.rb CHANGED
@@ -72,6 +72,7 @@ require_relative "ruby_client/SecurityType.rb"
72
72
  require_relative "ruby_client/SignatureFieldInformation.rb"
73
73
  require_relative "ruby_client/Template.rb"
74
74
  require_relative "ruby_client/TextFieldInformation.rb"
75
+ require_relative "ruby_client/TextOrder.rb"
75
76
  require_relative "ruby_client/TextReplace.rb"
76
77
  require_relative "ruby_client/UrlAction.rb"
77
78
  require_relative "ruby_client/UnitConverter.rb"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamicpdf_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dynamicpdf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-18 00:00:00.000000000 Z
11
+ date: 2025-05-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Ruby Client API that uses the DynamicPDF API to create, merge, split,
14
14
  form fill, stamp, secure/encrypt PDF documents and convert word/Excel files to PDF.
@@ -159,6 +159,7 @@ files:
159
159
  - lib/ruby_client/SignatureFieldInformation.rb
160
160
  - lib/ruby_client/Template.rb
161
161
  - lib/ruby_client/TextFieldInformation.rb
162
+ - lib/ruby_client/TextOrder.rb
162
163
  - lib/ruby_client/TextReplace.rb
163
164
  - lib/ruby_client/UnitConverter.rb
164
165
  - lib/ruby_client/UrlAction.rb