0 Replies Latest reply on Nov 19, 2010 7:26 AM by deepak venkatachalam

    Challenges with Compare Pdf

    deepak venkatachalam

      Hi Friends

      I am using the following code to compare two versions of pdf in my web application.

      I have the following challenges with it.

      1) I need to suppress the Compare Dialog box that opens on calling DIGSIG:CompareDocuments.

      2)How the output pdf can be shown on the client machine as this is a server code that runs on the server side.Also client machine would not have Acrobat installed on it.

      3)Also how far the output pdf can be customized.Ex,Is there a possiblity to remove the first page of the output pdf.

      Kindly help me out.  Related URLs are welcome

      Thanks in advance. Refer the code below.

      Function

       

       

       

      CompareTwoPdfFiles(ByVal OldFileName As String, ByVal NewFileName As String) As Boolean

       

       

       

       

      Dim AcrobatApp As Acrobat.CAcroApp

      AcrobatApp = CreateObject(

       

      "AcroExch.App")

      AcrobatApp.Show()

       

       

       

      Dim OpenPdfCount As Integer

       

       

      Dim PDSaveFull As Short

       

      OpenPdfCount = AcrobatApp.GetNumAVDocs

       

       

      Dim DocumentWasOpen As Boolean

      DocumentWasOpen = (OpenPdfCount > 0)

       

       

      Dim ok As Boolean

      ok =

       

      True

       

       

      ' Open the "New" file first,

       

       

      ' so it appears on the right side in the comparison output.

       

       

      Dim NewPd As Acrobat.CAcroPDDoc

       

       

      Dim NewAv As Acrobat.CAcroAVDoc

       

       

      If ok Then

      NewPd = CreateObject(

       

      "AcroExch.PDDoc")

      ok = NewPd.Open(NewFileName)

       

       

      If ok Then

      NewAv = NewPd.OpenAVDoc(NewFileName)

       

       

      Else

      MsgBox(

       

      "Could not open PDF file: " & NewFileName)

       

       

      End If

       

       

      End If

       

       

      ' Open the "Old" file second,

       

       

      ' so it appears on the left side in the comparison output.

       

       

      Dim OldPd As Acrobat.CAcroPDDoc

       

       

      Dim OldAv As Acrobat.CAcroAVDoc

       

       

      If ok Then

      OldPd = CreateObject(

       

      "AcroExch.PDDoc")

      ok = OldPd.Open(OldFileName)

       

       

      If ok Then

      OldAv = OldPd.OpenAVDoc(OldFileName)

       

       

      Else

      MsgBox(

       

      "Could not open PDF file: " & OldFileName)

       

       

      End If

       

       

      End If

       

       

      If ok Then

      ok = AcrobatApp.MenuItemExecute(

       

      "DIGSIG:CompareDocuments")

       

       

      If Not ok Then

      MsgBox(

       

      "Could not compare files")

       

       

      End If

       

       

      End If

       

       

       

       

      Dim NoSave As Boolean

      NoSave =

       

      True

       

       

       

       

      If ok Then

       

       

      Dim DiffAv As Acrobat.CAcroAVDoc

      DiffAv = AcrobatApp.GetActiveDoc

       

       

       

       

      Dim DiffPd As Acrobat.CAcroPDDoc

      DiffPd = DiffAv.GetPDDoc

      ok = DiffPd.Save(PDSaveFull,

       

      "C:\Deepak\TED Pdfs\Comparison.pdf")

       

       

      If Not ok Then

       

       

      MsgBox(

       

      "Could not save comparison output file")

       

       

      End If

       

       

      End If

       

      CompareTwoPdfFiles = ok

       

       

      End Function

      Regards

      Deepak.