Class: PDFRavager::Ravager
- Inherits:
-
Object
- Object
- PDFRavager::Ravager
- Defined in:
- lib/pdf_ravager/ravager.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(template, opts = {}) ⇒ Ravager
constructor
A new instance of Ravager.
- #ravage ⇒ Object
Constructor Details
#initialize(template, opts = {}) ⇒ Ravager
Returns a new instance of Ravager.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pdf_ravager/ravager.rb', line 21 def initialize(template, opts={}) @opts = opts opts = {:in_file => opts} if opts.is_a? String @out = if opts[:out_file] java.io.FileOutputStream.new(opts[:out_file]) else java.io.ByteArrayOutputStream.new end @template = template reader = com.lowagie.text.pdf.PdfReader.new(opts[:in_file]) @stamper = com.lowagie.text.pdf.PdfStamper.new(reader, @out) @strategy = case template.strategy when :acro_forms Strategies::AcroForm.new(@stamper) when :xfa Strategies::XFA.new(@stamper) when :smart Strategies::Smart.new(@stamper) end end |
Class Method Details
.ravage(*args, &blk) ⇒ Object
15 16 17 18 19 |
# File 'lib/pdf_ravager/ravager.rb', line 15 def self.ravage(*args, &blk) warn "[DEPRECATION] Please use PDFRavager::Ravager's instance " + "methods instead of the `::ravage` method" new(*args, &blk).ravage end |
Instance Method Details
#ravage ⇒ Object
42 43 44 45 46 47 |
# File 'lib/pdf_ravager/ravager.rb', line 42 def ravage @strategy.set_field_values(@template) @strategy.set_read_only if @opts[:read_only] @stamper.close @out end |