This is in relation to this thread:
http://www.ruby-forum.com/topic/186295
(I was asked to create a new one as it was 6 months old)
I am using the following Ruby code but unable to open the pdf file.
require ‘rubygems’
require ‘pdf/toolkit’
class AbcController < ApplicationController
def get_teachings
my_pdf = PDF::Toolkit.open(“/home/abc/mozilla.pdf”)
text = my_pdf.to_text.read
puts text
end
end
The file exists but I am getting this error
PDF::Toolkit::ExecutionError in SaiController#get_teachings
Error invoking PDFTK
RAILS_ROOT: script/…/config/…
Application Trace | Framework Trace | Full Trace
/var/lib/gems/1.8/gems/pdf-toolkit-0.5.0/lib/pdf/toolkit.rb:563:in
read_data' /var/lib/gems/1.8/gems/pdf-toolkit-0.5.0/lib/pdf/toolkit.rb:279:in
reload’
/var/lib/gems/1.8/gems/pdf-toolkit-0.5.0/lib/pdf/toolkit.rb:227:in
open' app/controllers/sai_controller.rb:9:in
get_teachings’
/var/lib/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/base.rb:1095:in
`send’
Request
Parameters: None
Show session dump
Response
Headers: {“Cache-Control”=>“no-cache”, “cookie”=>[]}
I am running this on a Linux Ubuntu 64 bit.
I need a way to parse a pdf file’s contents and search for specific
content.
I am not sure how to check for the file’s security settings as mentioned
in the previous post.
Any help would be appreciated.
Thanks
Balaji