26 January 2010

Quick Test Professional Automation with Adobe PDF Documents - IV

Accessing the text in the document – Method 2

Set myAVDoc = CreateObject("AcroExch.AVDoc")
myAVDoc.Open "C:\TESTPDF.pdf",""

Set myPDDoc = myAVDoc.GetPDDoc

Set acroHiList = CreateObject( "AcroExch.HiliteList" )
Call acroHiList.Add( 0, 32767 )
Virtually highlighting all the text on the document

Set acroPageView = myAVDoc.GetAVPageView()
Get the object of AVPageView class

Call acroPageView.Goto(0)
Go to page 1 of the adobe document under test

Set acroPDPage = acroPageView.GetPage()
Get the object of the PDPage class

Set pdTextSelect = acroPDPage.CreateWordHilite( acroHiList )
Get the object of the PDTextSelect class

Call myAVDoc.SetTextSelection( pdTextSelect )
Call myAVDoc.ShowTextSelect()
myText = pdTextSelect.GetText(0)
Get all the text on the pdf document under test

Print myText

No comments:

Post a Comment