Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to find text coordination using VBScript and OLE Automation

595 views
Skip to first unread message

Rafi_...@adobeforums.com

unread,
Dec 11, 2003, 2:32:41 PM12/11/03
to
We are trying to add a signature field into an existing PDF file on the fly using VBScript and OLE automation in Windows XP and Acrobat 50. The problem is that the location of the signature field is not fixed so we need to find the location of the signature field based on a constant text in the contract.
Our code successfully finds the constant text and highlights it in order to call GetBoundingRect method to get rectangle (and thus the coordination) of the highligthed text. The problem is that we keep getting the error “Object doesn't support this property or method.” When calling to GetBoundingRect.
According to Adobe InterApplication Communication Reference (IACReference.pdf) document, PDTextSelect object has five methods (Destroy, GetBoundingRect, GetNumText, GetPage, GetText) and we could use four of them in VBScript but not GetBoundingRect. Any idea why?
Attached is a simple VBScript that highlights the second word of a PDF file but fails to get its location using GetBoundingRect. To run it just copy it to a file name FindTextLocation.vbs and run the following from a command line:
cscript /nologo FindTextLocation.vbs AnyPDFFileName
----------------------------------------------------

Dim arguments
Set arguments = WScript.Arguments
pdfFileName = arguments.Unnamed.Item(0)

Set AcroApp = CreateObject("AcroExch.App")
Set PDFObj = CreateObject("AcroExch.PDDoc")
PDFObj.open pdfFileName
Set AVObj = PDFObj.openAVDoc("Dex Contract")

Set myPDFPage = PDFObj.AcquirePage(0)
'create a hilite object to find a text
Set myPageHilite = CreateObject("AcroExch.hilitelist")
hiliteResult = myPageHilite.Add(2, 1) 'Hilite the second word
Set pageSelect = myPDFPage.CreateWordHilite(myPageHilite)
'MsgBox pageSelect.GetText(0)

'Show the hilited text before calling to GetBoundingRect
AVObj.SetTextSelection(pageSelect)
AVObj.ShowTextSelect()
AcroApp.Show
MsgBox "Second Word is highlighted"

Set acroRect = CreateObject("AcroExch.Rect")
acroRect = pageSelect.GetBoundingRect 'AcroExch.PDTextSelect
'Set SgnRect = pageSelect.GetBoundingRect 'AcroExch.PDTextSelect

Set myPDFPage = Nothing
Set myPageHilite = Nothing
Set pageSelect = Nothing

0 new messages