Forum Discussion

sameerjade's avatar
sameerjade
Frequent Contributor
8 years ago

PDF comparison - error with Java Class

Hi,
I am learning how to compare PDFs in TestComplete using the PDFBox. When using the function "loadDocument(fileName)", it gives an error on the line "JavaClasses.org_apache_pdfbox_pdmodel.PDDocument.load_3(fileName)".

The error is:

"Object doesn't support this property or method"

I have the required four Java Classes added in TestComplete (image attached).

 

I found a similar thread here where it was mentioned to use an older version of PDFBpx 1.8.12.jar. I am using the latest version 2.0.5.jar. Do I have to go to an older version for this to work? Seems strange..

 

Any suggestions? Thank you.

 

-Sameer

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    You need the older version...  the latest version is not necessarily compatible with the plugins and such for TestComplete.  So, yes... download the older version of PDFBox and then, as indicated in that other thread, you will need to go to where you downloaded the files, right click on the files, select properties, and click the "Unblock" button to tell windows to allow to use the file.

    • sameerjade's avatar
      sameerjade
      Frequent Contributor

      Thank you, Robert. I updated to the older version 1.8.12 and went to dll properties to 'unblock' them. Even after that I am getting the same error at the same point. The error happens in the following line. The issue is with the part "load_3" as TestComplete doesn't recognize load_3. I am not sure where it comes from. This is the line from here. I saw a similar thread here and tried some steps but it does not solve my problem.

      docObj = JavaClasses.org_apache_pdfbox_pdmodel.PDDocument.load_3(fileName);

       

      -Sameer

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        One thing about "load_3" is that this is an overloaded function within PDFBox.... so, within the code of PDFBox there is no actual "load_3", just another load function with a different set of parameters.  TestComplete interprets these overloaded functions as load, load_1, load_2, etc....it's entirely possible that TC, instead of having "load_3" actually has load_2... you will need to examine the objects to determine what is available.