ilovepdf 1.0.1 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -2
- data/LICENSE +0 -0
- data/README.md +13 -1
- data/ilovepdf.gemspec +4 -4
- data/lib/ilovepdf/errors.rb +2 -0
- data/lib/ilovepdf/file.rb +4 -3
- data/lib/ilovepdf/helper.rb +13 -0
- data/lib/ilovepdf/ilovepdf.rb +8 -5
- data/lib/ilovepdf/task.rb +32 -14
- data/lib/ilovepdf/tool/extract.rb +18 -0
- data/lib/ilovepdf/tool/pagenumber.rb +2 -2
- data/lib/ilovepdf/tool/pdfa.rb +3 -2
- data/lib/ilovepdf/tool/validate_pdfa.rb +31 -0
- data/lib/ilovepdf/version.rb +1 -1
- data/lib/ilovepdf.rb +4 -0
- data/samples/extract_advanced.rb +23 -0
- data/samples/extract_basic.rb +15 -0
- data/samples/imagepdf_advanced.rb +25 -0
- data/samples/imagepdf_basic.rb +14 -0
- data/samples/pdfa_advanced.rb +4 -1
- data/samples/pdfa_basic.rb +0 -3
- data/samples/validatepdfa_advanced.rb +18 -0
- data/samples/validatepdfa_basic.rb +16 -0
- metadata +41 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40f8c75f0001c5018bfe9916546965192e6581d8
|
4
|
+
data.tar.gz: 9ca611361ccd485ea7a84555dec6a9b63879adf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 474cde19c9fa02183d3a967e7d2f4ded8e6e008e0a8d05b1f73f8e087618774e996a5d2c59893aad552c4d3d724f542224326668f91f59fbf21d214c230cb33f
|
7
|
+
data.tar.gz: 489a5bf27973204b423ef75ec5039727d54c3073262011d02defddd90924e2255a4834b2a374c9425ec5e5e3efa8f73bc95fa65d547f0eda8f675720c7c5d887
|
data/.travis.yml
CHANGED
data/LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
iLovePDF Api - Ruby Library
|
2
2
|
--------------------------
|
3
|
+
[![Build Status](https://travis-ci.org/ilovepdf/ilovepdf-php.svg?branch=master)](https://travis-ci.org/ilovepdf/ilovepdf-php)
|
3
4
|
[![GitHub version](https://badge.fury.io/gh/ilovepdf%2Filovepdf-ruby.svg)](https://badge.fury.io/gh/ilovepdf%2Filovepdf-ruby)
|
4
5
|
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
5
6
|
|
@@ -22,11 +23,13 @@ Develop and automate PDF processing tasks like:
|
|
22
23
|
* Stamp a Watermark
|
23
24
|
* Repair PDF
|
24
25
|
* PDF to PDF/A
|
26
|
+
* Validate PDF/A
|
27
|
+
* Extract
|
25
28
|
|
26
29
|
Each one with several settings to get your desired results.
|
27
30
|
|
28
31
|
## Requirements
|
29
|
-
Ruby 2.
|
32
|
+
Ruby 2.3 or greater
|
30
33
|
|
31
34
|
## Installation
|
32
35
|
|
@@ -103,6 +106,15 @@ end
|
|
103
106
|
| packaged_filename | This allows you to specify the filename of the compressed file in case there is more than 1 file to be downloaded | |
|
104
107
|
| output_filename | The final name of the processed file | |
|
105
108
|
|
109
|
+
#### Methods to query after performing the **execute** API method:
|
110
|
+
* result: It has stored the last **Ilovepdf::Response**
|
111
|
+
|
112
|
+
#### Methods to query after performing the **download** API method:
|
113
|
+
* download_info: Returns a [struct](https://ruby-doc.org/core-2.2.0/Struct.html) with the following info
|
114
|
+
* :output_filename
|
115
|
+
* :output_file
|
116
|
+
* :output_filetype
|
117
|
+
|
106
118
|
### Tool attributes
|
107
119
|
|
108
120
|
All tools have specific attributes you can access and modify.
|
data/ilovepdf.gemspec
CHANGED
@@ -20,14 +20,14 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.bindir = "exe"
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
|
-
spec.required_ruby_version = '>= 2.
|
23
|
+
spec.required_ruby_version = '>= 2.3'
|
24
24
|
|
25
25
|
spec.add_runtime_dependency 'rest-client', '~> 2'
|
26
|
-
spec.add_runtime_dependency 'jwt', '~>
|
26
|
+
spec.add_runtime_dependency 'jwt', '~> 2'
|
27
27
|
|
28
28
|
|
29
|
-
spec.add_development_dependency "bundler", "
|
30
|
-
spec.add_development_dependency "rake", "
|
29
|
+
spec.add_development_dependency "bundler", ">= 1.16"
|
30
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
31
31
|
spec.add_development_dependency "rspec", "~> 3.0"
|
32
32
|
spec.add_development_dependency "byebug", "~> 9"
|
33
33
|
spec.add_development_dependency "webmock", "~> 3"
|
data/lib/ilovepdf/errors.rb
CHANGED
data/lib/ilovepdf/file.rb
CHANGED
@@ -12,12 +12,13 @@ module Ilovepdf
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def file_options
|
15
|
-
{
|
15
|
+
h = {
|
16
16
|
server_filename: self.server_filename,
|
17
17
|
filename: self.filename,
|
18
|
-
rotate: self.rotate
|
19
|
-
password: self.password
|
18
|
+
rotate: self.rotate
|
20
19
|
}
|
20
|
+
h[:password] = self.password if self.password
|
21
|
+
h
|
21
22
|
end
|
22
23
|
|
23
24
|
def rotate= degrees
|
data/lib/ilovepdf/ilovepdf.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Ilovepdf
|
2
2
|
class Ilovepdf
|
3
|
-
attr_accessor :api_version, :token, :encrypt_key
|
3
|
+
attr_accessor :api_version, :token, :encrypt_key, :debug, :timeout, :long_timeout
|
4
4
|
|
5
5
|
START_SERVER = 'https://api.ilovepdf.com'.freeze
|
6
|
-
API_VERSION = 'v1'.freeze
|
6
|
+
API_VERSION = 'ruby.v1'.freeze
|
7
7
|
TOKEN_ALGORITHM = 'HS256'.freeze
|
8
8
|
ALL_ENDPOINTS = [:start, :upload, :process, :download, :task].freeze
|
9
9
|
LONG_JOB_ENDPOINTS = [:process, :upload, :download].freeze
|
@@ -13,10 +13,13 @@ module Ilovepdf
|
|
13
13
|
def initialize(public_key=nil, secret_key=nil)
|
14
14
|
set_api_keys(public_key, secret_key)
|
15
15
|
api_version = API_VERSION
|
16
|
+
self.timeout = 10
|
17
|
+
self.long_timeout = nil
|
16
18
|
end
|
17
19
|
|
18
20
|
def new_task(tool_name)
|
19
|
-
|
21
|
+
camelized_name = Helper.camelize_str(tool_name.to_s)
|
22
|
+
task_klass = ::Ilovepdf::Tool.const_get(camelized_name) rescue false
|
20
23
|
unless task_klass
|
21
24
|
raise ::Ilovepdf::Error.new("Unknown tool '#{tool_name}'. Available tools: #{self.class.all_tool_names.to_s}")
|
22
25
|
end
|
@@ -24,7 +27,7 @@ module Ilovepdf
|
|
24
27
|
end
|
25
28
|
|
26
29
|
def self.all_tool_names
|
27
|
-
::Ilovepdf::Tool.constants.map(
|
30
|
+
::Ilovepdf::Tool.constants.map{|tool_name| Helper.underscore_str(tool_name.to_s)}
|
28
31
|
end
|
29
32
|
|
30
33
|
def self.raise_exceptions=(value)
|
@@ -62,7 +65,7 @@ module Ilovepdf
|
|
62
65
|
def send_request(http_method, endpoint, extra_opts={})
|
63
66
|
to_server = worker_server ? worker_server : START_SERVER
|
64
67
|
|
65
|
-
timeout_to_use = LONG_JOB_ENDPOINTS.include?(endpoint.to_sym) ?
|
68
|
+
timeout_to_use = LONG_JOB_ENDPOINTS.include?(endpoint.to_sym) ? self.long_timeout : self.timeout
|
66
69
|
extra_opts[:body] ||= {}
|
67
70
|
extra_opts[:headers] ||= {}
|
68
71
|
|
data/lib/ilovepdf/task.rb
CHANGED
@@ -3,7 +3,10 @@ module Ilovepdf
|
|
3
3
|
attr_accessor :task_id, :tool, :packaged_filename, :output_filename,
|
4
4
|
:ignore_errors, :ignore_password, :try_pdf_repair
|
5
5
|
|
6
|
-
|
6
|
+
attr_reader :result
|
7
|
+
|
8
|
+
API_PARAMS = []
|
9
|
+
DOWNLOAD_INFO = [:output_filename, :output_file, :output_filetype]
|
7
10
|
|
8
11
|
def initialize(public_key, secret_key)
|
9
12
|
super(public_key, secret_key)
|
@@ -38,8 +41,29 @@ module Ilovepdf
|
|
38
41
|
files.last
|
39
42
|
end
|
40
43
|
|
41
|
-
def download(path=nil)
|
42
|
-
download_file
|
44
|
+
def download(path=nil, create_directory: false)
|
45
|
+
download_file
|
46
|
+
|
47
|
+
if path
|
48
|
+
path = Pathname.new(path).to_s if path.is_a?(Pathname)
|
49
|
+
path.chop! if path.end_with? '/'
|
50
|
+
else
|
51
|
+
path = '.'
|
52
|
+
end
|
53
|
+
|
54
|
+
destination = "#{path}/#{download_info.output_filename}"
|
55
|
+
FileUtils.mkdir_p(path) if create_directory
|
56
|
+
::File.open(destination, 'wb'){|file| file.write(download_info.output_file) }
|
57
|
+
true
|
58
|
+
end
|
59
|
+
|
60
|
+
def blob
|
61
|
+
download_file
|
62
|
+
download_info.output_file
|
63
|
+
end
|
64
|
+
|
65
|
+
def download_info
|
66
|
+
@download_info ||= Struct.new(*DOWNLOAD_INFO).new
|
43
67
|
end
|
44
68
|
|
45
69
|
# [API Methods] Actions on task
|
@@ -49,7 +73,7 @@ module Ilovepdf
|
|
49
73
|
end
|
50
74
|
|
51
75
|
def execute
|
52
|
-
perform_process_request
|
76
|
+
@result = perform_process_request
|
53
77
|
end
|
54
78
|
|
55
79
|
def delete!
|
@@ -87,7 +111,7 @@ module Ilovepdf
|
|
87
111
|
@files = new_array_of_files
|
88
112
|
end
|
89
113
|
|
90
|
-
def download_file
|
114
|
+
def download_file
|
91
115
|
response = perform_filedownload_request
|
92
116
|
content_disposition = response.headers[:content_disposition]
|
93
117
|
|
@@ -98,15 +122,9 @@ module Ilovepdf
|
|
98
122
|
filename = match_data[1].gsub('"', '')
|
99
123
|
end
|
100
124
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
else
|
105
|
-
path = '.'
|
106
|
-
end
|
107
|
-
destination = "#{path}/#{filename}"
|
108
|
-
::File.open(destination, 'wb'){|file| file.write(response.raw_body) }
|
109
|
-
file = response.raw_body
|
125
|
+
download_info.output_filename = filename
|
126
|
+
download_info.output_file = response.raw_body
|
127
|
+
download_info.output_filetype = ::File.extname(filename)
|
110
128
|
true
|
111
129
|
end
|
112
130
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Ilovepdf
|
2
|
+
module Tool
|
3
|
+
class Extract < ::Ilovepdf::Task
|
4
|
+
API_PARAMS = [:detailed]
|
5
|
+
attr_accessor *API_PARAMS
|
6
|
+
|
7
|
+
def initialize(public_key, secret_key)
|
8
|
+
self.tool = :extract
|
9
|
+
super(public_key, secret_key)
|
10
|
+
end
|
11
|
+
|
12
|
+
def detailed
|
13
|
+
@detailed ||= false
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -9,8 +9,8 @@ module Ilovepdf
|
|
9
9
|
|
10
10
|
attr_accessor *API_PARAMS
|
11
11
|
|
12
|
-
VERTICAL_POSITION_VALUES = ['bottom', 'top']
|
13
|
-
HORIZONTAL_POSITION_VALUES = ['left', '
|
12
|
+
VERTICAL_POSITION_VALUES = ['bottom', 'middle' ,'top']
|
13
|
+
HORIZONTAL_POSITION_VALUES = ['left', 'center', 'right']
|
14
14
|
FONT_FAMILY_VALUES = [ 'Arial', 'Arial Unicode MS', 'Verdana', 'Courier',
|
15
15
|
'Times New Roman', 'Comic Sans MS',
|
16
16
|
'WenQuanYi Zen Hei', 'Lohit Marathi'
|
data/lib/ilovepdf/tool/pdfa.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Ilovepdf
|
2
2
|
module Tool
|
3
3
|
class Pdfa < ::Ilovepdf::Task
|
4
|
-
API_PARAMS = [:conformance]
|
4
|
+
API_PARAMS = [:conformance, :allow_downgrade]
|
5
5
|
attr_accessor *API_PARAMS
|
6
6
|
|
7
7
|
CONFORMANCE_VALUES = ['pdfa-1b', 'pdfa-1a', 'pdfa-2b', 'pdfa-2u',
|
@@ -11,6 +11,7 @@ module Ilovepdf
|
|
11
11
|
def initialize(public_key, secret_key)
|
12
12
|
self.tool = :pdfa
|
13
13
|
super(public_key, secret_key)
|
14
|
+
self.allow_downgrade = true
|
14
15
|
end
|
15
16
|
|
16
17
|
def conformance= new_val
|
@@ -19,7 +20,7 @@ module Ilovepdf
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def conformance
|
22
|
-
@conformance ||= '
|
23
|
+
@conformance ||= 'pdfa-2b'
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Ilovepdf
|
2
|
+
module Tool
|
3
|
+
class ValidatePdfa < ::Ilovepdf::Task
|
4
|
+
API_PARAMS = [:conformance]
|
5
|
+
attr_accessor *API_PARAMS
|
6
|
+
|
7
|
+
CONFORMANCE_VALUES = ['pdfa-1b', 'pdfa-1a', 'pdfa-2b', 'pdfa-2u',
|
8
|
+
'pdfa-2a', 'pdfa-3b', 'pdfa-3u', 'pdfa-3a'
|
9
|
+
]
|
10
|
+
|
11
|
+
def initialize(public_key, secret_key)
|
12
|
+
self.tool = :validatepdfa
|
13
|
+
super(public_key, secret_key)
|
14
|
+
end
|
15
|
+
|
16
|
+
def conformance= new_val
|
17
|
+
raise Errors::ArgumentEnumError.new(CONFORMANCE_VALUES) unless CONFORMANCE_VALUES.include? new_val
|
18
|
+
@conformance = new_val
|
19
|
+
end
|
20
|
+
|
21
|
+
def conformance
|
22
|
+
@conformance ||= 'pdfa-2b'
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def download_file
|
27
|
+
raise ::Ilovepdf::Errors::UnsupportedFunctionalityError.new('This tool does not download files (Check in the sample files how to use it)')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/ilovepdf/version.rb
CHANGED
data/lib/ilovepdf.rb
CHANGED
@@ -9,6 +9,7 @@ require 'rest-client'
|
|
9
9
|
# Base classes
|
10
10
|
require "ilovepdf/errors"
|
11
11
|
require "ilovepdf/response"
|
12
|
+
require "ilovepdf/helper"
|
12
13
|
require "ilovepdf/ilovepdf"
|
13
14
|
require "ilovepdf/file"
|
14
15
|
require "ilovepdf/task"
|
@@ -20,12 +21,15 @@ require 'ilovepdf/tool/merge'
|
|
20
21
|
require 'ilovepdf/tool/officepdf'
|
21
22
|
require 'ilovepdf/tool/pagenumber'
|
22
23
|
require 'ilovepdf/tool/pdfa'
|
24
|
+
require 'ilovepdf/tool/validate_pdfa'
|
23
25
|
require 'ilovepdf/tool/pdfjpg'
|
24
26
|
require 'ilovepdf/tool/repair'
|
25
27
|
require 'ilovepdf/tool/rotate'
|
26
28
|
require 'ilovepdf/tool/split'
|
27
29
|
require 'ilovepdf/tool/unlock'
|
28
30
|
require 'ilovepdf/tool/watermark'
|
31
|
+
require 'ilovepdf/tool/protect'
|
32
|
+
require 'ilovepdf/tool/extract'
|
29
33
|
|
30
34
|
module Ilovepdf
|
31
35
|
class << self
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require 'ilovepdf'
|
3
|
+
|
4
|
+
# You can call task class directly
|
5
|
+
my_task = Ilovepdf::Tool::Extract.new("PUBLIC_KEY", "SECRET_KEY");
|
6
|
+
|
7
|
+
# File object keeps information about its server_filename and the properties you can set
|
8
|
+
file = my_task.add_file '/path/to/file/document.pdf'
|
9
|
+
|
10
|
+
# By setting this parameter to true,
|
11
|
+
# we'll have detailed contents extraction into a CSV-formatted file
|
12
|
+
my_task.detailed = true
|
13
|
+
|
14
|
+
# and set name for output file.
|
15
|
+
# the task will set the correct file extension for you.
|
16
|
+
my_task.output_filename = 'csv_filename'
|
17
|
+
|
18
|
+
# Process files
|
19
|
+
response = my_task.execute
|
20
|
+
|
21
|
+
# and finally download the file. If no path is set, it will be downloaded on your current working directory
|
22
|
+
# It will download a text file with Linux line endings
|
23
|
+
my_task.download
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require 'ilovepdf'
|
3
|
+
|
4
|
+
# You can call task class directly
|
5
|
+
my_task = Ilovepdf::Tool::Extract.new("PUBLIC_KEY", "SECRET_KEY");
|
6
|
+
|
7
|
+
# File object keeps information about its server_filename and the properties you can set
|
8
|
+
file = my_task.add_file '/path/to/file/document.pdf'
|
9
|
+
|
10
|
+
# Process files
|
11
|
+
response = my_task.execute
|
12
|
+
|
13
|
+
# and finally download the file. If no path is set, it will be downloaded on your current working directory
|
14
|
+
# It will download a text file with Linux line endings
|
15
|
+
my_task.download
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require 'ilovepdf'
|
3
|
+
|
4
|
+
# You can call task class directly
|
5
|
+
my_task = Ilovepdf::Tool::Imagepdf.new("PUBLIC_KEY", "SECRET_KEY");
|
6
|
+
|
7
|
+
# File object keeps information about its server_filename and the properties you can set
|
8
|
+
file = my_task.add_file '/path/to/file/photo.png'
|
9
|
+
file2 = my_task.add_file '/path/to/file/image.tiff'
|
10
|
+
|
11
|
+
# Merge After: Default is true. If it is false then it will download a zip file with a pdf for each image
|
12
|
+
my_task.merge_after = false
|
13
|
+
|
14
|
+
# and set name for output file.
|
15
|
+
# the task will set the correct file extension for you.
|
16
|
+
my_task.output_filename = 'pdf_filename'
|
17
|
+
|
18
|
+
# and name for splitted document (inside the zip file)
|
19
|
+
my_task.packaged_filename = 'zip_filename'
|
20
|
+
|
21
|
+
# Process files
|
22
|
+
response = my_task.execute
|
23
|
+
|
24
|
+
# and finally download the file. If no path is set, it will be downloaded on your current working directory
|
25
|
+
my_task.download
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require 'ilovepdf'
|
3
|
+
|
4
|
+
# You can call task class directly
|
5
|
+
my_task = Ilovepdf::Tool::Imagepdf.new("PUBLIC_KEY", "SECRET_KEY");
|
6
|
+
|
7
|
+
# File object keeps information about its server_filename and the properties you can set
|
8
|
+
file = my_task.add_file '/path/to/file/photo.png'
|
9
|
+
|
10
|
+
# Process files
|
11
|
+
response = my_task.execute
|
12
|
+
|
13
|
+
# and finally download the file. If no path is set, it will be downloaded on your current working directory
|
14
|
+
my_task.download
|
data/samples/pdfa_advanced.rb
CHANGED
@@ -8,7 +8,10 @@ my_task = Ilovepdf::Tool::Pdfa.new("PUBLIC_KEY", "SECRET_KEY");
|
|
8
8
|
file = my_task.add_file '/path/to/file/document.pdf'
|
9
9
|
|
10
10
|
# Set conformance
|
11
|
-
|
11
|
+
my_task.conformance = 'pdfa-2a'
|
12
|
+
|
13
|
+
# don't allow downgrading in case your conformance level fails
|
14
|
+
file.allow_downgrade = false
|
12
15
|
|
13
16
|
# and set name for output file.
|
14
17
|
# the task will set the correct file extension for you.
|
data/samples/pdfa_basic.rb
CHANGED
@@ -7,9 +7,6 @@ my_task = Ilovepdf::Tool::Pdfa.new("PUBLIC_KEY", "SECRET_KEY");
|
|
7
7
|
# File object keeps information about its server_filename and the properties you can set
|
8
8
|
file = my_task.add_file '/path/to/file/document.pdf'
|
9
9
|
|
10
|
-
# Set conformance
|
11
|
-
file.conformance = 'pdfa-1b'
|
12
|
-
|
13
10
|
# Finally is time to process the files. i.e We'll send them to Ilovepdf servers :)
|
14
11
|
response = my_task.execute
|
15
12
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require 'ilovepdf'
|
3
|
+
|
4
|
+
# You can call task class directly
|
5
|
+
my_task = Ilovepdf::Tool::ValidatePdfa.new("PUBLIC_KEY", "SECRET_KEY");
|
6
|
+
|
7
|
+
# File object keeps information about its server_filename and the properties you can set
|
8
|
+
file = my_task.add_file '/path/to/file/document.pdf'
|
9
|
+
|
10
|
+
file.conformance = 'pdfa-2a'
|
11
|
+
|
12
|
+
# Finally is time to process the files. i.e We'll send them to Ilovepdf servers :)
|
13
|
+
response = my_task.execute
|
14
|
+
|
15
|
+
response.body['validations'].each do |results|
|
16
|
+
file = my_task.files.find{|file| file.server_filename == results['server_filename']}
|
17
|
+
puts "File with name '#{file.filename}' has the following status: #{results['status']}"
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require 'ilovepdf'
|
3
|
+
|
4
|
+
# You can call task class directly
|
5
|
+
my_task = Ilovepdf::Tool::ValidatePdfa.new("PUBLIC_KEY", "SECRET_KEY");
|
6
|
+
|
7
|
+
# File object keeps information about its server_filename and the properties you can set
|
8
|
+
file = my_task.add_file '/path/to/file/document.pdf'
|
9
|
+
|
10
|
+
# Finally is time to process the files. i.e We'll send them to Ilovepdf servers :)
|
11
|
+
response = my_task.execute
|
12
|
+
|
13
|
+
response.body['validations'].each do |results|
|
14
|
+
file = my_task.files.find{|file| file.server_filename == results['server_filename']}
|
15
|
+
puts "File with name '#{file.filename}' has the following status: #{results['status']}"
|
16
|
+
end
|
metadata
CHANGED
@@ -1,125 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ilovepdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonardo Collazo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: jwt
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.16'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
54
|
+
version: '1.16'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 12.3.3
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 12.3.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '3.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: byebug
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '9'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '9'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: webmock
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '3'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '3'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: addressable
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '2.5'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - ~>
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '2.5'
|
125
125
|
description: Develop and automate PDF processing tasks like Compress PDF, Merge PDF,
|
@@ -132,10 +132,10 @@ executables: []
|
|
132
132
|
extensions: []
|
133
133
|
extra_rdoc_files: []
|
134
134
|
files:
|
135
|
-
- .editorconfig
|
136
|
-
- .gitignore
|
137
|
-
- .rspec
|
138
|
-
- .travis.yml
|
135
|
+
- ".editorconfig"
|
136
|
+
- ".gitignore"
|
137
|
+
- ".rspec"
|
138
|
+
- ".travis.yml"
|
139
139
|
- Gemfile
|
140
140
|
- LICENSE
|
141
141
|
- README.md
|
@@ -146,10 +146,12 @@ files:
|
|
146
146
|
- lib/ilovepdf.rb
|
147
147
|
- lib/ilovepdf/errors.rb
|
148
148
|
- lib/ilovepdf/file.rb
|
149
|
+
- lib/ilovepdf/helper.rb
|
149
150
|
- lib/ilovepdf/ilovepdf.rb
|
150
151
|
- lib/ilovepdf/response.rb
|
151
152
|
- lib/ilovepdf/task.rb
|
152
153
|
- lib/ilovepdf/tool/compress.rb
|
154
|
+
- lib/ilovepdf/tool/extract.rb
|
153
155
|
- lib/ilovepdf/tool/imagepdf.rb
|
154
156
|
- lib/ilovepdf/tool/merge.rb
|
155
157
|
- lib/ilovepdf/tool/officepdf.rb
|
@@ -161,10 +163,15 @@ files:
|
|
161
163
|
- lib/ilovepdf/tool/rotate.rb
|
162
164
|
- lib/ilovepdf/tool/split.rb
|
163
165
|
- lib/ilovepdf/tool/unlock.rb
|
166
|
+
- lib/ilovepdf/tool/validate_pdfa.rb
|
164
167
|
- lib/ilovepdf/tool/watermark.rb
|
165
168
|
- lib/ilovepdf/version.rb
|
166
169
|
- samples/compress_advanced.rb
|
167
170
|
- samples/compress_basic.rb
|
171
|
+
- samples/extract_advanced.rb
|
172
|
+
- samples/extract_basic.rb
|
173
|
+
- samples/imagepdf_advanced.rb
|
174
|
+
- samples/imagepdf_basic.rb
|
168
175
|
- samples/merge_advanced.rb
|
169
176
|
- samples/merge_basic.rb
|
170
177
|
- samples/pdfa_advanced.rb
|
@@ -179,6 +186,8 @@ files:
|
|
179
186
|
- samples/try_catch_errors.rb
|
180
187
|
- samples/unlock_advanced.rb
|
181
188
|
- samples/unlock_basic.rb
|
189
|
+
- samples/validatepdfa_advanced.rb
|
190
|
+
- samples/validatepdfa_basic.rb
|
182
191
|
- samples/watermark_advanced.rb
|
183
192
|
- samples/watermark_basic.rb
|
184
193
|
- uploads/sample_pdf.pdf
|
@@ -192,17 +201,17 @@ require_paths:
|
|
192
201
|
- lib
|
193
202
|
required_ruby_version: !ruby/object:Gem::Requirement
|
194
203
|
requirements:
|
195
|
-
- -
|
204
|
+
- - ">="
|
196
205
|
- !ruby/object:Gem::Version
|
197
|
-
version: '2.
|
206
|
+
version: '2.3'
|
198
207
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
199
208
|
requirements:
|
200
|
-
- -
|
209
|
+
- - ">="
|
201
210
|
- !ruby/object:Gem::Version
|
202
211
|
version: '0'
|
203
212
|
requirements: []
|
204
213
|
rubyforge_project:
|
205
|
-
rubygems_version: 2.
|
214
|
+
rubygems_version: 2.6.14
|
206
215
|
signing_key:
|
207
216
|
specification_version: 4
|
208
217
|
summary: A library in Ruby for iLovePDF Api
|