acrobat 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6073a8a04f7af59dd0b8825ff3286975f0197d7d
4
- data.tar.gz: 6004fca142d6c6856acf3bb83a2c918600ce3458
2
+ SHA256:
3
+ metadata.gz: 0c99bfc29e7fb060276f39533f1f762f937eca16d6961d0d889243f5f4882878
4
+ data.tar.gz: ceb386e7cdc9abba3085c515f2e11cbed715aeff2d48e175b3d61818a5c767cd
5
5
  SHA512:
6
- metadata.gz: 8af177966f67905aba759fbced241768d2da6b5aa6128f531c505c6217d8b63d3893ec3092d88162c2d5d35ece6502f33d4db39d97640f6e3af3e3b4371a6ed8
7
- data.tar.gz: 3e32a912018fcde36ee7ec584484e1f249313f356d29fa6535ee501052f8475d6248a03ffbe2334ce31a06166eefe3e3e75cdd39273deac5f7222cd5514ddc6c
6
+ metadata.gz: 51a1bb2f8f589f2226b160cda8e9be8b08585e95d96f221216a047bcc2a1d18c93e28b897aec2f7937b0f17a95f050ce29052c17cb43f0b123edd15d2ea3fb93
7
+ data.tar.gz: 2b6e94fce7255c41afb8b75a51364a9c8e51b4cdbda37a49e071675ff4fbee8882ea0dab4363f27322c05fa2df05cb60162ce622179b43a3d44b2f236d9dfc8e
Binary file
data.tar.gz.sig CHANGED
@@ -1 +1 @@
1
- ��S����y�/��B���wq���Q��1]��XVY�L�VG88���9�hi߇ ���R_L,��q�V�>™��?.Eb�
1
+ X"����Ƙ�tŊ�����^���w���Q��­<ͥ��sBO��n���������0k��=bQ��e4���(�#LS�{o������Ti(�e'N��/�����G��S*Z���%���T�@��4��JK�¿�֕S��L* 5xuTH�bX��W ���n��_
@@ -71,7 +71,7 @@ Using `bundle update` is *not* recommended as it will also update other gems, wh
71
71
  == Usage
72
72
 
73
73
  [source,ruby]
74
- ====
74
+ ----
75
75
 
76
76
  require 'acrobat'
77
77
  Adobe::Acrobat.run do |app|
@@ -87,7 +87,7 @@ Using `bundle update` is *not* recommended as it will also update other gems, wh
87
87
 
88
88
 
89
89
 
90
- ====
90
+ ----
91
91
 
92
92
  == Getting Help
93
93
 
data/Rakefile CHANGED
@@ -29,15 +29,16 @@ Hoe.plugin :minitest
29
29
  Hoe.plugin :yard
30
30
 
31
31
  Hoe.spec "acrobat" do |s|
32
- dependency("hoe-bundler", "> 0.0",:development)
33
- dependency("hoe-yard", "> 0.0",:development)
32
+ dependency("hoe-bundler", "~> 1.4",:development)
33
+ dependency("hoe-yard", "> 0.1",:development)
34
34
  dependency("pry", "> 0.0", :development)
35
35
  dependency("pry-byebug", "> 0.0", :development)
36
36
  dependency("yard", "> 0.0", :development)
37
37
  dependency("guard", "> 0.0", :development)
38
- dependency("wdm", "> 0.1.0", :development) if Gem.win_platform?
38
+ dependency("wdm", "> 0.1", :development) if Gem.win_platform?
39
39
  dependency("guard-minitest", "> 0.0", :development)
40
- dependency("asciidoctor", ">0.0",:development)
40
+ dependency("asciidoctor", "> 0.0",:development)
41
+ # dependency("minitest-utils", "> 0.0", :development)
41
42
  developer("Dominic Sisneros","dsisnero@gmail.com")
42
43
  clean_globs << "tmp"
43
44
  license "MIT" # this should match the license in the README
@@ -3,7 +3,7 @@ require 'acrobat/app'
3
3
 
4
4
 
5
5
  module Acrobat
6
- VERSION = "0.0.7"
6
+ VERSION = "0.0.8"
7
7
  end
8
8
 
9
9
 
@@ -25,9 +25,14 @@ module Acrobat
25
25
 
26
26
  class App
27
27
 
28
+ # [WIN32_OLE] ole_obj
29
+ attr_reader :ole_obj
28
30
 
29
- attr_reader :ole_obj, :pdoc
31
+ # the wrapped [PDoc] PDoc object
32
+ attr_reader :pdoc
30
33
 
34
+ # Initialize the
35
+ # @return [App] return an instance of App
31
36
  def initialize()
32
37
  @ole_obj = WIN32OLE.new('AcroExch.App')
33
38
  load_constants(@ole_obj)
@@ -39,11 +44,12 @@ module Acrobat
39
44
  # Runs the adobe app and quits at the end
40
45
  # @yield app [App]
41
46
  #
42
- # Acrobat::App.run do |app|
43
- # doc = app.open('doc.pdf')
44
- # doc.fill_form( city: 'City', state: 'ST')
45
- # doc.save_as('filled.pdf')
46
- # end
47
+ # @example
48
+ # Acrobat::App.run do |app|
49
+ # doc = app.open('doc.pdf')
50
+ # doc.fill_form( city: 'City', state: 'ST')
51
+ # doc.save_as('filled.pdf')
52
+ # end
47
53
  #
48
54
  # @return nil
49
55
  def self.run
@@ -58,6 +64,32 @@ module Acrobat
58
64
  end
59
65
  end
60
66
 
67
+ def self.replace_pages(src, replacement, output_name: , **opts)
68
+ self.run do |app|
69
+ app.open(src) do |doc|
70
+ doc.replace_pages(replacement, opts)
71
+ doc.save_as(output_name)
72
+ end
73
+ end
74
+ end
75
+
76
+ # Fills the form with updates in a hash
77
+ # @example
78
+ # Acrobat::App.fill_form(myform.pdf, output_name: 'filled.pdf
79
+ # , update_hash: { name: 'dom', filled_date: 1/20/2013
80
+ # @param doc [String] the String path of a fillable pdf file
81
+ # @param output_name [String] the name of the saved filled pdf file
82
+ # @param update_hash [Hash] the hash with updates
83
+ def self.fill_form(form,output_name: , update_hash: )
84
+ self.run do |app|
85
+ doc = app.open(form)
86
+ doc.fill_form(update_hash)
87
+ doc.save_as(output_name)
88
+ end
89
+ end
90
+
91
+
92
+
61
93
  # show the Adobe Acrobat application
62
94
  def show
63
95
  ole_obj.Show
@@ -86,6 +118,8 @@ module Acrobat
86
118
  doc
87
119
  end
88
120
 
121
+
122
+
89
123
  # merges the pdfs in directory
90
124
  # @param dir [String] the path of the directory
91
125
  # @param name [String,Nil] the name of the returned pdf file
@@ -145,7 +179,7 @@ module Acrobat
145
179
  private
146
180
 
147
181
  def load_constants(ole_obj)
148
- WIN32OLE.const_load(ole_obj, ACRO) unless ACRO.constants.size > 0
182
+ WIN32OLE.const_load(ole_obj, ACRO) unless ACRO.constants.size > 0
149
183
  end
150
184
 
151
185
  end
@@ -20,22 +20,38 @@ module Acrobat
20
20
  ole_obj.GetNumPages()
21
21
  end
22
22
 
23
+ def last_page
24
+ page_count -1
25
+ end
26
+
23
27
  # merges the doc to the
24
28
  # @overload merge(doc)
25
29
  # @param doc [String] the String path of a pdf file
26
30
  # @overload merge(doc)
27
31
  # @param doc [PDoc] an open PDoc to merge
28
32
  # @return [Boolean] whether the doc was merged correctly
29
- def merge(doc)
30
- case doc
31
- when PDoc
32
- merge_pdoc(doc)
33
- when String, Pathname
34
- docpath = Pathname(doc)
35
- raise 'File not found' unless docpath.file?
36
- doc2 = app.open(docpath)
37
- merge_pdoc(doc2)
38
- end
33
+ def merge(doc, options = {})
34
+ src = open_pdoc(doc)
35
+ merge_pdoc(src,options)
36
+ end
37
+
38
+ # opens and/or returns PDoc
39
+ # @overload open(doc)
40
+ # @param doc [String] the String path of a pdf file
41
+ # @overload open(PDoc] and open PDoc file
42
+ # @param doc [PDoc] an already open PDoc file
43
+ # @return doc [PDOC] the opened PDoc
44
+ def open_pdoc(doc)
45
+ src = case doc
46
+ when PDoc
47
+ doc
48
+ when String, Pathname
49
+ docpath = Pathname(doc)
50
+ raise 'File not found' unless docpath.file?
51
+ doc2 = app.open(docpath)
52
+ doc2
53
+ end
54
+ src
39
55
  end
40
56
 
41
57
  def fill_and_save(results,name: nil, dir: nil)
@@ -45,11 +61,15 @@ module Acrobat
45
61
  true
46
62
  end
47
63
 
48
- def default_dir(d)
64
+
65
+ # returns [Pathname] of d
66
+ # @param dir [String, Nil] the String path
67
+ # @return dir [Pathname] Pathname of dir or of working directory
68
+ def default_dir(dir)
49
69
  Pathname(dir || Pathname.getw)
50
70
  end
51
71
 
52
- def save_as(name:nil, dir:nil)
72
+ def save_as(name,dir:nil)
53
73
  name = path.basename unless name
54
74
  dir = Pathname(dir || Pathname.getwd)
55
75
  dir.mkpath
@@ -65,11 +85,19 @@ module Acrobat
65
85
  ole_obj.Close rescue nil
66
86
  end
67
87
 
88
+ def replace_pages(doc, start: 0, replace_start: 0, num_of_pages: 1,merge_annotations: true)
89
+ src = open_pdoc(doc)
90
+
91
+ ole_obj.ReplacePages(start,src.ole_obj,replace_start,num_of_pages,merge_annotations)
92
+ end
68
93
 
94
+ # return the instance of JSO object
95
+ # @return [Jso] a WIN32OLE wrapped Jso object 'javascript object'
69
96
  def jso
70
97
  @jso ||= Jso.new(self,ole_obj.GetJSObject)
71
98
  end
72
99
 
100
+ # return the field_names of the pdf form
73
101
  def field_names
74
102
  jso.field_names
75
103
  end
@@ -79,10 +107,17 @@ module Acrobat
79
107
  end
80
108
 
81
109
  protected
82
- def merge_pdoc(doc)
110
+ def merge_pdoc(doc,options = {})
83
111
  begin
84
- merged = ole_obj.InsertPages(page_count - 1, doc.ole_obj, 0, doc.page_count, true)
85
- return merged
112
+ unless options
113
+ merged = ole_obj.InsertPages(page_count - 1, doc.ole_obj, 0, doc.page_count, true)
114
+ return merged
115
+ else
116
+ start = options[:start]
117
+ start_page
118
+ pages = options[:pages]
119
+ ole_obj.InsertPages(start, doc.ole_obj, 0, doc.page_count, true)
120
+ end
86
121
  rescue
87
122
  return false
88
123
  end
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require_relative 'test_helper'
2
2
 
3
3
 
4
4
  require "acrobat"
@@ -12,9 +12,12 @@ module Acrobat
12
12
 
13
13
  describe 'new' do
14
14
 
15
+ it 'works' do
16
+ assert true
17
+ end
15
18
 
16
- it 'can be created' do
17
19
 
20
+ it 'can be created' do
18
21
  app = App.new
19
22
  app.must_be_instance_of App
20
23
  end
@@ -7,3 +7,7 @@ else
7
7
  end
8
8
 
9
9
 
10
+ require 'minitest/spec'
11
+ require 'minitest/autorun'
12
+ #require 'minitest/focus'
13
+ #require 'minitest/utils'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acrobat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominic Sisneros
@@ -10,27 +10,31 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |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YDVR0OBBYEFP/qHc8Ca+WsXZKhFxmn+ucN9sRgMB0GA1Ud
26
+ EQQWMBSBEmRzaXNuZXJvQGdtYWlsLmNvbTAdBgNVHRIEFjAUgRJkc2lzbmVyb0Bn
27
+ bWFpbC5jb20wDQYJKoZIhvcNAQELBQADggGBABZGwLTkRYYdfrlXSoxITxVb13id
28
+ fE4libPxIwMaJ+T78pwfFnPMFNmPFwSDZInzfZExsNxlxrkBFKXDZSHD4TFSUS5O
29
+ nmenPGns6K7kjwMVq9hLm4kMEZnKX5vq6YO/YbJbVJMn+sCiDb9nphL+HlkZ1YDe
30
+ Q6vlynaKWlzN2Dv2NIYxcGLYff+kTQZNsuCL5GF8O3C+WQpIe5Dy2foA7b6RTbNI
31
+ 1ZHlj2wGWQ2ooLnkwKMJsOHTe5U12Aub/1dFFk+NsK8cXiP//5eipvtI6z/QY34C
32
+ I0E/5rKu54YgiKt1Waa6+JmM1k+kpakAYi2JwpyF8GyxM1UHuzcg/b0molfdS9gD
33
+ B2MEh8WYqwy827jl4vUZYuoquOG1Z83fN6ehSVro4yqbTkmPtOFTeFt/mUGMKC90
34
+ GkZB86BODcU2ZIxvw1AkKmr0YgWPfYunalhX5FirP9guVLlaoeJwn1wMf8ghBOrp
35
+ tvCvgfI163rqmb9syMyTmNffdkGy6U2IIja7hw==
32
36
  -----END CERTIFICATE-----
33
- date: 2017-01-31 00:00:00.000000000 Z
37
+ date: 2018-04-23 00:00:00.000000000 Z
34
38
  dependencies:
35
39
  - !ruby/object:Gem::Dependency
36
40
  name: minitest
@@ -38,42 +42,42 @@ dependencies:
38
42
  requirements:
39
43
  - - "~>"
40
44
  - !ruby/object:Gem::Version
41
- version: '5.10'
45
+ version: '5.11'
42
46
  type: :development
43
47
  prerelease: false
44
48
  version_requirements: !ruby/object:Gem::Requirement
45
49
  requirements:
46
50
  - - "~>"
47
51
  - !ruby/object:Gem::Version
48
- version: '5.10'
52
+ version: '5.11'
49
53
  - !ruby/object:Gem::Dependency
50
54
  name: hoe-yard
51
55
  requirement: !ruby/object:Gem::Requirement
52
56
  requirements:
53
57
  - - ">="
54
58
  - !ruby/object:Gem::Version
55
- version: 0.1.2
59
+ version: 0.1.3
56
60
  type: :development
57
61
  prerelease: false
58
62
  version_requirements: !ruby/object:Gem::Requirement
59
63
  requirements:
60
64
  - - ">="
61
65
  - !ruby/object:Gem::Version
62
- version: 0.1.2
66
+ version: 0.1.3
63
67
  - !ruby/object:Gem::Dependency
64
68
  name: hoe-bundler
65
69
  requirement: !ruby/object:Gem::Requirement
66
70
  requirements:
67
- - - ">"
71
+ - - "~>"
68
72
  - !ruby/object:Gem::Version
69
- version: '0.0'
73
+ version: '1.4'
70
74
  type: :development
71
75
  prerelease: false
72
76
  version_requirements: !ruby/object:Gem::Requirement
73
77
  requirements:
74
- - - ">"
78
+ - - "~>"
75
79
  - !ruby/object:Gem::Version
76
- version: '0.0'
80
+ version: '1.4'
77
81
  - !ruby/object:Gem::Dependency
78
82
  name: pry
79
83
  requirement: !ruby/object:Gem::Requirement
@@ -136,14 +140,14 @@ dependencies:
136
140
  requirements:
137
141
  - - ">"
138
142
  - !ruby/object:Gem::Version
139
- version: 0.1.0
143
+ version: '0.1'
140
144
  type: :development
141
145
  prerelease: false
142
146
  version_requirements: !ruby/object:Gem::Requirement
143
147
  requirements:
144
148
  - - ">"
145
149
  - !ruby/object:Gem::Version
146
- version: 0.1.0
150
+ version: '0.1'
147
151
  - !ruby/object:Gem::Dependency
148
152
  name: guard-minitest
149
153
  requirement: !ruby/object:Gem::Requirement
@@ -178,14 +182,14 @@ dependencies:
178
182
  requirements:
179
183
  - - "~>"
180
184
  - !ruby/object:Gem::Version
181
- version: '3.16'
185
+ version: '3.17'
182
186
  type: :development
183
187
  prerelease: false
184
188
  version_requirements: !ruby/object:Gem::Requirement
185
189
  requirements:
186
190
  - - "~>"
187
191
  - !ruby/object:Gem::Version
188
- version: '3.16'
192
+ version: '3.17'
189
193
  description: |-
190
194
  <div class="paragraph">
191
195
  <p>The acrobat gem is a library that uses WIN32OLE to automate pdf functions. Adobe Reader or Adobe Acrobat must be installed and then you can fill forms and merge documents</p>
@@ -237,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
241
  version: '0'
238
242
  requirements: []
239
243
  rubyforge_project:
240
- rubygems_version: 2.6.10
244
+ rubygems_version: 2.7.6
241
245
  signing_key:
242
246
  specification_version: 4
243
247
  summary: <div class="paragraph"> <p>The acrobat gem is a library that uses WIN32OLE
metadata.gz.sig CHANGED
Binary file