PDF Comparison

359 views
Skip to first unread message

Nidhi Sharma

unread,
Dec 2, 2014, 8:11:19 AM12/2/14
to mercuryqtp
Hi,

Can anyone suggest me how to so PDF content comparison using UFT 11.5.

Thanks,
Nidhi

Parke Kuntz

unread,
Dec 2, 2014, 9:37:13 AM12/2/14
to QTP - HP Quick Test Professional - Automated Software Testing
Nidhi:

To check if two PDF files are identical, download diff-pdf-2012-02-28.zip.  The windows version is not as good as the UNIX version but it works.

I used QTP to automate the running of diff-pdf-2012-02-28.

I was only concerned whether or not the two files were identical and not where the differences occurred or the number of discrepancies.

hth,


Parke


--
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

---
You received this message because you are subscribed to the Google Groups "QTP - HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mercuryqtp+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Parke

Gaurav Gupta

unread,
Dec 16, 2014, 5:45:05 AM12/16/14
to mercu...@googlegroups.com, Mercu...@googlegroups.com
Hi,

I think in this Comparison, You can use Image.GetVisibleText Property.  It will allow you to check the characters of pdf if containing less then 255 chars.

Also you can use Bitmap check Checkpoint because pdf will be recognized by QTP as plain Image.

Thanks

shanker

unread,
Dec 17, 2014, 12:17:37 AM12/17/14
to mercu...@googlegroups.com
Hi,

Here is how you can implement the pdf comparison without using the UFT's pdf checkpoint.:

  1. Open the reference PDF
  2. Using 'SendKeys' method of Wscript, select all and copy the content to clipboard (Ctrl+A and Ctrl+C)
  3. Create a notepad using FSO and paste (Ctrl+V) the copied content in to the notepad save it.
  4. Close the reference pdf and notepad
  5. Open the pdf to be compared and repeat steps 2 - 4 with a second notepad created.
  6. Create two FSO objects, copy open the two notepads.
  7. Compare these two notepads line by line.
  8. If there are any dynamic values like name, phone number, you should create a permanent template of reference notepad and make use of RegEx object to deal with the comparison so that you can check for the pattern of the dynamic values.
  9. you better create modular functions for each of the above operation and use them.


The UFT's pdf check point also works on the same logic, but I didn't use it so far as I had to implement this logic before the feature was introduced.

Note: the copied content on the notepad may not be in the same order as that of pdf.

You can reach me if you have any questions on the above approach.
Also please reply if it worked for you.

Thanks,
Shanker.

--
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

---
You received this message because you are subscribed to the Google Groups "QTP - HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mercuryqtp+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Shanker.

Akhalesh Yadav

unread,
Dec 17, 2014, 1:07:55 AM12/17/14
to mercu...@googlegroups.com

It is a best solution. Thanks shankar.

Nidhi Sharma

unread,
Dec 18, 2014, 5:20:27 AM12/18/14
to mercuryqtp
Hi,
 
Thanks for your suggestion but it doesn't work for me,as I copy the content from PDF to text file,the file data becomes irrelevent to me as it doen't show the data in the same format as displayed in PDF
For eg:I have tables in PDF file and as soon as I copy them in Text file,the table data is not shown correctly.
So cannot go for this option.
 
Is there any other way my problem can be solved.

shanker

unread,
Dec 18, 2014, 7:09:39 AM12/18/14
to mercu...@googlegroups.com
Nidhi,
 
If you want to check the format (like tables and images), I guess there is no solution as of now.
You can compare the content of the PDF though it doesn't copy the content in the same sequence/format as that in the PDF (I had added a note for this).
Please feel free to ask any further questions.
 
Thanks,
Shanker

Nidhi Sharma

unread,
Dec 19, 2014, 8:46:14 AM12/19/14
to mercuryqtp
Hi Parke,
 
Can you suggest me that how you have automated Diff PDF using QTP.
 
Thanks,
Nidhi

Nikhil Gangwar

unread,
Dec 19, 2014, 9:46:29 AM12/19/14
to mercu...@googlegroups.com

Hi Nidhi,

My recommendation would be to save both PDF as text (there is an option already) after that you can compare using writing your code using FSO. Long back, i had worked on one assignment where PDF invoices we had to compare during regression. I had used this technique and it worked very well smoothly. Let me know if you have further query.

Thanks
Nikhil Gangwar

Parke

unread,
Dec 22, 2014, 11:06:54 AM12/22/14
to mercu...@googlegroups.com

Nids:

The pdf files I needed to compare were in separate folders, folder1 and folder2. My naming is very simple minded. Each folder should have the same number of files.
' The names in folder1 and folder2 should be identical
'  used mousemove to "activate" the comparison form that opens up from cmd line
' window("Differences between C:\\Data\\QT").Activate did not always work
'  moving the mouse "activated" the form everytime.
'  manually open cmd to where diff-pdf-2012-02-28 is installed.
' format for entering the files to be compared is:
' C:\downloads\diff_pdf\diff-pdf-2012-02-28>diff-pdf.exe --verbose --view "path for file1","path for file2"
' In my comparisons, usually if there files were not identical there was also a file size difference.
' This is why I used the dictionaries.
' I used the dotnet dictionaries as dotnet has several specialized dictionaries which can come in handy.
The code is attached.
 
hth,
 
Parke
comparePDF_2.txt

Anil Kumar V

unread,
Jan 7, 2015, 4:07:24 AM1/7/15
to mercu...@googlegroups.com, Mercu...@googlegroups.com
Hi,

Please go through this link which is very useful for PDF comparison,
http://www.learnqtp.com/learnquicktestpdf-api-manipulating-pdfs-in-qtp/

Regards,
Anil Kumar V


On Tuesday, December 2, 2014 6:41:19 PM UTC+5:30, nids wrote:
Reply all
Reply to author
Forward
0 new messages