Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare of 2 PDF files in QTP - problem

Status
Not open for further replies.

18041984

Technical User
Jan 23, 2008
3
US
Hello,

I have a problem with my application, I have to create a test that have to compare a generated report ( application uses a jreport framework) and this generated report after export to PDF file I have to compare to my expected result file but I don't know how to do this. Have some one of you any idea ?

Thanks
Robert
 
It's possible to so it in WR using the file_compare function.

If you have QTP, you should have WR as well, since Mercury now packages the two together. If you can't find anything in QTP's FileSystemObject which will allow this, write a small function in WR along the lines of the following and call it from QTP:

Code:
public function FileComparison(in File1, inFile2, out Result)
{
    auto SaveFile = "Somefile in which the compared files are saved for future viewing."

    Result = file_compare(File1, File2, SaveFile, 0);

    return(Result);
}

That would call the function, compare the files and return the Result to you (0 = successful, other values = failed)

Cheers,
Dave

"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

For all your testing needs: Forum1393
 
This should works - but I would like to compare the content of each documents - formating, fonts size and all this possible things that could be changed - your's resolution will works okey - but what if in file were change 1 char to other ?


Thanks
Robert
 
This function opens both files and compares them directly. Every character is checked. I'm not 100% certain on the formatting, but give it a try and see.

If one character is different, the result will show that, and from the test results you'll be able to pull the SaveFile up which will illustrate where differences are...

Cheers,
Dave

"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

For all your testing needs: Forum1393
 
PDF content can be dumped into another app more visible to QTP, like NotePad, and then compared...but this is only CONTENT, not format. Otherwise, direct access to the Adobe PDF API costs $$$$.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top