Sha256: e93d89994f0f5eb1e19ef200d6be814689f7c42591495c081c134752370f1272
Contents?: true
Size: 1 KB
Versions: 8
Compression:
Stored size: 1 KB
Contents
module OcrFile module FileHelpers extend self def merge_pdfs(file_paths, save_file_path) documents = file_paths.map { |path| OcrFile::ImageEngines::PdfEngine.open_pdf(path) } merged_document = OcrFile::ImageEngines::PdfEngine.merge(documents) save_pdf(merged_document, save_file_path, optimise: true) end # Beware this is dangerous! def clear_folder(path) return unless path.include?('/temp') # Small hacky safeguard `rm -rf #{path}` # Cleanup end def make_directory(path) `mkdir -p #{path}` end def open_json(path) JSON.parse(File.read(path)) end def append_file(path, text) File.open(path, 'a') { |file| file.write(text) } end def open_text_file(path) File.read(path) end def fetch_temp_image_paths(save_path, temp_filename, filetype) filenames = `ls #{save_path} | grep .#{filetype}`.split("\n") filenames.map do |filename| "#{save_path}/#{filename}" end end end end
Version data entries
8 entries across 8 versions & 1 rubygems