Forum Discussion

sinduja_venkata's avatar
sinduja_venkata
Occasional Contributor
10 years ago
Solved

Unable to read pdf : “dotNET.org_apache_pdfbox_pdmodel.PDDocument” is null or not an object


Hi,


 


I am trying to read the pdf file using pdfbox dll. I have gone through the threads and have followed the steps mentioned in the following thread:



 


Steps performed:


Downloaded the complete and latest version of PDFBox .NET from here:


http://www.squarepdf.net/pdfbox-in-net and unzipped the archive.


Add the pdfbox-1.8.4.dll file to CLR Bridge.


 


Sample pdf:





Script used: [JScript]


function Test()


{


  var strFileName = "C:\\Work2\\TestComplete-datasheet.pdf";


  var doc = dotNET.org_apache_pdfbox_pdmodel.PDDocument.load(strFileName);


  var pdfStripper = dotNET.org_apache_pdfbox_util.PDFTextStripper.zctor_2();


  var str = pdfStripper.getText_2(doc);


  Log.Message("See Additional Info", str);


}


 


While executing this script, I get this error message: “dotNET.org_apache_pdfbox_pdmodel.PDDocument” is null or not an object.


 


Please find the attachements for the same.


 


Can you please let me know as how to overcome this error message?


 


Thanks.


 

  • HKosova's avatar
    HKosova
    10 years ago

    Update from the Support team: The problem was caused by Windows blocking the files downloaded from the Internet. It was resolved by clicking Unblock in the properties of each of the PDFBox DLLs.

     

    unblock.png

     

     

10 Replies

  • jorgesimoes1983's avatar
    jorgesimoes1983
    Regular Contributor

    Hi! Did you add pdfbox to clr bridge in "tools > current project properties".

     

    It should work.

     

    I have been using it for some time.

     

    I user version 1.8.4 successfully.

     

    By looking at your sreenshots, I see that I use it with 32-bit selected (try that one also)

     

    Suggestion: try with a different path/different file.

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Is your Windows 32-bit or 64-bit? If it's 32-bit, change the CLR Bridge's Preferred architecture option to The same as operating system.

    Does it work if you copy the project to the local folder and open it locally?

    • sinduja_venkata's avatar
      sinduja_venkata
      Occasional Contributor

      Thanks for your responses.

       

      I have tried copying the project folder locally. I did change the architecture to be same as operating system. Mine is a 64 bit machine, so tried to change it to 64 bit to see if it works. But nothing has helped so far.

       

      Any other suggestions??

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        Looks like there's a problem loading the PDFBox DLL or resolving assembly references.

        If you type

        dotNET.

        and press Ctrl+Space, do you see the org_apache_pdfbox_pdmodel namespace in the code completion? Or are there just the standard namespaces (Microsoft_*, System_*, and so on)?

        Does it work if you run TestComplete as administrator?

        If the org_apache_* namespace is missing, try this:

         

        1. Delete and re-add the PDFBox DLL in CLR Bridge.
        2. Change the preferred architecture to 32-bit.
        3. Restart TestComplete and check the code completion again.

        Let us know if this helps.

    • sinduja_venkata's avatar
      sinduja_venkata
      Occasional Contributor
      Thanks everyone. Helen, since the script doesn't seem to work after all this, I have raised a support request. Hoping to get it resolved soon. Thanks for your help.
      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        Update from the Support team: The problem was caused by Windows blocking the files downloaded from the Internet. It was resolved by clicking Unblock in the properties of each of the PDFBox DLLs.

         

        unblock.png