acrobat 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop/minitest.yml +2 -0
- data/.rubocop/strict.yml +4 -0
- data/.rubocop.yml +23 -0
- data/LICENSE.txt +1 -1
- data/exe/acrobat +3 -0
- data/gemfiles/rubocop.gemfile +6 -0
- data/lib/acrobat/app.rb +60 -35
- data/lib/acrobat/avdoc.rb +22 -0
- data/lib/acrobat/pdoc.rb +58 -37
- data/lib/acrobat/version.rb +1 -1
- data/lib/acrobat.rb +9 -45
- data/rbs_collection.yaml +19 -0
- data/sig/generated/acrobat/app.rbs +94 -0
- data/sig/generated/acrobat/avdoc.rbs +15 -0
- data/sig/generated/acrobat/jso.rbs +37 -0
- data/sig/generated/acrobat/pdoc.rbs +63 -0
- data/sig/generated/acrobat/version.rbs +5 -0
- data/sig/generated/acrobat.rbs +6 -0
- data/sig/prototype/lib/acrobat/app.rbs +3 -0
- data/sig/prototype/lib/acrobat/jso.rbs +5 -0
- data/sig/prototype/lib/acrobat/pdoc.rbs +5 -0
- metadata +36 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaad7882d94357e1ef66a4c97145b069b0d807706439e46a34caf9beb5c9233d
|
4
|
+
data.tar.gz: 0c307460f2af09f599949579d9ede54124f1a0dab4435cbbe8f6dc61a8e0633c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fcc79f0eaa847050e9a82c68ed6617db4d2aff3b981262db1b924c3e12846b640d4cd58c48bc40c27237af5f64e84f9e2313962063e5756dcd152c372e7ee17
|
7
|
+
data.tar.gz: 76b5a080702086907a970d73ce6d6d400e43e22bda378498fb1880225045508bfc07f5669bbc37fa895cab2a8b733677968e63ba8e17c69f31923e92f30c4d2d
|
data/.rubocop/strict.yml
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
inherit_mode:
|
2
|
+
merge:
|
3
|
+
- Exclude
|
4
|
+
|
5
|
+
require:
|
6
|
+
- standard
|
7
|
+
- standard-custom
|
8
|
+
- standard-performance
|
9
|
+
- rubocop-performance
|
10
|
+
|
11
|
+
inherit_gem:
|
12
|
+
standard: config/base.yml
|
13
|
+
standard-performance: config/base.yml
|
14
|
+
standard-custom: config/base.yml
|
15
|
+
|
16
|
+
inherit_from:
|
17
|
+
- .rubocop/minitest.yml
|
18
|
+
- .rubocop/strict.yml
|
19
|
+
|
20
|
+
AllCops:
|
21
|
+
NewCops: disable
|
22
|
+
SuggestExtensions: false
|
23
|
+
TargetRubyVersion: 3.4
|
data/LICENSE.txt
CHANGED
data/exe/acrobat
ADDED
data/lib/acrobat/app.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
# rbs_inline: enable
|
2
|
+
|
1
3
|
require "win32ole"
|
2
4
|
require_relative "pdoc"
|
5
|
+
require_relative "avdoc"
|
3
6
|
require_relative "jso"
|
4
7
|
|
5
8
|
module Acrobat
|
@@ -27,22 +30,28 @@ module ACRO; end
|
|
27
30
|
module Acrobat
|
28
31
|
class App
|
29
32
|
# [WIN32_OLE] ole_obj
|
30
|
-
attr_reader :ole_obj
|
31
|
-
|
32
|
-
# the wrapped [PDoc] PDoc object
|
33
|
-
attr_reader :pdoc
|
33
|
+
attr_reader :ole_obj # :WIN32OLE
|
34
34
|
|
35
|
-
#
|
36
|
-
# @return [App] return an instance of App
|
37
|
-
def initialize
|
35
|
+
def initialize # : Void
|
38
36
|
@ole_obj = WIN32OLE.new("AcroExch.App")
|
37
|
+
unless @ole_obj
|
38
|
+
@ole_obj = WIN32OLE.connect("AcroExch.App")
|
39
|
+
end
|
39
40
|
load_constants(@ole_obj)
|
40
41
|
@docs = []
|
41
42
|
end
|
42
43
|
|
44
|
+
def self.close(path)
|
45
|
+
name = File.basename(path)
|
46
|
+
run do |app|
|
47
|
+
av = app.avdocs.find{|a| a.pdoc_name == name}
|
48
|
+
av&.close
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
|
43
54
|
# Runs the adobe app and quits at the end
|
44
|
-
# @yield app [App]
|
45
|
-
#
|
46
55
|
# @example
|
47
56
|
# Acrobat::App.run do |app|
|
48
57
|
# doc = app.open('doc.pdf')
|
@@ -50,19 +59,18 @@ module Acrobat
|
|
50
59
|
# doc.save_as('filled.pdf')
|
51
60
|
# end
|
52
61
|
#
|
53
|
-
# @return
|
62
|
+
# @rbs return Void
|
54
63
|
def self.run
|
55
64
|
the_app = new
|
56
65
|
yield the_app
|
57
66
|
ensure
|
58
67
|
the_app&.quit
|
59
68
|
GC.start
|
60
|
-
nil
|
61
69
|
end
|
62
70
|
|
63
|
-
def self.replace_pages(
|
71
|
+
def self.replace_pages(pdf_file, replacement, output_name:, **opts)
|
64
72
|
run do |app|
|
65
|
-
app.open(
|
73
|
+
app.open(pdf_file) do |doc|
|
66
74
|
doc.replace_pages(replacement, **opts)
|
67
75
|
doc.save_as(output_name)
|
68
76
|
end
|
@@ -73,30 +81,51 @@ module Acrobat
|
|
73
81
|
# @example
|
74
82
|
# Acrobat::App.fill_form(myform.pdf, output_name: 'filled.pdf
|
75
83
|
# , update_hash: { name: 'dom', filled_date: 1/20/2013
|
76
|
-
# @
|
77
|
-
# @
|
78
|
-
# @
|
79
|
-
def self.fill_form(
|
84
|
+
# @rbs pdf_form: String -- the String path of a fillable pdf file
|
85
|
+
# @rbs output_name: String -- the name of the saved filled pdf file
|
86
|
+
# @rbs update_hash: Hash -- the hash with updates
|
87
|
+
def self.fill_form(pdf_form, output_name:, update_hash:)
|
80
88
|
run do |app|
|
81
|
-
doc = app.open(
|
89
|
+
doc = app.open(pdf_form)
|
82
90
|
doc.fill_form(update_hash)
|
83
91
|
doc.save_as(output_name)
|
84
92
|
end
|
85
93
|
end
|
86
94
|
|
95
|
+
# @rbs return Array[AvDoc]
|
96
|
+
# @rbs &: (AvDoc) -> Void
|
97
|
+
def avdocs
|
98
|
+
count = ole_obj.GetNumAVDocs
|
99
|
+
return [] if count == 0
|
100
|
+
return to_enum(:avdocs) unless block_given?
|
101
|
+
av_array = []
|
102
|
+
count.times do |i|
|
103
|
+
ole = ole_obj.GetAVDoc(i)
|
104
|
+
raise "Wrong index for GetNumAVDocs #{i -1}" unless ole
|
105
|
+
av = AvDoc.new(ole)
|
106
|
+
if block_given?
|
107
|
+
yield av
|
108
|
+
else
|
109
|
+
av_array << av
|
110
|
+
end
|
111
|
+
end
|
112
|
+
av_array unless block_given?
|
113
|
+
end
|
114
|
+
|
115
|
+
|
87
116
|
# show the Adobe Acrobat application
|
88
|
-
def show
|
117
|
+
def show # : Void
|
89
118
|
ole_obj.Show
|
90
119
|
end
|
91
120
|
|
92
121
|
# hide the Adobe Acrobat application
|
93
|
-
def hide
|
122
|
+
def hide # : Void
|
94
123
|
ole_obj.Hide
|
95
124
|
end
|
96
125
|
|
97
126
|
# Finds the pdfs in a dir
|
98
|
-
# @
|
99
|
-
# @return [
|
127
|
+
# @rbs dir: String -- the directory to find pdfs in
|
128
|
+
# @rbs return Array[Pathname] -- of pdf files
|
100
129
|
def find_pdfs_in_dir(dir)
|
101
130
|
Pathname.glob(dir + "/*.pdf")
|
102
131
|
end
|
@@ -113,10 +142,10 @@ module Acrobat
|
|
113
142
|
end
|
114
143
|
|
115
144
|
# merges the pdfs in directory
|
116
|
-
# @
|
117
|
-
# @
|
145
|
+
# @rbs dir: String -- the path of the directory
|
146
|
+
# @rbs name: String | Nil -- the name of the returned pdf file
|
118
147
|
# if the name is nil, the name is "merged.pdf"
|
119
|
-
# @
|
148
|
+
# @rbs output_dir: String | Nil -- the name of the output dir
|
120
149
|
# if the output_dir is nil, the output dir is the dir param
|
121
150
|
# return [Boolean] if the merge was successful or not
|
122
151
|
def merge_pdfs_in_dir(dir, name: nil, output_dir: nil)
|
@@ -127,7 +156,7 @@ module Acrobat
|
|
127
156
|
|
128
157
|
# quit the Adobe App.
|
129
158
|
# closes the open adobe documents and quits the program
|
130
|
-
# @return nil
|
159
|
+
# @rbs return nil
|
131
160
|
def quit
|
132
161
|
begin
|
133
162
|
docs.each { |d| d.close }
|
@@ -141,21 +170,17 @@ module Acrobat
|
|
141
170
|
attr_reader :docs
|
142
171
|
|
143
172
|
# open the file.
|
144
|
-
# @
|
145
|
-
# @
|
173
|
+
# @rbs file: String | Pathname -- #to_path
|
174
|
+
# @rbs &: (PDoc) -> Nil
|
175
|
+
# @rbs return PDoc -- the open file as a Pdoc instance
|
146
176
|
def open(file)
|
147
|
-
|
148
|
-
|
149
|
-
pdoc = WIN32OLE.new("AcroExch.PDDoc")
|
150
|
-
is_opened = pdoc.open FileSystemObject.windows_path(filepath)
|
151
|
-
doc = PDoc.new(self, pdoc, filepath) if is_opened
|
152
|
-
docs << doc if is_opened
|
177
|
+
doc = PDoc.from_path(file)
|
178
|
+
docs << doc
|
153
179
|
return doc unless block_given?
|
154
180
|
begin
|
155
181
|
yield doc
|
156
182
|
ensure
|
157
183
|
doc.close
|
158
|
-
nil
|
159
184
|
end
|
160
185
|
end
|
161
186
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Acrobat
|
2
|
+
class AvDoc
|
3
|
+
attr_reader :ole_obj #: WIN32OLE
|
4
|
+
|
5
|
+
attr_reader :pdoc_name #: String
|
6
|
+
|
7
|
+
def initialize( ole)
|
8
|
+
@ole_obj = ole
|
9
|
+
@pdoc_name = ole.GetPDDoc.GetFileName
|
10
|
+
end
|
11
|
+
|
12
|
+
# Close the AvDoc
|
13
|
+
# @rbs save: Boolean -- if true asks to save if false closes without saving
|
14
|
+
def close(save = false)
|
15
|
+
ole_save = save ? 0 : 1
|
16
|
+
@ole_obj.Close(ole_save)
|
17
|
+
@ole_obj = nil
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/lib/acrobat/pdoc.rb
CHANGED
@@ -1,9 +1,19 @@
|
|
1
1
|
module Acrobat
|
2
2
|
class PDoc
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :ole_obj
|
4
|
+
|
5
|
+
attr_reader :path #: Path | Nil
|
4
6
|
|
5
|
-
def
|
6
|
-
|
7
|
+
def self.from_path(path)
|
8
|
+
filepath = Pathname(path).expand_path
|
9
|
+
raise FileNotFound.new(filepath) unless filepath.file?
|
10
|
+
pdoc = WIN32OLE.new("AcroExch.PDDoc")
|
11
|
+
result = pdoc.open FileSystemObject.windows_path(filepath)
|
12
|
+
raise "Error opening Acrobat::Pdoc from #{filepath}" if result == 0
|
13
|
+
new(pdoc, path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(ole, path = nil)
|
7
17
|
@ole_obj = ole
|
8
18
|
@path = path
|
9
19
|
end
|
@@ -13,41 +23,32 @@ module Acrobat
|
|
13
23
|
ole_obj.OpenAVDoc(name)
|
14
24
|
end
|
15
25
|
|
16
|
-
# @return
|
26
|
+
# @rbs return Fixnum -- the number of pages in the pdf
|
17
27
|
def page_count
|
18
28
|
ole_obj.GetNumPages()
|
19
29
|
end
|
20
30
|
|
21
|
-
def last_page
|
22
|
-
page_count
|
31
|
+
def last_page # : Fixnum
|
32
|
+
page_count - 1
|
23
33
|
end
|
24
34
|
|
25
35
|
# merges the doc to the
|
26
|
-
#
|
27
|
-
#
|
28
|
-
# @overload merge(doc)
|
29
|
-
# @param doc [PDoc] an open PDoc to merge
|
30
|
-
# @return [Boolean] whether the doc was merged correctly
|
36
|
+
# @rbs doc: PDoc|String|Pathname -- an open PDoc to merge or filename
|
37
|
+
# @rbs return Boolean -- whether the doc was merged correctly
|
31
38
|
def merge(doc)
|
32
|
-
src =
|
33
|
-
|
39
|
+
src = open_ole_pdoc(doc)
|
40
|
+
ole_insert_pages(src, self_start_page: last_page, merge_doc_page_start: 0,
|
41
|
+
number_pages: src.page_count, bookmarks: true)
|
34
42
|
end
|
35
43
|
|
36
44
|
# opens and/or returns PDoc
|
37
|
-
#
|
38
|
-
|
39
|
-
# @overload open(PDoc] and open PDoc file
|
40
|
-
# @param doc [PDoc] an already open PDoc file
|
41
|
-
# @return doc [PDOC] the opened PDoc
|
42
|
-
def open_pdoc(doc)
|
45
|
+
# @rbs doc: String|Pathname|Pdoc -- the String path of a pdf file
|
46
|
+
def open_ole_pdoc(doc) # : Pdoc
|
43
47
|
case doc
|
44
48
|
when PDoc
|
45
49
|
doc
|
46
50
|
when String, Pathname
|
47
|
-
|
48
|
-
raise "File not found" unless docpath.file?
|
49
|
-
app.open(docpath)
|
50
|
-
|
51
|
+
self.class.from_path(doc)
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
@@ -58,20 +59,13 @@ module Acrobat
|
|
58
59
|
true
|
59
60
|
end
|
60
61
|
|
61
|
-
def insert_pages(src:, insert_after: nil, src_page_start: nil, src_page_end: nil)
|
62
|
-
insert_hash = {"nPage" => insert_after - 1}
|
63
|
-
insert_hash["nStart"] = src_page_start + 1 if src_page_start
|
64
|
-
insert_hash["nEnd"] = src_page_end + 1 if src_page_end
|
65
|
-
ole_obj.InsertPages(**insert_hash)
|
66
|
-
end
|
67
|
-
|
68
62
|
def prepend_pages(src_path:, src_page_start: 1, src_page_end: nil)
|
69
63
|
insert_pages(insert_after: 0, src_path: src_path, src_page_start: src_page_start, src_page_end: src_page_end)
|
70
64
|
end
|
71
65
|
|
72
66
|
# returns [Pathname] of d
|
73
|
-
# @
|
74
|
-
# @return dir [Pathname] Pathname of dir or of working directory
|
67
|
+
# @rbs dir: [String, Nil] the String path
|
68
|
+
# @rbs return dir [Pathname] Pathname of dir or of working directory
|
75
69
|
def default_dir(dir)
|
76
70
|
Pathname(dir || Pathname.getw)
|
77
71
|
end
|
@@ -88,20 +82,21 @@ module Acrobat
|
|
88
82
|
ole_obj.GetFileName
|
89
83
|
end
|
90
84
|
|
91
|
-
def close
|
92
|
-
ole_obj.Close
|
85
|
+
def close # : Bool -- true if closes successfully
|
86
|
+
result = ole_obj.Close
|
87
|
+
result == -1
|
93
88
|
rescue
|
94
|
-
|
89
|
+
false
|
95
90
|
end
|
96
91
|
|
97
92
|
def replace_pages(doc, start: 0, replace_start: 0, num_of_pages: 1, merge_annotations: true)
|
98
|
-
src =
|
93
|
+
src = open_ole_pdoc(doc)
|
99
94
|
|
100
95
|
ole_obj.ReplacePages(start, src.ole_obj, replace_start, num_of_pages, merge_annotations)
|
101
96
|
end
|
102
97
|
|
103
98
|
# return the instance of JSO object
|
104
|
-
# @return [Jso] a WIN32OLE wrapped Jso object 'javascript object'
|
99
|
+
# @rbs return [Jso] a WIN32OLE wrapped Jso object 'javascript object'
|
105
100
|
def jso
|
106
101
|
@jso ||= Jso.new(self, ole_obj.GetJSObject)
|
107
102
|
end
|
@@ -117,6 +112,32 @@ module Acrobat
|
|
117
112
|
|
118
113
|
protected
|
119
114
|
|
115
|
+
def ole_insert_pages(merge_doc, self_start_page: 0, merge_doc_page_start: 0,
|
116
|
+
number_pages: nil, bookmarks: true)
|
117
|
+
bookmarks_ole = bookmarks ? 1 : 0
|
118
|
+
result = ole_obj.InsertPages(self_start_page, merge_doc.ole_obj, merge_doc_page_start, number_pages, bookmarks_ole)
|
119
|
+
if result == 0
|
120
|
+
raise "ole.InsertPages unable to insert merge doc #{merge_doc.name} into #{name}"
|
121
|
+
end
|
122
|
+
true
|
123
|
+
end
|
124
|
+
|
125
|
+
def ole_replace_pages(merge_doc, self_start_page: nil, merge_doc_page_start: nil,
|
126
|
+
number_pages: nil, bookmarks: true)
|
127
|
+
self_start_page_ole = self_start_page ? self_start_page - 1 : page_count - 1
|
128
|
+
page_start_ole = merge_doc_page_start ? merge_doc_page_start - 1 : merge_doc.GetNumPages - 1
|
129
|
+
number_pages_ole = number_pages || merge_doc
|
130
|
+
bookmarks_ole = bookmarks ? 1 : 0
|
131
|
+
result = ole_obj.ReplacePages(self_start_page_ole, merge_doc.ole, page_start_ole, number_pages_ole, bookmarks_ole)
|
132
|
+
end
|
133
|
+
|
134
|
+
def insert_pages(src:, insert_after: nil, src_page_start: nil, src_page_end: nil)
|
135
|
+
insert_hash = {"nPage" => insert_after - 1}
|
136
|
+
insert_hash["nStart"] = src_page_start + 1 if src_page_start
|
137
|
+
insert_hash["nEnd"] = src_page_end + 1 if src_page_end
|
138
|
+
ole_obj.InsertPages(**insert_hash)
|
139
|
+
end
|
140
|
+
|
120
141
|
def merge_pdoc(doc, **options)
|
121
142
|
if options
|
122
143
|
start = options[:start]
|
data/lib/acrobat/version.rb
CHANGED
data/lib/acrobat.rb
CHANGED
@@ -1,45 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
if $0 == __FILE__
|
11
|
-
require "pry"
|
12
|
-
|
13
|
-
Acrobat::App.run do |app|
|
14
|
-
data = Pathname(__dir__).parent + "data"
|
15
|
-
antenna_form = data + "faa.6030.17.antenna.pdf"
|
16
|
-
|
17
|
-
|
18
|
-
doc1 = app.open(antenna_form)
|
19
|
-
doc1.show
|
20
|
-
|
21
|
-
fields = {"city" => "OGD", "state" => "Utah",
|
22
|
-
"lid" => "OGD",
|
23
|
-
"fac" => "RTR"}
|
24
|
-
doc1.fill_form(fields)
|
25
|
-
|
26
|
-
|
27
|
-
doc1.save_as(name: "ogd.rtr.pdf", dir: "tmp")
|
28
|
-
binding.pry
|
29
|
-
jso = doc1.jso
|
30
|
-
jso.show_console
|
31
|
-
puts "field count: #{jso.field_count}"
|
32
|
-
puts "field names: \n#{jso.field_names}"
|
33
|
-
binding.pry
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
doc2 = app.open(data + "faa.6030.17.cm300.uhf.tx.pdf")
|
38
|
-
doc2.show
|
39
|
-
doc2.fill_form(fields)
|
40
|
-
|
41
|
-
doc1.merge(doc2)
|
42
|
-
doc1.save_as(name: "ogd.merged_antenna_tx.pdf", dir: "tmp")
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
1
|
+
# frozen_string_literal: true; -*- rbs_inline: enabled -*-
|
2
|
+
|
3
|
+
require_relative "acrobat/version"
|
4
|
+
require_relative "acrobat/app"
|
5
|
+
|
6
|
+
module Acrobat
|
7
|
+
class Error < StandardError; end
|
8
|
+
# Your code goes here...
|
9
|
+
end
|
data/rbs_collection.yaml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Download sources
|
2
|
+
sources:
|
3
|
+
- type: git
|
4
|
+
name: ruby/gem_rbs_collection
|
5
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
6
|
+
revision: main
|
7
|
+
repo_dir: gems
|
8
|
+
|
9
|
+
# You can specify local directories as sources also.
|
10
|
+
# - type: local
|
11
|
+
# path: path/to/your/local/repository
|
12
|
+
|
13
|
+
# A directory to install the downloaded RBSs
|
14
|
+
path: .gem_rbs_collection
|
15
|
+
|
16
|
+
# gems:
|
17
|
+
# # If you want to avoid installing rbs files for gems, you can specify them here.
|
18
|
+
# - name: GEM_NAME
|
19
|
+
# ignore: true
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# Generated from lib/acrobat/app.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Acrobat
|
4
|
+
class FileNotFound < StandardError
|
5
|
+
def initialize: (untyped path) -> untyped
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module FileSystemObject
|
10
|
+
def self.instance: () -> untyped
|
11
|
+
|
12
|
+
def self.windows_path: (untyped path) -> untyped
|
13
|
+
end
|
14
|
+
|
15
|
+
module ACRO
|
16
|
+
end
|
17
|
+
|
18
|
+
module Acrobat
|
19
|
+
class App
|
20
|
+
# [WIN32_OLE] ole_obj
|
21
|
+
attr_reader ole_obj: untyped
|
22
|
+
|
23
|
+
def initialize: () -> untyped
|
24
|
+
|
25
|
+
def self.close: (untyped path) -> untyped
|
26
|
+
|
27
|
+
# Runs the adobe app and quits at the end
|
28
|
+
# @example
|
29
|
+
# Acrobat::App.run do |app|
|
30
|
+
# doc = app.open('doc.pdf')
|
31
|
+
# doc.fill_form( city: 'City', state: 'ST')
|
32
|
+
# doc.save_as('filled.pdf')
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# @rbs return Void
|
36
|
+
def self.run: () -> Void
|
37
|
+
|
38
|
+
def self.replace_pages: (untyped pdf_file, untyped replacement, output_name: untyped, **untyped opts) -> untyped
|
39
|
+
|
40
|
+
# Fills the form with updates in a hash
|
41
|
+
# @example
|
42
|
+
# Acrobat::App.fill_form(myform.pdf, output_name: 'filled.pdf
|
43
|
+
# , update_hash: { name: 'dom', filled_date: 1/20/2013
|
44
|
+
# @rbs pdf_form: String -- the String path of a fillable pdf file
|
45
|
+
# @rbs output_name: String -- the name of the saved filled pdf file
|
46
|
+
# @rbs update_hash: Hash -- the hash with updates
|
47
|
+
def self.fill_form: (String pdf_form, output_name: String, update_hash: Hash) -> untyped
|
48
|
+
|
49
|
+
# @rbs return Array[AvDoc]
|
50
|
+
# @rbs &: (AvDoc) -> Void
|
51
|
+
def avdocs: () { (AvDoc) -> Void } -> Array[AvDoc]
|
52
|
+
|
53
|
+
# show the Adobe Acrobat application
|
54
|
+
def show: () -> untyped
|
55
|
+
|
56
|
+
# hide the Adobe Acrobat application
|
57
|
+
def hide: () -> untyped
|
58
|
+
|
59
|
+
# Finds the pdfs in a dir
|
60
|
+
# @rbs dir: String -- the directory to find pdfs in
|
61
|
+
# @rbs return Array[Pathname] -- of pdf files
|
62
|
+
def find_pdfs_in_dir: (String dir) -> Array[Pathname]
|
63
|
+
|
64
|
+
def merge_pdfs: (*untyped pdfs) -> untyped
|
65
|
+
|
66
|
+
# merges the pdfs in directory
|
67
|
+
# @rbs dir: String -- the path of the directory
|
68
|
+
# @rbs name: String | Nil -- the name of the returned pdf file
|
69
|
+
# if the name is nil, the name is "merged.pdf"
|
70
|
+
# @rbs output_dir: String | Nil -- the name of the output dir
|
71
|
+
# if the output_dir is nil, the output dir is the dir param
|
72
|
+
# return [Boolean] if the merge was successful or not
|
73
|
+
def merge_pdfs_in_dir: (String dir, ?name: String | Nil, ?output_dir: String | Nil) -> untyped
|
74
|
+
|
75
|
+
# quit the Adobe App.
|
76
|
+
# closes the open adobe documents and quits the program
|
77
|
+
# @rbs return nil
|
78
|
+
def quit: () -> nil
|
79
|
+
|
80
|
+
attr_reader docs: untyped
|
81
|
+
|
82
|
+
# open the file.
|
83
|
+
# @rbs file: String | Pathname -- #to_path
|
84
|
+
# @rbs &: (PDoc) -> Nil
|
85
|
+
# @rbs return PDoc -- the open file as a Pdoc instance
|
86
|
+
def open: (String | Pathname file) { (PDoc) -> Nil } -> PDoc
|
87
|
+
|
88
|
+
def form: () -> untyped
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def load_constants: (untyped ole_obj) -> untyped
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Generated from lib/acrobat/avdoc.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Acrobat
|
4
|
+
class AvDoc
|
5
|
+
attr_reader ole_obj: WIN32OLE
|
6
|
+
|
7
|
+
attr_reader pdoc_name: String
|
8
|
+
|
9
|
+
def initialize: (untyped ole) -> untyped
|
10
|
+
|
11
|
+
# Close the AvDoc
|
12
|
+
# @rbs save: Boolean -- if true asks to save if false closes without saving
|
13
|
+
def close: (?Boolean save) -> untyped
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Generated from lib/acrobat/jso.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Acrobat
|
4
|
+
class Jso
|
5
|
+
attr_reader doc: untyped
|
6
|
+
|
7
|
+
attr_reader ole_obj: untyped
|
8
|
+
|
9
|
+
def initialize: (untyped doc, untyped ole) -> untyped
|
10
|
+
|
11
|
+
def find_field: (untyped name_or_number) -> untyped
|
12
|
+
|
13
|
+
def ole_get_field: (untyped field) -> untyped
|
14
|
+
|
15
|
+
def console: () -> untyped
|
16
|
+
|
17
|
+
def show_console: () -> untyped
|
18
|
+
|
19
|
+
def field_names: () -> untyped
|
20
|
+
|
21
|
+
def export_as_fdf: (untyped name) -> untyped
|
22
|
+
|
23
|
+
def import_fdf: (untyped path) -> untyped
|
24
|
+
|
25
|
+
def fields_hash: () -> untyped
|
26
|
+
|
27
|
+
def set_field: (untyped name, untyped value) -> untyped
|
28
|
+
|
29
|
+
def get_field: (untyped name) -> untyped
|
30
|
+
|
31
|
+
def field_count: () -> untyped
|
32
|
+
|
33
|
+
def clear_form: () -> untyped
|
34
|
+
|
35
|
+
def fill_form: (untyped hash) -> untyped
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Generated from lib/acrobat/pdoc.rb with RBS::Inline
|
2
|
+
|
3
|
+
module Acrobat
|
4
|
+
class PDoc
|
5
|
+
attr_reader ole_obj: untyped
|
6
|
+
|
7
|
+
attr_reader path: Path | Nil
|
8
|
+
|
9
|
+
def self.from_path: (untyped path) -> untyped
|
10
|
+
|
11
|
+
def initialize: (untyped ole, ?untyped path) -> untyped
|
12
|
+
|
13
|
+
def show: (?untyped name) -> untyped
|
14
|
+
|
15
|
+
# @rbs return Fixnum -- the number of pages in the pdf
|
16
|
+
def page_count: () -> Fixnum
|
17
|
+
|
18
|
+
def last_page: () -> untyped
|
19
|
+
|
20
|
+
# merges the doc to the
|
21
|
+
# @rbs doc: PDoc|String|Pathname -- an open PDoc to merge or filename
|
22
|
+
# @rbs return Boolean -- whether the doc was merged correctly
|
23
|
+
def merge: (PDoc | String | Pathname doc) -> Boolean
|
24
|
+
|
25
|
+
# opens and/or returns PDoc
|
26
|
+
# @rbs doc: String|Pathname|Pdoc -- the String path of a pdf file
|
27
|
+
def open_ole_pdoc: (String | Pathname | Pdoc doc) -> untyped
|
28
|
+
|
29
|
+
def fill_and_save: (untyped results, ?name: untyped, ?dir: untyped) -> untyped
|
30
|
+
|
31
|
+
def prepend_pages: (src_path: untyped, ?src_page_start: untyped, ?src_page_end: untyped) -> untyped
|
32
|
+
|
33
|
+
# returns [Pathname] of d
|
34
|
+
# @rbs dir: [String, Nil] the String path
|
35
|
+
# @rbs return dir [Pathname] Pathname of dir or of working directory
|
36
|
+
def default_dir: ([ String, Nil ] dir) -> dir[Pathname]
|
37
|
+
|
38
|
+
def save_as: (untyped name, ?dir: untyped) -> untyped
|
39
|
+
|
40
|
+
def name: () -> untyped
|
41
|
+
|
42
|
+
def close: () -> untyped
|
43
|
+
|
44
|
+
def replace_pages: (untyped doc, ?start: untyped, ?replace_start: untyped, ?num_of_pages: untyped, ?merge_annotations: untyped) -> untyped
|
45
|
+
|
46
|
+
# return the instance of JSO object
|
47
|
+
# @rbs return [Jso] a WIN32OLE wrapped Jso object 'javascript object'
|
48
|
+
def jso: () -> [ Jso ]
|
49
|
+
|
50
|
+
# return the field_names of the pdf form
|
51
|
+
def field_names: () -> untyped
|
52
|
+
|
53
|
+
def fill_form: (untyped results) -> untyped
|
54
|
+
|
55
|
+
def ole_insert_pages: (untyped merge_doc, ?self_start_page: untyped, ?merge_doc_page_start: untyped, ?number_pages: untyped, ?bookmarks: untyped) -> untyped
|
56
|
+
|
57
|
+
def ole_replace_pages: (untyped merge_doc, ?self_start_page: untyped, ?merge_doc_page_start: untyped, ?number_pages: untyped, ?bookmarks: untyped) -> untyped
|
58
|
+
|
59
|
+
def insert_pages: (src: untyped, ?insert_after: untyped, ?src_page_start: untyped, ?src_page_end: untyped) -> untyped
|
60
|
+
|
61
|
+
def merge_pdoc: (untyped doc, **untyped options) -> untyped
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,22 +1,39 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acrobat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dsisnero
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
10
|
+
date: 2025-01-01 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: win32ole
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
13
26
|
description: Merge PDFs fill in forms, from ruby
|
14
27
|
email:
|
15
28
|
- dsisnero@gmail.com
|
16
|
-
executables:
|
29
|
+
executables:
|
30
|
+
- acrobat
|
17
31
|
extensions: []
|
18
32
|
extra_rdoc_files: []
|
19
33
|
files:
|
34
|
+
- ".rubocop.yml"
|
35
|
+
- ".rubocop/minitest.yml"
|
36
|
+
- ".rubocop/strict.yml"
|
20
37
|
- ".standard.yml"
|
21
38
|
- CHANGELOG.md
|
22
39
|
- CODE_OF_CONDUCT.md
|
@@ -28,14 +45,27 @@ files:
|
|
28
45
|
- examples/6030.17.cm300.tx.pdf
|
29
46
|
- examples/form_field.rb
|
30
47
|
- examples/merge.rb
|
48
|
+
- exe/acrobat
|
49
|
+
- gemfiles/rubocop.gemfile
|
31
50
|
- lib/acrobat.rb
|
32
51
|
- lib/acrobat/app.rb
|
52
|
+
- lib/acrobat/avdoc.rb
|
33
53
|
- lib/acrobat/jso.rb
|
34
54
|
- lib/acrobat/pdoc.rb
|
35
55
|
- lib/acrobat/version.rb
|
56
|
+
- rbs_collection.yaml
|
36
57
|
- samples_other/background.js
|
37
58
|
- samples_other/find_word.vb
|
38
59
|
- samples_other/form.vb
|
60
|
+
- sig/generated/acrobat.rbs
|
61
|
+
- sig/generated/acrobat/app.rbs
|
62
|
+
- sig/generated/acrobat/avdoc.rbs
|
63
|
+
- sig/generated/acrobat/jso.rbs
|
64
|
+
- sig/generated/acrobat/pdoc.rbs
|
65
|
+
- sig/generated/acrobat/version.rbs
|
66
|
+
- sig/prototype/lib/acrobat/app.rbs
|
67
|
+
- sig/prototype/lib/acrobat/jso.rbs
|
68
|
+
- sig/prototype/lib/acrobat/pdoc.rbs
|
39
69
|
- vba/overlay.vba
|
40
70
|
homepage: https://github.com/dsisnero/acrobat
|
41
71
|
licenses:
|
@@ -44,7 +74,6 @@ metadata:
|
|
44
74
|
homepage_uri: https://github.com/dsisnero/acrobat
|
45
75
|
source_code_uri: https://github.com/dsisnero/acrobat
|
46
76
|
changelog_uri: https://github.com/dsisnero/acrobat/CHANGELOG.md
|
47
|
-
post_install_message:
|
48
77
|
rdoc_options: []
|
49
78
|
require_paths:
|
50
79
|
- lib
|
@@ -59,8 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
88
|
- !ruby/object:Gem::Version
|
60
89
|
version: '0'
|
61
90
|
requirements: []
|
62
|
-
rubygems_version: 3.
|
63
|
-
signing_key:
|
91
|
+
rubygems_version: 3.6.2
|
64
92
|
specification_version: 4
|
65
93
|
summary: Automate Adobe Acrobat from Ruby
|
66
94
|
test_files: []
|