dynamicpdf_api 1.2.1 → 1.3.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: '0680c136fd344450e1b3f772c0ec4094781342bdee3114037fc27de04c036a8a'
4
- data.tar.gz: 4b5541b2b8d47dabc56c894857d1bf2fad98b53c770023d080ef7ac096fa4306
3
+ metadata.gz: a7ac0d6c7b3af40747eebd62d4bbe5312c47f7df899eeeace9e62baafd607f19
4
+ data.tar.gz: 6f3448f2d9daa4d345109bb187797ad2f4f385b5225c6217159868e4d4e79bee
5
5
  SHA512:
6
- metadata.gz: 1b8c8d62491859abfbb0bc5718fd9594b969e0689b5abd369fc283afca882186370e0bbe1e6edc311a98370e259d01443016fbd6e048e6e4ca6b544069af856e
7
- data.tar.gz: 9b104c7ea32e0a9f35cf3468eae12fb395d8f8a42ffa04b0894253d0e52b81323ada51db32ce83602a04d21482238572ca42cf3d81dc732795cb3fc0a68f0a29
6
+ metadata.gz: 5666463e8fdfa35d273f72b1e13cced90e661054cfb772329869f77069303c28fe7bdfb802ff9dbe5db68aaab7b1b114377d78e0ad15f85e1350287a57f646c1
7
+ data.tar.gz: 8536196f5815157f71fe925c4cd7879a1b09dc5e8ea1f8723d3e94207fbe927ab55b19a38cd9bb80c66a76b3bd4d17c9f6db3bfb4bb5543827fec8bbb59a12a1
@@ -0,0 +1,31 @@
1
+ module DynamicPDFApi
2
+ #
3
+ # Specifies Encryption Type.
4
+ #
5
+ class EncryptionType
6
+ #
7
+ # RC4 40 bit security.
8
+ #
9
+ RC440 = 'rc440'.freeze
10
+
11
+ #
12
+ # RC4 128 bit security.
13
+ #
14
+ RC4128 = 'rc4128'.freeze
15
+
16
+ #
17
+ # AES 128 bit security with CBC cipher mode.
18
+ #
19
+ AES128CBC = 'aes128cbc'.freeze
20
+
21
+ #
22
+ # AES 256 bit security with CBC cipher mode.
23
+ #
24
+ AES256CBC = 'aes256cbc'.freeze
25
+
26
+ #
27
+ # No security.
28
+ #
29
+ NONE = 'none'.freeze
30
+ end
31
+ end
@@ -0,0 +1,102 @@
1
+ module DynamicPDFApi
2
+ require_relative 'EncryptionType'
3
+
4
+ # Represents the PDF security info endpoint.
5
+ class PdfSecurityInfo
6
+ def initialize(data = {})
7
+ @encryption_type_string = data["encryptionType"]
8
+ @allow_edit = data["allowEdit"]
9
+ @allow_print = data["allowPrint"]
10
+ @allow_update_annots_and_fields = data["allowUpdateAnnotsAndFields"]
11
+ @allow_copy = data["allowCopy"]
12
+ @allow_high_resolution_printing = data["allowHighResolutionPrinting"]
13
+ @allow_document_assembly = data["allowDocumentAssembly"]
14
+ @allow_form_filling = data["allowFormFilling"]
15
+ @allow_accessibility = data["allowAccessibility"]
16
+ @encrypt_all_except_metadata = data["encryptAllExceptMetadata"]
17
+ @encrypt_only_file_attachments = data["encryptOnlyFileAttachments"]
18
+ @has_owner_password = data["hasOwnerPassword"]
19
+ @has_user_password = data["hasUserPassword"]
20
+ @encryption_type = encryption_type()
21
+ end
22
+
23
+ #
24
+ # Gets or sets if the document can be edited by the user.
25
+ #
26
+ attr_accessor :allow_edit
27
+
28
+ #
29
+ # Gets or sets if the document can be printed by the user.
30
+ #
31
+ attr_accessor :allow_print
32
+
33
+ #
34
+ # Gets or sets if annotations and form fields can be added, edited and modified by the user.
35
+ #
36
+ attr_accessor :allow_update_annots_and_fields
37
+
38
+ #
39
+ # Gets or sets if text and images can be copied to the clipboard by the user.
40
+ #
41
+ attr_accessor :allow_copy
42
+
43
+ #
44
+ # Gets or sets if the document can be printed at a high resolution by the user.
45
+ #
46
+ attr_accessor :allow_high_resolution_printing
47
+
48
+ #
49
+ # Gets or sets if the document can be assembled and manipulated by the user.
50
+ #
51
+ attr_accessor :allow_document_assembly
52
+
53
+ #
54
+ # Gets or sets if form filling should be allowed by the user.
55
+ #
56
+ attr_accessor :allow_form_filling
57
+
58
+ #
59
+ # Gets or sets if accessibility programs should be able to read the documents text and images for the user.
60
+ #
61
+ attr_accessor :allow_accessibility
62
+
63
+ #
64
+ # Gets or sets a value indicating whether all data should be encrypted except for metadata.
65
+ #
66
+ attr_accessor :encrypt_all_except_metadata
67
+
68
+ #
69
+ # Gets or sets a value indicating whether only file attachments should be encrypted.
70
+ #
71
+ attr_accessor :encrypt_only_file_attachments
72
+
73
+ #
74
+ # Gets or sets a value indicating whether the PDF document has an owner password set.
75
+ #
76
+ attr_accessor :has_owner_password
77
+
78
+ #
79
+ # Gets or sets a value indicating whether the PDF document has an user password set.
80
+ #
81
+ attr_accessor :has_user_password
82
+
83
+
84
+ # Gets or sets the encryption type.
85
+ attr_accessor :encryption_type_string
86
+
87
+ def encryption_type
88
+ case (@encryption_type_string).downcase
89
+ when "rc4-40"
90
+ EncryptionType::RC440
91
+ when "rc4-128"
92
+ EncryptionType::RC4128
93
+ when "aes-128-cbc"
94
+ EncryptionType::AES128CBC
95
+ when "aes-256-cbc"
96
+ EncryptionType::AES256CBC
97
+ else
98
+ EncryptionType::NONE
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,71 @@
1
+ module DynamicPDFApi
2
+ require_relative 'Endpoint'
3
+ require_relative 'PdfSecurityInfoResponse'
4
+
5
+ #
6
+ # Represents the pdf security info endpoint.
7
+ #
8
+ class PdfSecurityInfoEndpoint < Endpoint
9
+ #
10
+ # Initializes a new instance of the PdfSecurityInfoEndpoint class.
11
+ #
12
+ # @param resource [PdfResource] The resource of type PdfResource.
13
+ #
14
+ def initialize(resource)
15
+ super()
16
+ @resource = resource
17
+ @_endpoint_name = 'pdf-security-info'
18
+ end
19
+
20
+ #
21
+ # Process the pdf resource to get pdf's security information.
22
+ # @return PdfInfoResponse Returns collection of PdfSecurityInfoResponse.
23
+ #
24
+ def process
25
+ header = {
26
+ 'Authorization': "Bearer #{@api_key}",
27
+ 'Content-Length': @resource.data.length.to_s,
28
+ 'Expect': '100-continue',
29
+ 'Content-Type': 'application/pdf'
30
+ }
31
+ uri = URI.parse("#{@base_url}/v1.0/#{@_endpoint_name}")
32
+
33
+ request = Net::HTTP::Post.new(uri.request_uri, header)
34
+
35
+ req_options = {
36
+ use_ssl: uri.scheme == 'https',
37
+ verify_mode: OpenSSL::SSL::VERIFY_NONE
38
+
39
+ }
40
+
41
+ request.content_type = 'application/pdf'
42
+
43
+ request.body = @resource.data
44
+
45
+ response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
46
+ http.request(request)
47
+ end
48
+ out_data = response.body
49
+ ret_object = PdfSecurityInfoResponse.new(out_data)
50
+ ret_object.is_successful = false
51
+ ret_object.status_code = response.code
52
+ if ret_object.status_code == '200'
53
+ ret_object.is_successful = true
54
+ else
55
+ if ret_object.status_code == '401'
56
+ raise "Invalid api key specified."
57
+ end
58
+ out_data_json = JSON.parse(out_data)
59
+ ret_object.error_json = out_data
60
+ ret_object.error_message = if !out_data_json['message'].nil?
61
+ out_data_json['message']
62
+ else
63
+ "status_code : #{Net::HTTPResponse::CODE_TO_OBJ[ret_object.status_code]}"
64
+ end
65
+ ret_object.error_id = out_data_json['id']
66
+ end
67
+
68
+ ret_object
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,28 @@
1
+ module DynamicPDFApi
2
+ require_relative 'JsonResponse'
3
+ require_relative 'PdfSecurityInfo'
4
+
5
+ #
6
+ # Represents the pdf security info response.
7
+ #
8
+ class PdfSecurityInfoResponse < JsonResponse
9
+ #
10
+ # Initializes a new instance of the PdfSecurityInfoResponse class.
11
+ #
12
+ # @param json_content [String] The json content
13
+ #
14
+ def initialize(json_content = nil)
15
+ @content = nil
16
+ super(json_content) unless json_content.nil?
17
+ @content = PdfSecurityInfo.new(JSON.parse(json_content))
18
+
19
+ end
20
+ # # @content.instance_variable_set(:@encryption_type, @content.encryption_type)
21
+ # end
22
+
23
+ #
24
+ # Gets the collection of PdfContent.
25
+ #
26
+ attr_accessor :content
27
+ end
28
+ end
@@ -18,6 +18,6 @@ module DynamicPDFApi
18
18
  #
19
19
  # RC4 128 bit security.
20
20
  #
21
- RC_4128 = 'aC4128'.freeze
21
+ RC_4128 = 'rc4128'.freeze
22
22
  end
23
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyClient
4
- VERSION = "1.2.1"
4
+ VERSION = "1.3.0"
5
5
  end
data/lib/ruby_client.rb CHANGED
@@ -16,6 +16,7 @@ require_relative "ruby_client/DlexInput.rb"
16
16
  require_relative "ruby_client/DlexLayout.rb"
17
17
  require_relative "ruby_client/DlexResource.rb"
18
18
  require_relative "ruby_client/EncryptDocumentComponents.rb"
19
+ require_relative "ruby_client/EncryptionType.rb"
19
20
  require_relative "ruby_client/Endpoint.rb"
20
21
  require_relative "ruby_client/EndPointException.rb"
21
22
  require_relative "ruby_client/EndpointResource.rb"
@@ -59,6 +60,9 @@ require_relative "ruby_client/PdfInput.rb"
59
60
  require_relative "ruby_client/PdfInstructions.rb"
60
61
  require_relative "ruby_client/PdfResource.rb"
61
62
  require_relative "ruby_client/PdfResponse.rb"
63
+ require_relative "ruby_client/PdfSecurityInfo.rb"
64
+ require_relative "ruby_client/PdfSecurityInfoEndpoint.rb"
65
+ require_relative "ruby_client/PdfSecurityInfoResponse.rb"
62
66
  require_relative "ruby_client/PdfText.rb"
63
67
  require_relative "ruby_client/PdfTextResponse.rb"
64
68
  require_relative "ruby_client/PdfXmp.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.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dynamicpdf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-29 00:00:00.000000000 Z
11
+ date: 2025-11-14 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.
@@ -72,6 +72,7 @@ files:
72
72
  - lib/ruby_client/Elements/TextElement.rb
73
73
  - lib/ruby_client/Elements/ValueType.rb
74
74
  - lib/ruby_client/EncryptDocumentComponents.rb
75
+ - lib/ruby_client/EncryptionType.rb
75
76
  - lib/ruby_client/EndPointException.rb
76
77
  - lib/ruby_client/Endpoint.rb
77
78
  - lib/ruby_client/EndpointResource.rb
@@ -146,6 +147,9 @@ files:
146
147
  - lib/ruby_client/PdfInstructions.rb
147
148
  - lib/ruby_client/PdfResource.rb
148
149
  - lib/ruby_client/PdfResponse.rb
150
+ - lib/ruby_client/PdfSecurityInfo.rb
151
+ - lib/ruby_client/PdfSecurityInfoEndpoint.rb
152
+ - lib/ruby_client/PdfSecurityInfoResponse.rb
149
153
  - lib/ruby_client/PdfText.rb
150
154
  - lib/ruby_client/PdfTextResponse.rb
151
155
  - lib/ruby_client/PdfXmp.rb