lib/fillable-pdf.rb in fillable-pdf-0.9.5.1 vs lib/fillable-pdf.rb in fillable-pdf-0.9.5.2

- old
+ new

@@ -1,10 +1,10 @@ require_relative 'fillable-pdf/itext' require_relative 'field' require 'base64' -require 'fileutils' require 'securerandom' +require 'tmpdir' class FillablePDF # rubocop:disable Metrics/ClassLength ## # Opens a given fillable-pdf PDF file and prepares it for modification. # @@ -146,11 +146,11 @@ # # @param [String|Symbol] key the field name # @param [String|Symbol] base64_image_data base64 encoded data image # def set_image_base64(key, base64_image_data) - tmp_file = SecureRandom.uuid + tmp_file = "#{Dir.tmpdir}/#{SecureRandom.uuid}" File.binwrite(tmp_file, Base64.decode64(base64_image_data)) set_image(key, tmp_file) ensure FileUtils.rm tmp_file end @@ -212,10 +212,10 @@ # Overwrites the previously opened PDF document and flattens it if requested. # # @param [bool] flatten true if PDF should be flattened, false otherwise # def save(flatten: false) - tmp_file = SecureRandom.uuid + tmp_file = "#{Dir.tmpdir}/#{SecureRandom.uuid}" save_as(tmp_file, flatten: flatten) FileUtils.mv tmp_file, @file_path end ##