# declare a COM object for the Acrobat application
# this doesn't show up in the Task Manager
$app = New-Object -ComObject AcroExch.App
# declare a COM object for PDDoc
$PDDoc = New-Object -ComObject AcroExch.PDDoc
# open a PDF
$PDDoc.Open('C:\Users\jtang20\Desktop\pdfFolder\test1.pdf')
# this displays the document in the acrobat instance and creates an AVDoc COM object
# at this point, acrobat shows up in the task manager
$AVDoc = $PDDoc.OpenAVDoc("")
# now I can use the FindText method
$AVDoc.FindText("123123",0,1,1)
# Gets the number of open AcroExch.AVDoc objects.
$app.GetNumAVDocs()
# this hides the acrobat instance if it's visible
# acrobat disappears from the Task Manager
$app.Hide()
# housekeeping on the way out
$app.CloseAllDocs()
# supposedly "an application must explicitly close any AVDoc that it opens by calling AVDoc.Close",
# but I'm getting a False in Powershell that makes me think this step isn't working
$AVDoc.Close(0)
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($app)
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($AVDoc)
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($PDDoc)