Knowledge Base

Article ID: 1318 | Category: General Questions | Type: FAQ | Last Modified: 8/27/2015

Using Attachments in FlexiCapture

Available downloads

Description

What is called "Attachment" in the context of FlexiCapture? How can attachments be used? How to add an attachment to a batch/document/page?

Solution

In FlexiCapture 10 files of any format can be added as attachments to batches, documents and pages. Since the system will not process these files in any way, attachments can be used to add material that does not require recognition to batches, documents and pages.

As you probably know, there is an Enable annex pages option in the document assembly settings. Annex pages are included in the document but aren’t processed, just like attachments. However, there is an important difference between annex pages and attachments. Annex pages are simply files that do not require any processing. They are imported with Hot Folder or uploaded from a Scanning Station. Attachments, on the other hand, can have any format, and, more importantly, be the result of operations performed on the document’s pages. Attachments are most commonly used to digitaly sign pages. This is accomplished by attaching a binary file derived from a page’s image to the page when it is scanned on the scanning station (see the project example for details).

The following ways of adding attachments are available:

  1. When importing images from Hot Folder according to settings specified in the description file.
  2. By creating a script that adds attachments on the scanning station.
  3. On the Attachments tab of page, document or batch properties dialog box.
  4. By script using the methods of the IUserAttachment interface.
  5. By using Web Service API.

Let’s examine each of these methods in detail.

1.     An XML description file can be used to attach files to units (batches, documents and images) when they are imported form Hot Folder. You can read more about the structure of these files in FlexiCapture 10’s help (Program Settings -> Description File). To attach a file to a unit, you will need to add a tag <Attachments> to the corresponding element in the xml description file.

<Attachments>
               <Attachment Name="attachment_name">path_to_the_file_relative_to_the_Hot_Folder</Attachment>
</Attachments>

Below is an example of a description file for a batch named Batch. This batch contains 5 images and two attachments. One of them (attachment1) is attached to the batch and the other (attachment2) is attached to the first image in the batch.

Example

2.     A script on a Scanning Station can utilize the IAttachments and IAttachmentByteArray interface methods to attach files to batches, pages and documents (if the batch was separated into documents).

Here is an example of a script that adds an attachment to the last batch in the list of batches:

var batch = Batches(Batches.Count - 1);
var ua = batch.Attachments.AddFromFile("attachment_name", "path_to_file");

3.    The Attachments tab. This tab of the Batch Properties dialog can be used to add attachments. Click the Add… button and specify the path to the file you want to attach. You can also delete an attachment or save it to your hard disk.

 

4.     Script. Files can be attached to pages, documents and batches using methods of the IUserAttachments interface.

You can use event handler scripts to attach files to batches (e.g. during a Batch Creation event) and scripts on scripting stages, when the script’s type is Batch processing. Attachments can also be added to documents and pages during event processing (Document Creation, Page Insertion) and on scripting stages. You can also enable an operator to do all this during the verification stage by creating custom actions (see the project example).

Note that the IUserAttachments.AddNew method creates a new IUserAttachment item without adding it to the collection. To add the item to the collection and make it available for editing, the IUserAttachment.UploadAttachment ( ) method must be called. Here is a very simple way to add an attachment to a document:

IUserAttachment ua = Document.Attachments.AddNew("attachment_name");
ua.FromFile(@"attachment_file_path");
ua.UploadAttachment();

After the files have been attached, they can be edited with other IUserAttachment methods.

5.    API methods can also be used to add and remove attachments from batches, documents and pages. The following methods handle attachments.

GetAttachmentNames

Gets the list of attachments on the Application Server

LoadAttachment

Loads an attachment from the Application Server

RemoveAttachment

Deletes an attachment from the Application Server

SaveAttachment

Saves an attachment to the Application Server

Here is an example of code that creates a new batch, adds an image to the batch, attaches a file to the batch and starts processing:

Sample code

For more information about using Web Services API see the article.

Batches, documents and pages with attachments are indicated by a paperclip in the attachments column:

Next let’s take a look at some projects that make use of attachments.

AddAttachment; JScript

GlobalModule; VBScript

551 people think this is helpful.
Was this information helpful to you?