lib/fillable-pdf.rb in fillable-pdf-0.9.0 vs lib/fillable-pdf.rb in fillable-pdf-0.9.1

- old
+ new

@@ -1,7 +1,8 @@ require_relative 'fillable-pdf/itext' require_relative 'field' +require 'fileutils' require 'securerandom' class FillablePDF # required Java imports BYTE_STREAM = Rjb.import 'com.itextpdf.io.source.ByteArrayOutputStream' @@ -24,12 +25,12 @@ @pdf_reader = PDF_READER.new @file_path @pdf_writer = PDF_WRITER.new @byte_stream @pdf_doc = PDF_DOCUMENT.new @pdf_reader, @pdf_writer @pdf_form = PDF_ACRO_FORM.getAcroForm(@pdf_doc, true) @form_fields = @pdf_form.getFormFields - rescue StandardError => ex - raise "#{ex.message} (input file may be corrupt, incompatible, or may not have any forms)" + rescue StandardError => e + raise "#{e.message} (input file may be corrupt, incompatible, or may not have any forms)" end end ## # Determines whether the form has any fields. @@ -156,10 +157,10 @@ # @param [bool] flatten true if PDF should be flattened, false otherwise # def save(flatten: false) tmp_file = SecureRandom.uuid save_as(tmp_file, flatten: flatten) - File.rename tmp_file, @file_path + FileUtils.mv tmp_file, @file_path end ## # Saves the filled out PDF document in a given path and flattens it if requested. #