Friday 17 October 2008

Accessing Toolkit 4.0 as a reference via COM Interop in .NET

ProductVersion   
Toolkit Lite
Toolkit Std
Toolkit Pro
4.0
 
Description
 
In certain implementations, you may not be able to instantiate Toolkit in .NET using the provided APToolkitNET.dll. It is possible to access Toolkit using a COM Interop in these situations.
 
Details
 

Referencing the APToolkit 4.0 Type Library

You must add a reference to the APToolkit 4.0 Type Library to use Toolkit as a COM interop in .NET. If the reference is incorrect or missing, the resultant script will cause a missing type or namespace error. Use the following steps to a reference to the type library:

 

  1. Start Visual Studio® .NET.
  2. In the Solution Explorer, right-click Reference, and then select Add Reference.
  3. In the Add Reference dialog, click COM.
  4. On the COM tab, select the APToolkit 4.0 Type Library, and then click OK


Instantiating the Objects in C#

You can instantiate the objects via COM interop after referencing the APToolkit 4.0 Type Library in the project. The following instructions provide the necessary steps for C#:

NOTE: These instructions cover the instatiation of the Toolkit 4.0 Professional Edition objects. These objects may not be available in the Standard or Lite editions.


 

  1. Add the following line to the beginning of your .NET code:
  2.  

    using APTOOLKITLib;

     

  3. Add one of the following declarations depending on your implementation:
    •  

    • Global Scope
    •  

      public static APTOOLKITLib.APToolkitClass TK = newAPTOOLKITLib.APToolkitClass();

       

    • Local
    •  

      APTOOLKITLib.APToolkitClass TK = newAPTOOLKITLib.APToolkitClass();
  4. Instantiate the object, using the syntax that pertains to the object you are using:
  5. NOTE: The following instructions assume you are using a Local declaration

       

    • To instantiate the Toolkit object:
    •  

      // Instantiate Toolkit object.
      APTOOLKITLib.APToolkitClass TK = newAPTOOLKITLib.APToolkitClass();

       

    • To instantiate the FieldInfo object:
    •  

      long r;
      // Instantiate Toolkit object.
      APTOOLKITLib.APToolkitClass TK = newAPTOOLKITLib.APToolkitClass();
      // A valid PDF must be opened as input
      r = TK.OpenInputFile("input.pdf");
      // Instantiate FieldInfo Sub-object. 
      // Must specify name and instance of field.
      PDFFieldInfo FIO = TK.FieldInfo("fieldname", 1);

       

    • To instantiate the Text2PDF object:
    •  

      // Instantiate Text2PDF Sub-object.
      Text2PDF T2P = new Text2PDF

       

    • To instantiate the ListItems object:
    •  

      long r;
      // Instantiate Toolkit object.
      APTOOLKITLib.APToolkitClass TK = newAPTOOLKITLib.APToolkitClass();
      // A valid PDF must be opened as input
      r = TK.OpenInputFile("input.pdf");
      // Instantiate FieldInfo Sub-object. 
      // Must specify name and instance of field.
      PDFFieldInfo FIO = TK.FieldInfo("fieldname", 1);
      // Instantiate ListItems Sub-object. 
      ListItems LST = FIO.ListItems();

       

    • To instantiate the Explorer object:
    •  

      long r;
      // Instantiate Toolkit object.
      APTOOLKITLib.APToolkitClass TK = newAPTOOLKITLib.APToolkitClass();
      // A valid PDF must be opened as input
      r = TK.OpenInputFile("input.pdf");
      // Instantiate Explorer Sub-object.
      TKExplorerObject EXP = TK.Explorer();

       

    • To instantiate the Barcode object:
    •  

      // Instantiate Barcode object.
      APTKBarcodeObject BCD = new APTKBarcodeObject

       

    • To instantiate the Flash object:
    •  

      // Instantiate Flash object.
      TKFlashObject FLSH = new TKFlashObject


Additional Considerations


 

If you are using C# as the scripting language on an ASPX page, you will need to use aCodebehind property. More information can is available in the Microsoft® knowledge base article located at http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b321748.

CAUTION: The information provided by this source is not regulated or guaranteed by activePDF, and is subject to change without notice. We strongly recommend that you read all posted warnings and cautions provided by this source, prior to implementing any recommend changes.

No comments: