3

I am new to 'libreconv' gem, I am using Ruby 2.2.0 and Rails 4.2.0 version While I am converting Ms Word document to PDF, I get following error:

2.2.0 > Libreconv.convert('sample1.doc', '/Users/rp/test_document.pdf')

Errno::ENOENT: No such file or directory @ rb_sysopen - /tmp/sample1.pdf from /home/rp/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/fileutils.rb:1391:in `initialize'

Any Suggestions ?

fidato
  • 719
  • 5
  • 22

1 Answers1

1

I solved this problem with such patch:

class Libreconv::Converter
  alias_method :old_convert, :convert

   def convert
     if Rails.env.development?
       old_convert
     else
       %x(sudo #{@soffice_command} --headless --convert-to pdf --outdir #{@target_path} #{@source})
       target_tmp_file = "#{@target_path}/#{File.basename(@source, ".*")}.pdf"
       FileUtils.cp target_tmp_file, @target
     end
   end
end
Gena Shumilkin
  • 713
  • 4
  • 16