使用QTP计算pdf文件中的字符串
我正在尝试计算 pdf 文件中字符串存在的次数。我使用了下面的代码,但它陷入了无限循环。问题是在找到最后一页之后的字符串后,它返回到第一页并再次重复所有步骤。有没有人有解决这个问题的办法。任何帮助将不胜感激。
谢谢 湿婆
Dim AcroApp, AcroAVDoc
Dim gPDFPath, bReset, nCount
gPDFPath = "xyz.pdf"
Set AcroApp = CreateObject( "AcroExch.App" )
AcroApp.Show()
Set AcroAVDoc = CreateObject( "AcroExch.AVDoc" )
If AcroAVDoc.Open( gPDFPath, "" ) Then
AcroAVDoc.BringToFront()
bReset = True : nCount = 0
Do While AcroAVDoc.FindText( "let", True, True, bReset )
bReset = False : nCount = nCount + 1
Wait 0, 200
Loop
End If
AcroApp.CloseAllDocs()
AcroApp.Exit()
I am trying to count the number of times a string exists in a pdf file. I used the below code, but it is going in infinite loop. The problem is after finding the string after the last page,it comes back to 1st page and repeats all the steps again. Does anyone have a solution for this problem. Any help will be appreciated.
Thanks
siva
Dim AcroApp, AcroAVDoc
Dim gPDFPath, bReset, nCount
gPDFPath = "xyz.pdf"
Set AcroApp = CreateObject( "AcroExch.App" )
AcroApp.Show()
Set AcroAVDoc = CreateObject( "AcroExch.AVDoc" )
If AcroAVDoc.Open( gPDFPath, "" ) Then
AcroAVDoc.BringToFront()
bReset = True : nCount = 0
Do While AcroAVDoc.FindText( "let", True, True, bReset )
bReset = False : nCount = nCount + 1
Wait 0, 200
Loop
End If
AcroApp.CloseAllDocs()
AcroApp.Exit()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为这与 QTP 有关,它与 Acrobat 的 API 有关,快速搜索返回 此 API 链接。
看起来问题在于您正在为
bReset
使用布尔值,文档说:所以
bReset
应该是一个 long 而不是布尔值。在 VBScript 中,
False
为 0,True
为 -1,因此当您发送True
时,它可能不被视为正数,尝试使用 1 代替。I don't think this is related to QTP it has to do with Acrobat's API, a quick search returned this link to the API.
It looks like the problem is that you're using a boolean for
bReset
, the documentation says:So
bReset
should be a long not a boolean.In VBScript
False
is 0 andTrue
is -1, so when you're sendingTrue
it could be that it's not considered a positive number, try using 1 instead.