1.Download the pdf reader gem from http://rubygems.org/gems/pdf-reader
based on ruby version
For ruby 1.8.7 - pdf-reader 0.9.2
For ruby 1.8.4 - pdf-reader 0.8.0

2.Install gem
gem install pdf-reader

3.Go to your web page  right clicks on the link where the pdf file can
be opened

4.Right click on the link and select 'Save As'
     @ie.link(:text, "Click here to open.....").focus
     @ie.send_keys("{APPSKEY}")
     @ie.send_keys("{A}")
5.Then save it in to local directory with the same file name
     filepath='C:'
    ai = WIN32OLE.new("AutoItX3.Control")
    ai.WinWait("File Download", "", 5)
    ai.ControlFocus("File Download", "", "&Save")
    sleep 1 #may not be necessary
    ai.WinActivate("File Download")
    sleep 1
    ai.ControlClick("File Download", "", "&Save", "left")
    ai.WinWait("Save As", "", 5)
    sleep 1 #may not be necessary
    fileName=ai.ControlGetText("Save As", "", "Edit1")
    ai.ControlSend("Save As", "", "Edit1", "#{filepath}\\#{fileName}")
    ai.ControlClick("Save As", "", "&Save", "left")
    ai.WinWait("Download complete", "", 5)
    ai.ControlClick("Download complete", "", "Close")
6.Convert whole pdf file into string array
    receiver = PageTextReceiver.new
    pdf = PDF::Reader.file("c:\\prospectus.pdf", receiver)
     puts receiver.content.inspect
7. Output of pdf file will be like
    [" The Prospectus for admission to XXX course 2006, is published
herewith..........." ]


-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

Reply via email to