How to fetch the content from the PDF into a string using QTP/VBScript?

非 Y 不嫁゛ 提交于 2019-12-22 16:40:59

问题


I need to validate a particular content from the PDF using QTP. How I can get the content from the PDF into the string Using QTP/VBScript. So that, I can validate the content in the PDF.


回答1:


Do visit Here. You will get your answer, this is one of the menthod to work with PDF in QTP. You can also fetch data from PDF by passing Keys i,e, Ctrl+a then Ctrl+c then copy this data to Clipboard & use this data for comparing with your standard data

Sample Function For Getting data from PDF, When PDF report is open in Broweser whose creation time is passed in datatable

Public function CopyPDFData(sDestinationFile)       
Dim clip, strText, nCT, fso

nCT = DataTable("bPDFCreationTime", dtLocalSheet)
If nCT =""  Then nCT=1
Browser("CreationTime:=" & nCT).Sync

Browser("CreationTime:=" & nCT).FullScreen            
wait(2)
Browser("CreationTime:=" & nCT).WinObject("object class:=AVL_AVView", "text:=AVPageView").Type micCtrlDwn + "a" + micCtrlUp
wait(4)
Browser("CreationTime:=" & nCT).WinObject("object class:=AVL_AVView", "text:=AVPageView").Type micCtrlDwn + "c" + micCtrlUp
wait(4)

Set clip = CreateObject("Mercury.Clipboard" )
strText = clip.GetText
clip.Clear

Set fso = CreateObject("Scripting.FileSystemObject")
Set strfile = fso.CreateTextFile(sDestinationFile, True) 
strfile .Write  strText
strfile .Close
Browser("CreationTime:=" & nCT).sync
Browser("CreationTime:=" & nCT).close
End Function

Let me know if this solves your problem, there are also other alternatives for PDF Report testing using QTP



来源:https://stackoverflow.com/questions/9323464/how-to-fetch-the-content-from-the-pdf-into-a-string-using-qtp-vbscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!