Forum Discussion

Diceman's avatar
Diceman
Occasional Contributor
7 years ago
Solved

Configuring TestComplete to work with PDF files

Hello;

 

I am trying to configure TestComplete to extract text, images and other content from PDF files.   I have followed the Preparation Steps, listed here, but when I run the loadDoucment() function, TestComplete throws an error saying the object doesn't support this property or method.

 

function loadDocument(fileName)
{
  var docObj;

  // Load the PDF file to the PDDocument object
  docObj = JavaClasses.org_apache_pdfbox_pdmodel.PDDocument.load_3(fileName);

  // Return the resulting PDDocument object
  return docObj;
}

 

 I have tried to use both different versions of PDFBox (1.8.13 and 2.0.6), but it doesn't seem to make a difference.  

 

I've also tried to use the code completion functionality built into the TestComplete script editor to "walk" into the classes and methods.   When I do this, it looks like PDDocument is a property of org_apache_pdfbox_pdmodel, but not its own class with child methods and properties.

 

Ultimately, I need to be able to use the PDFBox library functionality, so more information about how to do that would be fantastic, but failing that, perhaps some information to have TestComplete validate the configurations I've made so far and confirm they are correct would also be useful.   To be clear, I copy/pasted the information by hand from the help page, and have manually re-checked all the configurations made in JavaBridge, but I can't see where the given configurations and my local configurations are different.

 

Can anyone help?

  • I believe I have the problem solved - I am now able to see member methods and properties using the code completion function in TestComplete (see attached screenshot).  

     

    I think the root cause of my issue was version incompatibility.   I downloaded and used jars from different PDFBox versions, and I had to go back to 1.8.9 to find a version that worked with TestComplete 10.

6 Replies

    • Diceman's avatar
      Diceman
      Occasional Contributor

      So I've spent a fair amount of time going through your linked document, but I haven't been able to do what I actually need to do yet - which is to create a PDDocument object in order to access a PDF file.

       

      I have discovered that code completion works fine for other lines (see attached screenshot for details - you can see that the code completion context menu shows several flavours of newInstance).   But I can see any properties or methods beneath the PDDocument object of the next line down.

       

      I've experimented with both PDFBox 1.8.13 and PDFBox 2.0.6 jar files.   I've also checked the capitalization of my java classes several times.   I'm stumped.

       

      Any ideas on what I should check next?

      • Diceman's avatar
        Diceman
        Occasional Contributor

        I believe I have the problem solved - I am now able to see member methods and properties using the code completion function in TestComplete (see attached screenshot).  

         

        I think the root cause of my issue was version incompatibility.   I downloaded and used jars from different PDFBox versions, and I had to go back to 1.8.9 to find a version that worked with TestComplete 10.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Can you post screenshots of your java bridge configuration in Tools | Options | Engines and Tools | Current Project Properties?  That will help us make sure.

     

    Double check and make sure that load_3 is the proper method... as the article notes, depending upon how TestComplete reads the overloaded functions, load_3 might be the incorrect method.

    • Diceman's avatar
      Diceman
      Occasional Contributor

      I am using TestComplete 10, if that affects anything.

       

      I've attached screenshots of the Engine Settings and the Java Bridge settings.