Forum Discussion

m_essaid's avatar
m_essaid
Valued Contributor
10 years ago

Opening PDF documents with Acrobat Reader and save as theses documents in .txt

Hi,



I need text files from PDF documents.

I tried this tuto :

http://support.smartbear.com/viewarticle/55492/

but I don't managed to get the Acrobat Reader's window settings :




  AcroRd32X := Sys.Process('AcroRd32');


  wndAcrobatX := AcroRd32X.Window('Acrobat Reader', '*');   <---- this line is not correct.



I already have everything I need to read and manipulate the .txt files. But I get wrong after opening Acrobat Reader (as a TestedApp).



Could someone tell me why I'm wrong in the second line ?



Thank you in advance for any help,



Regards,



Mehdi

7 Replies

  • jorgesimoes1983's avatar
    jorgesimoes1983
    Regular Contributor
    You can do it like this, it works great!



    http://smartbear.com/forums/f81/t88540/getting-exception-while-trying-to-read-pdf-file/#88834



    and you can search for the document by doing something like this:



    var properties= new Array("ObjectIdentifier", "ObjectType");

    var values= new Array("PDF", "Object");



    var objPdf = Sys.Process(iexplore).Page("*").Find(properties, values, 20);



    then look at src property or innerHTML (it dependes the website structure)
  • elfen_dark's avatar
    elfen_dark
    Occasional Contributor
    try




      AcroRd32X := Sys.Process('AcroRd32');

    wndAcrobatX := AcroRd32X.Window('Acrobat Reader', '*',1);





    i hope work the help..





    regards
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Mehdi,

     


    What warning message do you get?


     


    Actually, I'm not sure that you can save the document to a txt file. I recommend that you refer to this FAQ entry to learn the approaches provided by TestComplete to work with PDF files.


     

  • If you can get Acrobat Reader to be the active window, you can drop into Windows Shell and send keypress events to select all and copy to the clipboard. Then just dump the clipboard object contents into a string and you have all the text from your PDF file.



    I've used this method before. Both on embedded web PDF's and standalone ones with Acrobat Reader.



    Primitive really. But it works.



    Unless the PDF is protected. I never did find a way to extract text from those ....
  • m_essaid's avatar
    m_essaid
    Valued Contributor
    Hi Tanya,



    I get this message :

    "Cannot obtain the window with the window class 'Acrobat Reader', window caption '*' and index 1."



    Manually I manage to export a pdf file into text file. I just would like to do so with Test Complete.



    Regards,



    Mehdi
  • m_essaid's avatar
    m_essaid
    Valued Contributor
    finally I found the following syntax which fill my need :




      TestedApps.AcroRd32.Run();


      AcroRd32X:= Sys.Process('AcroRd32');


      wndAcrobatX:= Aliases.AcroRd32.form;



    Anyway, thanks a lot to all of you who took some time to answser to me !



    Mehdi