def save_as(output_file_path, failure_list=[])
      filestream = FileOutputStream.new(output_file_path)
      copy = PdfCopyFields.new(filestream)

      @files_to_merge.each do |f|
        if File.exists?(f)
          begin
            copy.addDocument(PdfReader.new(f))
          rescue => e
            failure_list << f
            log "PDF::Merger: Invalid PDF: #{f}"
          end
        else
          failure_list << f
          log "PDF::Merger: File does not exist: #{f}"
        end
      end

      if @files_to_merge.size - failure_list.size > 0
        copy.addJavaScript(@js) if @js && !@js.empty?
        copy.close()
        PdfReader.new(output_file_path).getNumberOfPages
      else
        0
      end
    end
def save_as(output_file_path, failure_list=[])
      filestream = FileOutputStream.new(output_file_path)
      copy = PdfCopyFields.new(filestream)

      @files_to_merge.each do |f|
        if File.exists?(f)
          begin
            copy.addDocument(PdfReader.new(f))
          rescue => e
            failure_list << f
            log "PDF::Merger: Invalid PDF: #{f}"
          end
        else
          failure_list << f
          log "PDF::Merger: File does not exist: #{f}"
        end
      end

      if @files_to_merge.size - failure_list.size > 0
        copy.addJavaScript(@js) if @js && !@js.empty?
        copy.close()
        PdfReader.new(output_file_path).getNumberOfPages
      else
        0
      end
    end
Saves the PDF into a file defined by path given.
 - return the number of pages in the new file
 - populate failure_list with paths of missing or invalid PDFs