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,33 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class PdfAAction < Base
|
3
|
+
ATTRIBUTES = {
|
4
|
+
fonts_to_subset: 'Array<PdfFont>',
|
5
|
+
compliance: 'String',
|
6
|
+
allow_downgrade: 'BOOLEAN',
|
7
|
+
allow_upgrade: 'BOOLEAN',
|
8
|
+
out_put_intent_profile: 'String',
|
9
|
+
linearize: 'BOOLEAN',
|
10
|
+
custom_properties: 'Array<KeyValuePairStringString>'
|
11
|
+
}
|
12
|
+
attr_accessor *ATTRIBUTES.keys
|
13
|
+
|
14
|
+
validates_inclusion_of(
|
15
|
+
:compliance,
|
16
|
+
in: %w|pdfA1b pdfA2B pdfA3b pdfA1a pdfA2a pdfA3a pdfA2u pdfA3u|
|
17
|
+
)
|
18
|
+
validates_inclusion_of(
|
19
|
+
:out_put_intent_profile,
|
20
|
+
in: %w|notSet sRGBColorSpace|
|
21
|
+
)
|
22
|
+
|
23
|
+
def defaults
|
24
|
+
{
|
25
|
+
compliance: 'pdf2Ab',
|
26
|
+
allow_downgrade: false,
|
27
|
+
allow_upgrade: false,
|
28
|
+
out_put_intent_profile: 'notSet',
|
29
|
+
linearize: false
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class SplitAction < Base
|
3
|
+
ATTRIBUTES = {
|
4
|
+
split_after_page: 'Integer',
|
5
|
+
split_sequence: 'Array<Integer>',
|
6
|
+
recurring_split_after_page: 'Integer',
|
7
|
+
custom_properties: 'Array<KeyValuePairStringString>'
|
8
|
+
}
|
9
|
+
attr_accessor *ATTRIBUTES.keys
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class StampAction < Base
|
3
|
+
ATTRIBUTES = {
|
4
|
+
page_sequence: 'String',
|
5
|
+
relative_pos_x: 'Integer',
|
6
|
+
relative_pos_y: 'Integer',
|
7
|
+
size_x: 'Integer',
|
8
|
+
size_y: 'Integer',
|
9
|
+
rotate: 'Float',
|
10
|
+
autoorientation: 'BOOLEAN',
|
11
|
+
alpha: 'Double',
|
12
|
+
scale: 'String',
|
13
|
+
align_x: 'String',
|
14
|
+
align_y: 'String',
|
15
|
+
stamp_type: 'String',
|
16
|
+
text: 'Text',
|
17
|
+
image: 'Image',
|
18
|
+
custom_properties: 'Array<KeyValuePairStringString>'
|
19
|
+
}
|
20
|
+
attr_accessor *ATTRIBUTES.keys
|
21
|
+
|
22
|
+
validates_inclusion_of(
|
23
|
+
:page_sequence,
|
24
|
+
in: %w|all first last odd even notFirst notLast|,
|
25
|
+
if: ->(model){ /[a-z]+/i.match?(model.page_sequence) }
|
26
|
+
)
|
27
|
+
|
28
|
+
validates_inclusion_of(
|
29
|
+
:scale,
|
30
|
+
in: ['relToA4']
|
31
|
+
)
|
32
|
+
|
33
|
+
validates_inclusion_of(
|
34
|
+
:align_x,
|
35
|
+
in: %w|left center right|
|
36
|
+
)
|
37
|
+
|
38
|
+
validates_inclusion_of(
|
39
|
+
:align_y,
|
40
|
+
in: %w|top middle bottom|
|
41
|
+
)
|
42
|
+
|
43
|
+
validates_inclusion_of(
|
44
|
+
:stamp_type,
|
45
|
+
in: %w|annotation foreground background|
|
46
|
+
)
|
47
|
+
|
48
|
+
def defaults
|
49
|
+
{
|
50
|
+
page_sequence: '1',
|
51
|
+
autoorientation: false,
|
52
|
+
alpha: 1.0,
|
53
|
+
scale: 'relToA4',
|
54
|
+
align_x: 'left',
|
55
|
+
align_y: 'bottom',
|
56
|
+
stamp_type: 'annotation',
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class Text < Base
|
3
|
+
ATTRIBUTES = {
|
4
|
+
format: 'BOOLEAN',
|
5
|
+
size: 'Integer',
|
6
|
+
font: 'String',
|
7
|
+
color: 'Color',
|
8
|
+
font_encoding: 'String',
|
9
|
+
value: 'String',
|
10
|
+
mode: 'String',
|
11
|
+
rotate: 'Rotate',
|
12
|
+
translate: 'Translate',
|
13
|
+
transform: 'Transform'
|
14
|
+
}
|
15
|
+
attr_accessor *ATTRIBUTES.keys
|
16
|
+
|
17
|
+
validates_presence_of :value
|
18
|
+
|
19
|
+
validates_inclusion_of(
|
20
|
+
:font_encoding,
|
21
|
+
in: %w|unicode winAnsi|
|
22
|
+
)
|
23
|
+
|
24
|
+
validates_inclusion_of(
|
25
|
+
:mode,
|
26
|
+
in: %w|fill stroke|
|
27
|
+
)
|
28
|
+
|
29
|
+
def defaults
|
30
|
+
{
|
31
|
+
format: false,
|
32
|
+
font_encoding: 'unicode',
|
33
|
+
mode: 'fill'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Pdf4me
|
2
|
+
class Transform < Base
|
3
|
+
ATTRIBUTES = {
|
4
|
+
a: 'Integer',
|
5
|
+
b: 'Integer',
|
6
|
+
c: 'Integer',
|
7
|
+
d: 'Integer',
|
8
|
+
x: 'Integer',
|
9
|
+
y: 'Integer'
|
10
|
+
}
|
11
|
+
attr_accessor *ATTRIBUTES.keys
|
12
|
+
|
13
|
+
validates_presence_of :a, :b, :c, :d, :x, :y
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
File without changes
|
data/lib/pdf4me/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pdf4me::ConvertFileToPdf, type: :action do
|
4
|
+
|
5
|
+
it "extends Base Action" do
|
6
|
+
expect(subject).to be_kind_of(Pdf4me::WrapperAction)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'validations' do
|
10
|
+
it { should validate_presence_of :file }
|
11
|
+
it { should validate_presence_of :save_path }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'methods' do
|
15
|
+
describe '.path' do
|
16
|
+
it 'should give the right path' do
|
17
|
+
expect(subject.path).to eq('/Convert/ConvertFileToPdf')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pdf4me::ConvertToPdf, type: :action do
|
4
|
+
|
5
|
+
it "extends Base Action" do
|
6
|
+
expect(subject).to be_kind_of(Pdf4me::ComplexAction)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'methods' do
|
10
|
+
describe '.path' do
|
11
|
+
it 'should give the right path' do
|
12
|
+
expect(subject.path).to eq('/Convert/ConvertToPdf')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pdf4me::CreateThumbnail, type: :action do
|
4
|
+
|
5
|
+
it "extends Base Action" do
|
6
|
+
expect(subject).to be_kind_of(Pdf4me::WrapperAction)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'validations' do
|
10
|
+
it { should validate_presence_of :file }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'methods' do
|
14
|
+
describe '.path' do
|
15
|
+
it 'should give the right path' do
|
16
|
+
expect(subject.path).to eq('/Image/CreateThumbnail')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '.save_path' do
|
21
|
+
it 'should give file_name' do
|
22
|
+
subject.file = 'abc.pdf'
|
23
|
+
expect(subject.save_path).to eq('./abc-thumbnail.png')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pdf4me::ExtractPages, type: :action do
|
4
|
+
|
5
|
+
it 'extends Base Action' do
|
6
|
+
expect(subject).to be_kind_of(Pdf4me::WrapperAction)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'validations' do
|
10
|
+
before(:each) do
|
11
|
+
subject.pages=(5)
|
12
|
+
end
|
13
|
+
it { should validate_presence_of :file }
|
14
|
+
it { should validate_presence_of :save_path }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'methods' do
|
18
|
+
describe '.path' do
|
19
|
+
it 'should give the right path' do
|
20
|
+
expect(subject.path).to eq('/Extract/ExtractPages')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pdf4me::Extract, type: :action do
|
4
|
+
|
5
|
+
it 'extends Base Action' do
|
6
|
+
expect(subject).to be_kind_of(Pdf4me::ComplexAction)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'methods' do
|
10
|
+
describe '.path' do
|
11
|
+
it 'should give the right path' do
|
12
|
+
expect(subject.path).to eq('/Extract/Extract')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pdf4me::Merge, type: :action do
|
4
|
+
|
5
|
+
it 'extends Base action' do
|
6
|
+
expect(subject).to be_kind_of(Pdf4me::ComplexAction)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'methods' do
|
10
|
+
describe '.path' do
|
11
|
+
it 'should give the right path' do
|
12
|
+
expect(subject.path).to eq('/Merge/Merge')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pdf4me::MergeTwoPdfs, type: :action do
|
4
|
+
|
5
|
+
it 'extends Base Action' do
|
6
|
+
expect(subject).to be_kind_of(Pdf4me::WrapperAction)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'validations' do
|
10
|
+
it { should validate_presence_of :file1 }
|
11
|
+
it { should validate_presence_of :file2 }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'methods' do
|
15
|
+
describe '.path' do
|
16
|
+
it 'should give the right path' do
|
17
|
+
expect(subject.path).to eq('/Merge/Merge2Pdfs')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pdf4me::OptimizeByProfile, type: :action do
|
4
|
+
|
5
|
+
it "extends Base Action" do
|
6
|
+
expect(subject).to be_kind_of(Pdf4me::WrapperAction)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'validations' do
|
10
|
+
it { should validate_presence_of :file }
|
11
|
+
it { should validate_presence_of :profile }
|
12
|
+
it { should validate_presence_of :save_path }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'methods' do
|
16
|
+
describe '.path' do
|
17
|
+
it 'should give the right path' do
|
18
|
+
expect(subject.path).to eq('/Optimize/OptimizeByProfile')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|