pdf-toolkit icon indicating copy to clipboard operation
pdf-toolkit copied to clipboard

No such file or directory error

Open ramyakp opened this issue 10 years ago • 7 comments

Hello, I have downloaded the latest version of pdf-toolkit gem for Ruby. When i try to use PDF::Toolkit.open command, i get the error 'No such file or directory - /dev/null'

I have tried giving the absolute path, relative paths, nothing works. Can someone please help? I have the code snippet as below.

Regards, Ramya

require 'rubygems' require 'pdf/toolkit'

begin filename = "Test.pdf" my_pdf = PDF::Toolkit.open(filename) text = my_pdf.to_text.read puts text rescue Exception => msg

display the system generated error message

puts msg end

ramyakp avatar Jul 29 '14 14:07 ramyakp

Hello,

The only place where something could be wrong is here: https://github.com/blambeau/pdf-toolkit/blob/master/lib/pdf/toolkit/native.rb#L34

What is your environment? Can you send me the value of RUBY_PLATFORM?

blambeau avatar Jul 30 '14 05:07 blambeau

Hello, Thanks for the speedy response. Here are the deatils: RUBY_PLATFORM : i386-mingw32. ruby 1.9.3p545 (2014-02-24) [i386-mingw32]

Please let me know if you need any more details.

Regards, Ramya

On Wed, Jul 30, 2014 at 6:42 AM, Bernard Lambeau [email protected] wrote:

Hello,

The only place where something could be wrong is here: https://github.com/blambeau/pdf-toolkit/blob/master/lib/pdf/toolkit/native.rb#L34

What is your environment? Can you send me the value of RUBY_PLATFORM?

— Reply to this email directly or view it on GitHub https://github.com/blambeau/pdf-toolkit/issues/4#issuecomment-50575778.

ramyakp avatar Jul 30 '14 10:07 ramyakp

Ok. Could you try by replacing the line (lib/pdf/toolkit/native.rb:34)

STDERR.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')

by

STDERR.reopen(RUBY_PLATFORM =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')

If it works on your computer, I'll make the change in the repo, but I can't test it easily, having no windows machine.

blambeau avatar Jul 30 '14 11:07 blambeau

Thanks Bernard. I have made that change to native.rb. There is no error during the open however, Now i get this error when trying to execute 'my_pdf.to_text.read' line

No such file or directory - "pdftotext" "C:\Downloads\PrivateCompanyPreview.pdf" "-"

This is the code I have:

require 'rubygems'

require 'pdf/toolkit'

begin

filename = "C:\Downloads\PrivateCompanyPreview.pdf"

my_pdf = PDF::Toolkit.open(filename)

text = my_pdf.to_text.read

puts text

rescue Exception => msg

display the system generated error message

puts msg

end

ramyakp avatar Jul 30 '14 13:07 ramyakp

Clearly, the pdftk installation under windows is not the same as in linux.

pdftotext is a commandline utility that should come bundled with the installation pdf toolkit.

blambeau avatar Jul 30 '14 13:07 blambeau

ah i see. So, is there a workaround for this issue?

Regards, Ramya

On Wed, Jul 30, 2014 at 2:38 PM, Bernard Lambeau [email protected] wrote:

Clearly, the pdftk installation under windows is not the same as in linux.

pdftotext is a commandline utility that should come bundled with the installation pdf toolkit.

— Reply to this email directly or view it on GitHub https://github.com/blambeau/pdf-toolkit/issues/4#issuecomment-50614935.

ramyakp avatar Jul 30 '14 13:07 ramyakp

Not that I know. You should check the documentation of pdf toolkit under windows.

blambeau avatar Jul 30 '14 15:07 blambeau