pdf4me 2.0.3 → 2.0.4

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.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +0 -0
  3. data/README.md +246 -15
  4. data/lib/pdf4me.rb +30 -0
  5. data/lib/pdf4me/actions/complex_action.rb +5 -0
  6. data/lib/pdf4me/actions/convert_file_to_pdf.rb +3 -1
  7. data/lib/pdf4me/actions/convert_to_pdf.rb +1 -5
  8. data/lib/pdf4me/actions/create_images.rb +10 -0
  9. data/lib/pdf4me/actions/create_pdf_a.rb +0 -0
  10. data/lib/pdf4me/actions/create_thumbnail.rb +3 -1
  11. data/lib/pdf4me/actions/extract.rb +10 -0
  12. data/lib/pdf4me/actions/extract_pages.rb +4 -2
  13. data/lib/pdf4me/actions/merge.rb +35 -0
  14. data/lib/pdf4me/actions/merge_two_pdfs.rb +5 -4
  15. data/lib/pdf4me/actions/optimize.rb +0 -0
  16. data/lib/pdf4me/actions/optimize_by_profile.rb +3 -1
  17. data/lib/pdf4me/actions/pdf_a.rb +10 -0
  18. data/lib/pdf4me/actions/split.rb +10 -0
  19. data/lib/pdf4me/actions/split_by_page_nr.rb +0 -0
  20. data/lib/pdf4me/actions/stamp.rb +10 -0
  21. data/lib/pdf4me/actions/text_stamp.rb +9 -2
  22. data/lib/pdf4me/actions/wrapper_action.rb +0 -0
  23. data/lib/pdf4me/client.rb +0 -0
  24. data/lib/pdf4me/configuration.rb +0 -0
  25. data/lib/pdf4me/exceptions.rb +0 -0
  26. data/lib/pdf4me/models/base.rb +5 -1
  27. data/lib/pdf4me/models/color.rb +10 -0
  28. data/lib/pdf4me/models/convert_to_pdf_action.rb +0 -0
  29. data/lib/pdf4me/models/convert_to_pdf_res.rb +2 -1
  30. data/lib/pdf4me/models/create_images_res.rb +9 -0
  31. data/lib/pdf4me/models/custom_cms_config.rb +23 -0
  32. data/lib/pdf4me/models/doc_log.rb +0 -0
  33. data/lib/pdf4me/models/doc_metadata.rb +0 -0
  34. data/lib/pdf4me/models/document.rb +0 -0
  35. data/lib/pdf4me/models/extract_action.rb +28 -0
  36. data/lib/pdf4me/models/extract_res.rb +9 -0
  37. data/lib/pdf4me/models/image.rb +11 -0
  38. data/lib/pdf4me/models/image_action.rb +110 -0
  39. data/lib/pdf4me/models/merge_action.rb +8 -0
  40. data/lib/pdf4me/models/merge_res.rb +8 -0
  41. data/lib/pdf4me/models/notification.rb +1 -1
  42. data/lib/pdf4me/models/optimize_action.rb +0 -0
  43. data/lib/pdf4me/models/optimize_res.rb +2 -1
  44. data/lib/pdf4me/models/page.rb +0 -0
  45. data/lib/pdf4me/models/page_selection.rb +21 -0
  46. data/lib/pdf4me/models/pdf_a_action.rb +33 -0
  47. data/lib/pdf4me/models/pdf_a_res.rb +8 -0
  48. data/lib/pdf4me/models/pdf_font.rb +9 -0
  49. data/lib/pdf4me/models/rgb_set.rb +10 -0
  50. data/lib/pdf4me/models/rotate.rb +12 -0
  51. data/lib/pdf4me/models/split_action.rb +11 -0
  52. data/lib/pdf4me/models/split_res.rb +8 -0
  53. data/lib/pdf4me/models/stamp_action.rb +60 -0
  54. data/lib/pdf4me/models/stamp_res.rb +8 -0
  55. data/lib/pdf4me/models/text.rb +37 -0
  56. data/lib/pdf4me/models/transform.rb +16 -0
  57. data/lib/pdf4me/models/translate.rb +12 -0
  58. data/lib/pdf4me/utils/assigner.rb +0 -0
  59. data/lib/pdf4me/utils/serializer.rb +2 -0
  60. data/lib/pdf4me/version.rb +1 -1
  61. data/spec/actions/complex_action_spec.rb +12 -0
  62. data/spec/actions/convert_file_to_pdf_spec.rb +21 -0
  63. data/spec/actions/convert_to_pdf_spec.rb +16 -0
  64. data/spec/actions/create_pdf_a_spec.rb +0 -0
  65. data/spec/actions/create_thumbnail_spec.rb +27 -0
  66. data/spec/actions/extract_pages_spec.rb +24 -0
  67. data/spec/actions/extract_spec.rb +16 -0
  68. data/spec/actions/merge_spec.rb +17 -0
  69. data/spec/actions/merge_two_pdfs_spec.rb +21 -0
  70. data/spec/actions/optimize_by_profile_spec.rb +22 -0
  71. data/spec/actions/optimize_spec.rb +16 -0
  72. data/spec/actions/pdf_a_spec.rb +16 -0
  73. data/spec/actions/split_by_page_nr_spec.rb +21 -0
  74. data/spec/actions/split_spec.rb +16 -0
  75. data/spec/actions/stamp_spec.rb +16 -0
  76. data/spec/actions/text_stamp_spec.rb +24 -0
  77. data/spec/actions/wrapper_action_spec.rb +0 -0
  78. data/spec/files/4.pdf +0 -0
  79. data/spec/models/base_spec.rb +9 -0
  80. data/spec/models/color_spec.rb +7 -0
  81. data/spec/models/convert_to_pdf_action_spec.rb +23 -0
  82. data/spec/models/convert_to_pdf_res_spec.rb +7 -0
  83. data/spec/models/create_images_res_spec.rb +7 -0
  84. data/spec/models/custom_cms_config_spec.rb +7 -0
  85. data/spec/models/doc_log_spec.rb +36 -0
  86. data/spec/models/doc_metadata_spec.rb +7 -0
  87. data/spec/models/document_spec.rb +12 -0
  88. data/spec/models/extract_action_spec.rb +7 -0
  89. data/spec/models/extract_res_spec.rb +7 -0
  90. data/spec/models/image_action_spec.rb +46 -0
  91. data/spec/models/merge_action_spec.rb +7 -0
  92. data/spec/models/merge_res_spec.rb +7 -0
  93. data/spec/models/notification_spec.rb +13 -0
  94. data/spec/models/optimize_action_spec.rb +44 -0
  95. data/spec/models/optimize_res_spec.rb +7 -0
  96. data/spec/models/page_selection_spec.rb +17 -0
  97. data/spec/models/page_spec.rb +7 -0
  98. data/spec/models/pdf_a_action_spec.rb +22 -0
  99. data/spec/models/pdf_a_res_spec.rb +7 -0
  100. data/spec/models/pdf_font_spec.rb +7 -0
  101. data/spec/models/rgb_set_spec.rb +7 -0
  102. data/spec/models/rotate_spec.rb +13 -0
  103. data/spec/models/split_action_spec.rb +7 -0
  104. data/spec/models/split_res_spec.rb +7 -0
  105. data/spec/models/stamp_action_spec.rb +27 -0
  106. data/spec/models/stamp_res_spec.rb +7 -0
  107. data/spec/models/text_spec.rb +22 -0
  108. data/spec/models/transform_spec.rb +16 -0
  109. data/spec/models/translate_spec.rb +12 -0
  110. data/spec/spec_helper.rb +0 -0
  111. 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,8 @@
1
+ module Pdf4me
2
+ class PdfARes < Base
3
+ ATTRIBUTES = {
4
+ document: 'Document'
5
+ }
6
+ attr_accessor *ATTRIBUTES.keys
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ module Pdf4me
2
+ class PdfFont < Base
3
+ ATTRIBUTES = {
4
+ name: 'String',
5
+ font_content: 'String'
6
+ }
7
+ attr_accessor *ATTRIBUTES.keys
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ module Pdf4me
2
+ class RGBSet < Base
3
+ ATTRIBUTES = {
4
+ red: 'Integer',
5
+ green: 'Integer',
6
+ blue: 'Integer'
7
+ }
8
+ attr_accessor *ATTRIBUTES.keys
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ module Pdf4me
2
+ class Rotate < Base
3
+ ATTRIBUTES = {
4
+ angle: 'Double',
5
+ origin_x: 'Integer',
6
+ origin_y: 'Integer'
7
+ }
8
+ attr_accessor *ATTRIBUTES.keys
9
+
10
+ validates_presence_of :angle, :origin_x, :origin_y
11
+ end
12
+ 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,8 @@
1
+ module Pdf4me
2
+ class SplitRes < Base
3
+ ATTRIBUTES = {
4
+ documents: 'Array<Document>'
5
+ }
6
+ attr_accessor *ATTRIBUTES.keys
7
+ end
8
+ 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,8 @@
1
+ module Pdf4me
2
+ class StampRes < Base
3
+ ATTRIBUTES = {
4
+ document: 'Document'
5
+ }
6
+ attr_accessor *ATTRIBUTES.keys
7
+ end
8
+ 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
@@ -0,0 +1,12 @@
1
+ module Pdf4me
2
+ class Translate < Base
3
+ ATTRIBUTES = {
4
+ offset_x: 'Integer',
5
+ offset_y: 'Integer'
6
+ }
7
+ attr_accessor *ATTRIBUTES.keys
8
+
9
+ validates_presence_of :offset_x, :offset_y
10
+
11
+ end
12
+ end
File without changes
@@ -35,6 +35,8 @@ module Pdf4me
35
35
  value.to_i
36
36
  when 'BOOLEAN'
37
37
  value == 'true'
38
+ when 'Float'
39
+ value.to_f
38
40
  else
39
41
  Pdf4me.const_get(type).from_hash(value)
40
42
  end
@@ -1,3 +1,3 @@
1
1
  module Pdf4me
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.4"
3
3
  end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pdf4me::ComplexAction, type: :action do
4
+
5
+ describe '.methods' do
6
+ describe '.client' do
7
+ it 'should return the right client' do
8
+ expect(subject.client).to be_kind_of(Pdf4me::Client)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -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