Forum: Ruby Error invoking PDFTK when running from TextMate

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Mongeta 9. (Guest)
on 2009-05-07 15:27
Hello,

I have some simple code that works perfectly from irb and from RoR, but
when I try to run it from TextMate (command R) I'm getting always the
error:

PDF::Toolkit::ExecutionError: Error invoking PDFTK

require "rubygems"
require 'pdf/toolkit'
require "ActiveSupport"

...
 my_pdf = PDF::Toolkit.open(absolute_path_filename)
...


Any idea of what I'm missing ?

thanks,

r.
Jason F. (Guest)
on 2009-05-20 00:25
I'm having a similar problem, although I'm getting the error
"PDF::Toolkit::ExecutionError: Error invoking PDFTK" directly when
running Ruby on the command line

Here's my ruby script:

require 'rubygems'
require 'pdf/toolkit'
require "ActiveSupport"

my_pdf = PDF::Toolkit.open("/Users/jason/MTY292323-04.pdf")
puts "hello"
txt = my_pdf.to_text.read
puts txt


When I invoke this script I get the "Error invoking PDFTK"

$ ruby lib/test_pdf_toolkit.rb
/Library/Ruby/Gems/1.8/gems/pdf-toolkit-0.49/lib/pdf/toolkit.rb:556:in
`read_data': Error invoking PDFTK (PDF::Toolkit::ExecutionError)
  from
/Library/Ruby/Gems/1.8/gems/pdf-toolkit-0.49/lib/pdf/toolkit.rb:279:in
`reload'
  from
/Library/Ruby/Gems/1.8/gems/pdf-toolkit-0.49/lib/pdf/toolkit.rb:227:in
`open'
  from lib/test_pdf_toolkit.rb:5


I tried making a symlink from /usr/bin/pdftk to the real pdftk
executable here:  /usr/local/bin/pdftk

But still no luck. I'm on Mac OS X 10.5 and I installed PDFTK using the
package installer
(http://www.pdfhacks.com/pdftk/OSX-10.3/pdftk1.12_O...)

I did notice in the readme for PDFTK that it says: "NOTE: The version of
pdftk installed by this package will only work on macs running OS X
10.3." -- I don't suppose it means it really won't work on 10.4 and 10.5
and if you like me, on 10.5, you really need to build it using
DarwinPORTS ?  (I guess I assumed it work was forward compatible).
Mongeta 9. (Guest)
on 2009-05-20 11:53
I'm glad I'm not alone with this problem ...

With RubyMine it works, in command line it works, but in textmate it
doesn't ...

and yes, I'm with 10.5.x

and I'm still having the same problem ...

r.
Isaac M. (Guest)
on 2010-05-27 00:07
Raimon Fs wrote:
> Hello,
>
> I have some simple code that works perfectly from irb and from RoR, but
> when I try to run it from TextMate (command R) I'm getting always the
> error:
>
> PDF::Toolkit::ExecutionError: Error invoking PDFTK
>
> require "rubygems"
> require 'pdf/toolkit'
> require "ActiveSupport"
>
> ...
>  my_pdf = PDF::Toolkit.open(absolute_path_filename)
> ...
>
>
> Any idea of what I'm missing ?
>
> thanks,
>
> r.

A year later and still no resolution is posted?

I am having the same problem as those above. I am using winxp, ruby 1.91
and pdftoolkit 0.49

Just like the above, if I type the code into irb it works just fine. If
I run it in an IDE(I use netbeans) then it returns the following error:
C:/Ruby19/lib/ruby/gems/1.9.1/gems/pdf-toolkit-0.49/lib/pdf/toolkit.rb:556:in
`read_data': Error invoking PDFTK (PDF::Toolkit::ExecutionError)
        from
C:/Ruby19/lib/ruby/gems/1.9.1/gems/pdf-toolkit-0.49/lib/pdf/toolkit.rb:279:in
`reload'
        from
C:/Ruby19/lib/ruby/gems/1.9.1/gems/pdf-toolkit-0.49/lib/pdf/toolkit.rb:227:in
`open'
        from H:/NetBeansProjects/Beeprocessoradvanced/lib/main.rb:12:in
`<main>'


Someone PLEASE give me an idea of how to resolve this problem. The worst
part is this code is part of a program that worked only a week ago. I
don't know what changed but I went back to run the program and got this
error.
Code:
require 'pdf/toolkit'
require 'pp'

outcounter = 0
htmlcounter = 0
inputarray = []
outputarray = []
puts "0"
my_pdf = PDF::Toolkit.open('c:\process\b')
puts "1"

The above code returns the error on the line "my_pdf =
PDF::Toolkit.open('c:\process\b')" just after it outputs "0".
Brad H. (Guest)
on 2010-11-15 17:09
I had the same problem.

Turns out it was the security settings on the pdf I was attempting to
read.

I was getting the exact same error, so I resaved the pdf with NO
security settings and the problem went away!!!

I think you can supply the password to pdftk as well.
Mongeta 9. (Guest)
on 2010-11-15 17:15
Brad Hodges wrote in post #961578:
> I had the same problem.
>
> Turns out it was the security settings on the pdf I was attempting to
> read.
>
> I was getting the exact same error, so I resaved the pdf with NO
> security settings and the problem went away!!!
>
> I think you can supply the password to pdftk as well.

I'm not sure now if my pdf had some security settings, I think not, I'll
try to test again, thanks for sharing this info.

regards,

r.
This topic is locked and can not be replied to.