How to compare 2 excel files using QTP?
How to compare 2 PDF files using QTP?

Answer Posted / srihari j

How to compare 2 PDF files using QTP?

Dim varPath1, varPath2, str1, str2
varPath1 = "C:first.pdf"
varPath2 = "C:second.pdf"

str1= getPDFText (varPath1)
str2= getPDFText (varPath2)

if StrComp(str1,str2,0) <> 0 Then
msgbox "PDF files do not have same text content"
else
msgbox "PDF files have same text content"
end If

Public Function getPDFText (varPath)

Dim MyClipboard

SystemUtil.Run varPath

Window("regexpwndtitle:=Adobe Reader","regexpwndclass:=AdobeAcrobat").Type micAltDwn + "t" + micAltUp

Window("regexpwndtitle:=Adobe Reader","regexpwndclass:=AdobeAcrobat").Type "s"

Window("regexpwndtitle:=Adobe Reader","regexpwndclass:=AdobeAcrobat").Type micDwn

Window("regexpwndtitle:=Adobe Reader","regexpwndclass:=AdobeAcrobat").Type "Enter"

Window("regexpwndtitle:=Adobe Reader","regexpwndclass:=AdobeAcrobat").Type micCtrlDwn + "a" + micCtrlUp

Window("regexpwndtitle:=Adobe Reader","regexpwndclass:=AdobeAcrobat").Type micCtrlDwn + "c" + micCtrlUp

Set MyClipboard = CreateObject("Mercury.Clipboard")

getPDFText = MyClipboard.GetText

MyClipboard.Clear

Set MyClipboard=Nothing

Window("regexpwndtitle:=Adobe Reader","regexpwndclass:=AdobeAcrobat").Activate

Window("regexpwndtitle:=Adobe Reader","regexpwndclass:=AdobeAcrobat").Close

End Function

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In QA Testing when do you use Loadrunner vs QTP? What are the main differences between those two tools? Explain the purpose with real world scenario examples...In advance thank you!!!

2388


Shall we add Local Repository to shared object repository,if yes,how we add

5711


Can anyone pls tell me how to do action parameterization (input and output parameters) with respect to login window and insert order of flight reservation window in detail( pls give a clear step by step explanation with example) anyone please. Will be very thankful to u

1379


How do Parameterization and Data-Driving relate to each other in QTP?

560


Why we use QTP ,We can use other tools like WR OrSilktest What r the options in Qtp that WR and Swilktest Does not have.

1855






QTP script is not working on other's machine..

1541


What is the file extension of the code file in qtp?

563


what is the difference between data driver & data driven and driver script?

2143


In an interview, what r the general questions asked in SQL which is realted to testing ?pls give me anwser to this question?

1445


Can anyone help.i need total excelsheet operations,shortcuts in testing environment from starting onwards....

1434


what r the main attributes of test automation?

1482


how to evalute defects in QTP script?

1492


What are metrics and matrix?

1371


When I click on a link in web page.Link should open in new window.can anyone please let me know the script for this ---Koti

2491


Explain the concept of object repository & how qtp recognizes objects?

574