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
@@ -0,0 +1,35 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class Merge < ComplexAction
|
3
|
+
ATTRIBUTES = %w|documents merge_action|
|
4
|
+
attr_accessor *ATTRIBUTES
|
5
|
+
|
6
|
+
def path
|
7
|
+
'/Merge/Merge'
|
8
|
+
end
|
9
|
+
|
10
|
+
def merge_action
|
11
|
+
@merge_action || Pdf4me::MergeAction.new
|
12
|
+
end
|
13
|
+
|
14
|
+
# this does not follow the convention at all.
|
15
|
+
protected
|
16
|
+
|
17
|
+
def valid_objects?
|
18
|
+
documents.is_a?(Array) &&
|
19
|
+
merge_action.is_a?(Pdf4me::MergeAction) &&
|
20
|
+
notification.is_a?(Pdf4me::Notification)
|
21
|
+
end
|
22
|
+
|
23
|
+
def valid_instances?
|
24
|
+
notification.valid? && merge_action.valid?
|
25
|
+
end
|
26
|
+
|
27
|
+
def serialize_attributes
|
28
|
+
{
|
29
|
+
documents: documents.map { |document| document.attributes },
|
30
|
+
merge_action: merge_action.attributes,
|
31
|
+
notification: notification.attributes
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -15,10 +15,11 @@ module Pdf4me
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def save_path
|
18
|
-
@save_path ||=
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
@save_path ||= unless file1.nil? && file2.nil?
|
19
|
+
File.join(File.dirname(file1),
|
20
|
+
"Merged-#{File.basename(file1, ".*")}-#{File.basename(file2, ".*")}.pdf"
|
21
|
+
)
|
22
|
+
end
|
22
23
|
end
|
23
24
|
|
24
25
|
def call_api
|
File without changes
|
@@ -26,7 +26,9 @@ module Pdf4me
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def save_path
|
29
|
-
@save_path ||=
|
29
|
+
@save_path ||= unless file.nil?
|
30
|
+
File.join(File.dirname(file), "#{File.basename(file, ".*")}-optimized.pdf")
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
34
|
def call_api
|
File without changes
|
@@ -26,8 +26,15 @@ module Pdf4me
|
|
26
26
|
|
27
27
|
validate :page_attributes
|
28
28
|
|
29
|
+
def pages=(value)
|
30
|
+
@pages = Array(value)
|
31
|
+
end
|
32
|
+
|
33
|
+
|
29
34
|
def save_path
|
30
|
-
@save_path ||=
|
35
|
+
@save_path ||= unless file.nil?
|
36
|
+
File.join(File.dirname(file), "#{File.basename(file, ".*")}-stamped.pdf")
|
37
|
+
end
|
31
38
|
end
|
32
39
|
|
33
40
|
def path
|
@@ -54,7 +61,7 @@ module Pdf4me
|
|
54
61
|
errors.add(:pages, 'must be valid numeric value')
|
55
62
|
end
|
56
63
|
|
57
|
-
unless pages.all? {|i| i.is_a?(Integer) }
|
64
|
+
unless pages.all? { |i| i.is_a?(Integer) }
|
58
65
|
errors.add(:pages, 'contains values that are not numbers')
|
59
66
|
end
|
60
67
|
end
|
File without changes
|
data/lib/pdf4me/client.rb
CHANGED
File without changes
|
data/lib/pdf4me/configuration.rb
CHANGED
File without changes
|
data/lib/pdf4me/exceptions.rb
CHANGED
File without changes
|
data/lib/pdf4me/models/base.rb
CHANGED
@@ -17,8 +17,12 @@ module Pdf4me
|
|
17
17
|
attrs = self.class::ATTRIBUTES.stringify_keys.keys
|
18
18
|
attrs.each_with_object({}) do |attribute, memo|
|
19
19
|
value = send(attribute)
|
20
|
+
if value.kind_of?(Pdf4me::Base)
|
21
|
+
value = value.attributes
|
22
|
+
end
|
23
|
+
|
20
24
|
if value.present?
|
21
|
-
memo[attribute.camelize(:lower)] =
|
25
|
+
memo[attribute.camelize(:lower)] = value
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class CustomCmsConfig < Base
|
3
|
+
ATTRIBUTES = {
|
4
|
+
white: 'RGBSet',
|
5
|
+
c: 'RGBSet',
|
6
|
+
m: 'RGBSet',
|
7
|
+
y: 'RGBSet',
|
8
|
+
k: 'RGBSet',
|
9
|
+
cm: 'RGBSet',
|
10
|
+
cy: 'RGBSet',
|
11
|
+
ck: 'RGBSet',
|
12
|
+
my: 'RGBSet',
|
13
|
+
mk: 'RGBSet',
|
14
|
+
yk: 'RGBSet',
|
15
|
+
cmy: 'RGBSet',
|
16
|
+
cmk: 'RGBSet',
|
17
|
+
cyk: 'RGBSet',
|
18
|
+
myk: 'RGBSet',
|
19
|
+
cmyk: 'RGBSet'
|
20
|
+
}
|
21
|
+
attr_accessor *ATTRIBUTES.keys
|
22
|
+
end
|
23
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class ExtractAction < Base
|
3
|
+
|
4
|
+
ATTRIBUTES = {
|
5
|
+
extract_pages: 'Array<Integer>',
|
6
|
+
custom_properties: 'Array<KeyValuePairStringString>'
|
7
|
+
}
|
8
|
+
attr_accessor *ATTRIBUTES.keys
|
9
|
+
|
10
|
+
validate :page_attributes
|
11
|
+
|
12
|
+
def extract_pages=(pages)
|
13
|
+
@extract_pages = Array(pages)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def page_attributes
|
19
|
+
if extract_pages.empty?
|
20
|
+
errors.add(:extract_pages, 'must be valid numeric value')
|
21
|
+
end
|
22
|
+
|
23
|
+
unless extract_pages.all? { |i| i.is_a?(Integer) }
|
24
|
+
errors.add(:extract_pages, 'contains values that are not numbers')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class ImageAction < Base
|
3
|
+
ATTRIBUTES = {
|
4
|
+
page_selection: 'PageSelection',
|
5
|
+
center: 'BOOLEAN',
|
6
|
+
fit_page: 'BOOLEAN',
|
7
|
+
bits_per_pixel: 'Integer',
|
8
|
+
bilevel_threshold: 'Integer',
|
9
|
+
width_pixel: 'Integer',
|
10
|
+
height_pixel: 'Integer',
|
11
|
+
width_point: 'Integer',
|
12
|
+
height_point: 'Integer',
|
13
|
+
render_options: 'Array<String>',
|
14
|
+
rotate_mode: 'String',
|
15
|
+
preserve_active_ratio: 'BOOLEAN',
|
16
|
+
image_quality: 'Integer',
|
17
|
+
cms_engine: 'String',
|
18
|
+
custom_cMS_config: 'CustomCmsConfig',
|
19
|
+
dithering: 'String',
|
20
|
+
dpi: 'Integer',
|
21
|
+
fill_order: 'String',
|
22
|
+
filter_ratio: 'Integer',
|
23
|
+
image_extension: 'String',
|
24
|
+
color_space: 'String',
|
25
|
+
compression: 'String',
|
26
|
+
custom_properties: 'Array<KeyValuePairStringString>'
|
27
|
+
}
|
28
|
+
attr_accessor *ATTRIBUTES.keys
|
29
|
+
|
30
|
+
validates_presence_of :image_extension
|
31
|
+
|
32
|
+
validates_inclusion_of(
|
33
|
+
:bits_per_pixel,
|
34
|
+
in: [1, 8, 24, 32]
|
35
|
+
)
|
36
|
+
|
37
|
+
validates_inclusion_of(
|
38
|
+
:rotate_mode,
|
39
|
+
in: %w|none attribute potrait landscape|
|
40
|
+
)
|
41
|
+
|
42
|
+
validates_inclusion_of(
|
43
|
+
:cms_engine,
|
44
|
+
in: %w|none neugebauer lcms customCMS|
|
45
|
+
)
|
46
|
+
|
47
|
+
validates_inclusion_of(
|
48
|
+
:dithering,
|
49
|
+
in: %w|none floydSteinberg halftone pattern g3Optimized g4Optimized atkinson|
|
50
|
+
)
|
51
|
+
|
52
|
+
validates_inclusion_of(
|
53
|
+
:fill_order,
|
54
|
+
in: %w|mSB ISB|
|
55
|
+
)
|
56
|
+
|
57
|
+
validates_inclusion_of(
|
58
|
+
:image_extension,
|
59
|
+
in: %w|jpg jpeg bmp gif jb2 jp2 jpf jpx png tif tiff|
|
60
|
+
)
|
61
|
+
|
62
|
+
validates_inclusion_of(
|
63
|
+
:color_space,
|
64
|
+
in: %w|RGB RGBA Gray GrayA CMYK YCbCR YCbCrK Palette LAB CMYK_Konly CMYKA|
|
65
|
+
)
|
66
|
+
|
67
|
+
validates_inclusion_of(
|
68
|
+
:compression,
|
69
|
+
in: %w|raw jPEG flate LZW group3 group3_2D group4 jBIG2 jPEG2000 tlFFJPEG|
|
70
|
+
)
|
71
|
+
|
72
|
+
validates_numericality_of(
|
73
|
+
:bilevel_threshold,
|
74
|
+
greater_than_or_equal_to: 0,
|
75
|
+
less_than_or_equal_to: 255
|
76
|
+
)
|
77
|
+
|
78
|
+
validates_numericality_of(
|
79
|
+
:image_quality,
|
80
|
+
greater_than_or_equal_to: 1,
|
81
|
+
less_than_or_equal_to: 100
|
82
|
+
)
|
83
|
+
|
84
|
+
validates_numericality_of(
|
85
|
+
:filter_ratio,
|
86
|
+
greater_than_or_equal_to: 1,
|
87
|
+
less_than_or_equal_to: 3
|
88
|
+
)
|
89
|
+
|
90
|
+
def defaults
|
91
|
+
{
|
92
|
+
center: false,
|
93
|
+
fit_page: true,
|
94
|
+
bits_per_pixel: 24,
|
95
|
+
bilevel_threshold: 181,
|
96
|
+
rotate_mode: 'attribute',
|
97
|
+
preserve_aspect_ratio: true,
|
98
|
+
image_quality: 80,
|
99
|
+
cms_engine: 'lcms',
|
100
|
+
dithering: 'floydSteinberg',
|
101
|
+
dpi: 150,
|
102
|
+
fill_order: 'mSB',
|
103
|
+
filter_ratio: 1,
|
104
|
+
color_space: 'RGB',
|
105
|
+
compression: 'LZW',
|
106
|
+
}
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
File without changes
|
data/lib/pdf4me/models/page.rb
CHANGED
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class PageSelection < Base
|
3
|
+
ATTRIBUTES = {
|
4
|
+
page_nrs: 'Array<Integer>',
|
5
|
+
page_ids: 'Array<String>',
|
6
|
+
page_sequence: 'String'
|
7
|
+
}
|
8
|
+
attr_accessor *ATTRIBUTES.keys
|
9
|
+
|
10
|
+
validates_inclusion_of(
|
11
|
+
:page_sequence,
|
12
|
+
in: %w|all first last odd even notFirst notLast|
|
13
|
+
)
|
14
|
+
|
15
|
+
def defaults
|
16
|
+
{
|
17
|
+
page_sequence: 'all'
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|