0

I need to use PDFbox dll in QTP vbscript , initially I tried to convert PDFbox jar to respective PDFbox dll with help of ikvmbin-7.2.4630.5, it was successfully so that i can use pdfbox.dll in c# and VB.NET similarly i need to use it with vbscript - QTP . Initially tried to access the converted PDFbox.dll using DotNetFactory.CreateInstance

Set TestPDFDoc = DotNetFactory.CreateInstance("org.apache.pdfbox.pdmodel.PDDocument","D:\\PDF\\PDF\\pdfbox-1.7.1.dll")

while executing it throws me but it throws me Type 'org.apache.pdfbox.pdmodel.PDDocument' not found in any loaded assembly

can anyone help me out Thanks

Ganeshja
  • 2,675
  • 12
  • 36
  • 57
  • 1
    do you actually need to escape backslashes in the dll path? –  Feb 05 '13 at 14:22
  • Yes i need to provide the path for DLL since its a custom DLL converted from jar to dll using IVKM – Ganeshja Feb 05 '13 at 14:52
  • 2
    but do you need to escape the backslash, ie use `\\ ` instead of just `\ `? I don't know QTP, but in VBScript, you don't need to escape backslashes. –  Feb 05 '13 at 16:06
  • still it throws similar kind of error message : Could not load file or assembly 'file:///D:\PDF\PDF\pdfbox-1.7.‌​1.dll' or one of its dependencies. The system cannot find the file specified. – Ganeshja Feb 06 '13 at 05:02
  • Try removing the `file://` part does `"D:\PDF\PDF\pdfbox-1.7.1.dll"` work? – Motti Feb 06 '13 at 09:05

2 Answers2

3

I don't think you need to escape the backslashes, ie use \\ instead of just \ ? I don't know QTP, but in VBScript, you don't need to escape backslashes.

Ie try

Set TestPDFDoc = _
    DotNetFactory.CreateInstance("org.apache.pdfbox.pdmodel.PDDocument", _
                                 "D:\PDF\PDF\pdfbox-1.7.1.dll")
0

Most likely, the error occurs because one or more assemblies referenced by your .dll could not be found. Use a .NET dependency viewer tool (for example, the open-source ILSpy) to determine the referenced assemblies and place them to the same folder as pdfbox-1.7.1.dll. I guess you need to place some of the IKVM.NET assemblies next to your .dll.

Community
  • 1
  • 1
Helen
  • 87,344
  • 17
  • 243
  • 314
  • @Thanks helen for u r response ! do u have any idea how to place IVKM.NET.core.dll next to our dll , I tried with Set TestPDFDoc = _ DotNetFactory.CreateInstance("org.apache.pdfbox.pdmodel.PDDocument", "D:\PDF\PDF\pdfbox-1.7.1.dll","D:\ikvmbin-7.2.4630.5\ikvm-7.2.4630.5\bin\IKVM.OpenJDK.Core.dll") but it too fails so – Ganeshja Feb 06 '13 at 11:48
  • @Ganeshja: Copy all the needed assemblies to the *D:\PDF\PDF* folder. – Helen Feb 06 '13 at 12:20