QTP doesn’t provide a native support for Adobe pdf. So when comparing two pdf files, I would prefer other tools than can do a much better job. But if you are very sure to use QTP only for this effort, here are some of the broad guidelines to follow:

This sequence is for Adobe Reader 7.0. The steps may vary with other versions.

1) Open the pdf file in selection mode

Compare two PDF files in QTP

 

2) The opening of pdf file in selection mode can be automated by the following combination of key strokes. Alt+t+s+Down Arrow Key +Enter. Automation equivalent:

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"

3) Select the whole text using “Select All”. Automation equivalent:

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

4) Copy the whole selection to the clipboard. Automation equivalent:

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

5) Using FSO with QTP write content to a text file, name it as text “File-1”

6) Repeat the above steps with second file also. name it as text “File-2”

7) Now, using File System Object with QTP –yet again-compare two files line by line. Go through the How to read content from a file? section on the given link.

You might need to create some functions above to save yourself from repeated tasks. If you have any other idea (or a better idea) to compare two pdf files, do let me know through the comments below.

Subscribe To Our Free Newsletter!

Join 41,000+ UFT/QTP Engineers who receive the latest news and updates from our team.

You have Successfully Subscribed!