Community

External COM component export C# .NET - FC11 for Invoices

I want to create external component for export written in C# .NET. I used sample export script from ABBYY FlexiCapture 11 HELP and follow all steps described in HELP, but I have some trouble during building DLL file.



Part of script from help:

using System;


using System.Runtime.InteropServices;


using System.IO;


using ABBYY.FlexiCapture;


namespace ExportLibrary1


{


// The interface of the export component which can be accessed from the script


// When creating a new component, generate a new GUID


[Guid("32B10C3B-EEA3-4194-B0A0-E358C310225A")]


[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]


public interface _cExport


{


[DispId(1)]


void ExportDocument(ref IExportDocument DocRef, ref FCTools Tools);


}


// The class that implements export component functionality


// When creating a new component, generate a new GUID


// and set your ProgId


[Guid("3BA19BD7-C6DC-4f63-BC08-0D95254DADC3")]


[ClassInterface(ClassInterfaceType.None)]


[ProgId("ExportLibrary1.Export")]


[ComVisible(true)]


public class Export : _cExport


{


public Export()


{


}


// The function carries out document export: creates an export folder and


// saves in it page image files,


// the text file with document fields, and information about the document


public void ExportDocument( ref IExportDocument docRef, ref FCTools FCTools )


{


try


{


string exportFolder = createExportFolder( docRef.DefinitionName );


exportImages( docRef, FCTools, exportFolder );


// creating the text file


string fileName = exportFolder + "//" + "doc.txt";


StreamWriter sw = File.CreateText( fileName );


// exporting info about document


exportDocInfo( docRef, sw );


// exporting fields


sw.WriteLine( "Fields:" );


exportFields( docRef.Children, sw, "" );


sw.Close();


}


catch( Exception e )


{


docRef.Action.Succeeded = false;


docRef.Action.ErrorMessage = e.ToString();


}


}


}


}



When I try to build DLL I got error :

Error 2 'ref ABBYY.FlexiCapture.FCTools': static types cannot be used as parameters C:\Projects\VBProjects\ExportLibrary1\ExportLibrary1\Class1.cs 34 21 ExportLibrary1



I come from Java world and I don’t know that is possible to send static class as a parameter to the function in C# .NET.
I changed
ref FCTools FCTools as Object Tools in _cExport interface > ExportDocument function and then I can build DLL file and run component too from FC, but now I have a problem with calling static functions of FCTools static class. If I call any function(example: FCTools.ShowMessage(“Test”)) I got [Processing error]: Object reference not set to an instance of an object.





How to solve this problem?



0

Comments

6 comments

  • Avatar
    Anastasiya Nechaeva
    You redefined FCTools static global object by using it as parameter in your function.
    To avoid this error just change the name of parameter to something like FCToolsExt and use this name further.
    But you can also remove this parameter from function and use the global reference to FCTools.


    0
  • Avatar
    mirko.fisic
    I changed ref FCTools FCTools as Object Tools and I try to used global reference, static class FCTools but I got the same error if I call any function of FCTools static class.

    Errorbject reference not set to an instance of an object.


    0
  • Avatar
    Anastasiya Nechaeva
    I think you can remove this parameter from your export script. At the export stage FCTools can be used for creating IExportImageSavingOptions object.
    So you can create this object in FC script and then pass it to your external lib as a parameter.
    In order to create this object at FC side you should use the next code snippet:


    IExportImageSavingOptions exportOptionsObject = FCTools.NewImageSavingOptions();
    exportOptionsObject.Quality = 100;
    exportOptionsObject.Format = "pdf";
    exportOptionsObject.Resolution = 150;

    Please let us know If you need FCTools for other proposes.

    0
  • Avatar
    mirko.fisic
    Thank you very much, also I need FCTools to show message FCTools.ShowMessage("Some Custom Message");


    0
  • Avatar
    Anastasiya Nechaeva
    Mirko, I think our help file contains old description of export script sample. The current version of FC 11 doesn’t allow to use FCTools in the described way. I will inform our developers about this issue. Thank you for your attention!

    In order to see how to use FCTools object please download the project from the link https://www.dropbox.com/sh/moeem5rixoj310g/AABDKEafc03mQatJ_EcxUrboa?dl=0.
    This project shows how to create your own export library and use FCTools.





    0
  • Avatar
    mirko.fisic
    Thank you very much.
    0

Please sign in to leave a comment.