Class: Acrobat::PDoc
- Inherits:
-
Object
- Object
- Acrobat::PDoc
- Defined in:
- lib/acrobat/app.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#ole_obj ⇒ Object
readonly
Returns the value of attribute ole_obj.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #close ⇒ Object
- #default_dir(d) ⇒ Object
- #field_names ⇒ Object
- #fill_form(results) ⇒ Object
-
#initialize(app, ole, path = nil) ⇒ PDoc
constructor
A new instance of PDoc.
- #jso ⇒ Object
-
#merge(doc) ⇒ Boolean
merges the doc to the.
- #name ⇒ Object
-
#page_count ⇒ Fixnum
The number of pages in the pdf.
- #save_as(name: nil, dir: nil) ⇒ Object
- #show(name = nil) ⇒ Object
- #update_and_save(results, name: nil, dir: nil) ⇒ Object
- #update_form(results) ⇒ Object
Constructor Details
#initialize(app, ole, path = nil) ⇒ PDoc
Returns a new instance of PDoc.
154 155 156 157 158 |
# File 'lib/acrobat/app.rb', line 154 def initialize(app,ole,path=nil) @app = app @ole_obj = ole @path = path end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
152 153 154 |
# File 'lib/acrobat/app.rb', line 152 def app @app end |
#ole_obj ⇒ Object (readonly)
Returns the value of attribute ole_obj.
152 153 154 |
# File 'lib/acrobat/app.rb', line 152 def ole_obj @ole_obj end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
152 153 154 |
# File 'lib/acrobat/app.rb', line 152 def path @path end |
Instance Method Details
#close ⇒ Object
215 216 217 |
# File 'lib/acrobat/app.rb', line 215 def close ole_obj.Close end |
#default_dir(d) ⇒ Object
198 199 200 |
# File 'lib/acrobat/app.rb', line 198 def default_dir(d) Pathname(dir || Pathname.getw) end |
#field_names ⇒ Object
224 225 226 |
# File 'lib/acrobat/app.rb', line 224 def field_names jso.field_names end |
#fill_form(results) ⇒ Object
228 229 230 |
# File 'lib/acrobat/app.rb', line 228 def fill_form(results) jso.fill_form(results) end |
#jso ⇒ Object
220 221 222 |
# File 'lib/acrobat/app.rb', line 220 def jso @jso ||= Jso.new(ole_obj.GetJSObject) end |
#merge(doc) ⇒ Boolean #merge(doc) ⇒ Boolean
merges the doc to the
176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/acrobat/app.rb', line 176 def merge(doc) case doc when PDoc merge_pdoc(doc) when String, Pathname docpath = Pathname(doc) raise 'File not found' unless docpath.file? doc2 = app.open(docpath) merge_pdoc(doc2) end end |
#name ⇒ Object
211 212 213 |
# File 'lib/acrobat/app.rb', line 211 def name ole_obj.GetFileName end |
#page_count ⇒ Fixnum
Returns the number of pages in the pdf.
166 167 168 |
# File 'lib/acrobat/app.rb', line 166 def page_count ole_obj.GetNumPages() end |
#save_as(name: nil, dir: nil) ⇒ Object
203 204 205 206 207 208 209 |
# File 'lib/acrobat/app.rb', line 203 def save_as(name:nil, dir:nil) name = path.basename unless name dir = Pathname(dir || Pathname.getwd) dir.mkpath windows_path = FileSystemObject.windows_path(dir + name ) ole_obj.save(ACRO::PDSaveFull | ACRO::PDSaveCopy,windows_path) end |
#show(name = nil) ⇒ Object
160 161 162 163 |
# File 'lib/acrobat/app.rb', line 160 def show(name = nil) name = name || ole_obj.GetFileName ole_obj.OpenAVDoc(name) end |
#update_and_save(results, name: nil, dir: nil) ⇒ Object
192 193 194 195 196 |
# File 'lib/acrobat/app.rb', line 192 def update_and_save(results,name: nil, dir: nil) update_form(results) is_saved = save_as(name: name, dir: dir) puts "saved file: %s" % [dir + name] if is_saved end |
#update_form(results) ⇒ Object
188 189 190 |
# File 'lib/acrobat/app.rb', line 188 def update_form(results) form.update(results) end |