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

On Friday, December 19, 2014 8:46:14 AM UTC-5, nids wrote:

> Hi Parke,
>  
> Can you suggest me that how you have automated Diff PDF using QTP.
>  
> Thanks,
> Nidhi 
> On Tue, Dec 2, 2014 at 8:01 PM, Parke Kuntz <parke...@gmail.com 
> <javascript:>> wrote:
>>
>> 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
>>
>>
>> On Tue, Dec 2, 2014 at 8:00 AM, Nidhi Sharma <nidhii...@gmail.com 
>> <javascript:>> wrote:
>>
>>> Hi,
>>>
>>> Can anyone suggest me how to so PDF content comparison using UFT 11.5.
>>>
>>> Thanks,
>>> Nidhi
>>>
>>> -- 
>>> -- 
>>> 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 
>>> <javascript:>
>>> To unsubscribe from this group, send email to
>>> mercuryqtp+...@googlegroups.com <javascript:>
>>> 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 <javascript:>.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Parke
>> Cell: 770-842-0121
>>  
>> -- 
>> -- 
>> 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 
>> <javascript:>
>> To unsubscribe from this group, send email to
>> mercuryqtp+...@googlegroups.com <javascript:>
>> 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 <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
-- 
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 MercuryQTP@googlegroups.com
To unsubscribe from this group, send email to
mercuryqtp+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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.


'       Used SystemUtil.Run to open cdm
SystemUtil.Run "cmd.exe","","path\diff-pdf-2012-02-28","open"

'       And then I called the following function.
ComparePDF_2(sFolder1,sFolder2)


sub comparePDF_2(sFolder1,sFolder2)
        Dim fso, files, startTime, endTime, wshShell, folder1, files1, folder2, 
files2, numFiles1

        startTime = timer()

        Set WshShell = CreateObject("WScript.Shell")
        Set fso = createobject("scripting.FileSystemObject")
        
        Set folder1 = fso.GetFolder(sFolder1)
        Set folder2 = fso.GetFolder(sFolder2)
        
        Set files1 = folder1.files
        Set files2 = folder2.files
        
        numfiles1 = files1.count
        numFiles2 = files2.Count
        
        print "numfiles1 = " & numFiles1
        print "numfiles2 = " & numFiles2
        If numFiles1 <> numfiles2 Then
                print "PROBLEM, the number of files are not equal"
        Else
                print "The number of files in the two folders are the same, " & 
numfiles1
        End If
        print ""
        
        Set ListDict1 = 
Dotnetfactory.CreateInstance("System.Collections.Specialized.ListDictionary")
        Set ListDict2 = 
Dotnetfactory.CreateInstance("System.Collections.Specialized.ListDictionary")
        Set myEnum1 = 
DotnetFactory.CreateInstance("System.Collections.IDictionaryEnumerator") 
        Set myEnum2 = 
DotnetFactory.CreateInstance("System.Collections.IDictionaryEnumerator") 
        
''**name of pdf file is the key
        i = 1
        For each item1 in files1
                listDict1.add i,item1 & "::" & item1.size
                i = i + 1
        Next

        k = 1
        For each item2 in files2
                listDict2.add k,item2 & "::" & item2.size
                k = k + 1
        Next
        
        Set dr = CreateObject("Mercury.DeviceReplay")
        
        Set myEnum1 = listDict1.getEnumerator
        Set myEnum2 = ListDict2.getEnumerator
        While myEnum1.movenext
                myEnum2.MoveNext
                flag = 0
                cnt_loop_times = 0
                If Instr(myEnum1.value,"db") Then
                        
                Else
                        print myEnum1.key & "::" & myEnum1.value
                        print myEnum2.key & "::" & myEnum2.value
                        wait(1)
                        Window("cmd").Activate
                        wait(1)
                        Window("cmd").Type "diff-pdf.exe --verbose --view " & 
chr(34) & split(myEnum1.value,"::")(0) & """" & " """ & 
split(myEnum2.value,"::")(0) & """"
                        Window("cmd").Type micReturn
                        wait(1)
                        dr.MouseMove 100, 400                   
                        var = window("Differences between 
C:\\Data\\QT").WinStatusBar("WinStatusBar").GetROProperty("text")
                        Do
                                ''** bottom left of the screen has something 
similar to 
                                ''** Page 1 of 3; 1 of them is different OR 0 
of them is different
                                ''** This loop runs until the comparison of the 
two files is complete
                                ''** that is, the word "them" appears
                                If InStr(var,"them") Then
                                        flag = 1
                                Else
                                        cnt_loop_times = CInt(cnt_loop_times) + 
1
                                        wait(1)
                                        dr.MouseMove 300, 600
                                End If
                                dr.MouseMove 50, 400
                                var = window("Differences between 
C:\\Data\\QT").WinStatusBar("WinStatusBar").GetROProperty("text")
                        Loop until flag = 1
                        print "flag = " & flag & ", cnt_loop_times = " & 
cnt_loop_times
                        print "status bar = " & var
                        
                        arr = split(var,"; ")
                        
                        numDiff = split(arr(1)," of")
                        
                        print "numDiff = " & numDiff(0)&":"
                        
                        If CInt(numDiff(0)) = 0 Then
                                msg = "Pdf files are identical" 
                                print msg
                        Else
                                msg = "PDF files differ"
                                print msg
                        End If                  
                        
                        Window("Differences between C:\\Data\\QT").Close
                        If split(myEnum1.value,"::")(1) <> 
split(myEnum2.value,"::")(1) Then
                                print "size differs " & 
split(myEnum1.value,"::")(1) & " <> " & split(myEnum2.value,"::")(1)
                                print "difference = " & 
split(myEnum1.value,"::")(1) - split(myEnum2.value,"::")(1)
                        End If  
                End If
                print""
        Wend
        endTime = timer()
        print "total time = " & FormatNumber(EndTime - StartTime, 2)    
        print "-------------------"
        print ""
End Sub

-- 
-- 
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 MercuryQTP@googlegroups.com
To unsubscribe from this group, send email to
mercuryqtp+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to