Document operations

The following Batch restructuring operations are available for the document object.

Delete a Document

Batch.DeleteDocument(ByValpXFolder As CscXFolder, ByVal DocIndex As Long)

By calling this method the specified document is deleted from the given folder (pXFolder) containing that document.

Initially the parent folder of the deleted document is set to invalid.

Copy a Document

Batch.CopyDocument(ByVal pXFolder As CscXFolder, ByVal FromDocIndex As Long, ByVal ToDocIndex As Long)

Batch.CopyDocumentTo(ByVal pFromXFolder As CscXFolder, ByVal FromDocIndex As Long, ByVal pToXFolder As CscXFolder, ByVal ToDocIndex As Long)

A document (FromDocIndex) can be copied inside a folder (pXFolder) or via CopyDocumentTo to another folder (pFromXFolder, pToXFolder) by specifying its new position in the target folder (ToDocIndex). The copied document is a duplicate of the original one, its classification result is retained, and it is initially set to invalid.

Add a Document

Batch.AddDocument(ByVal pParentXFolder As CscXFolder, ByVal ppSourceFilenames() As String, ByVal FileType As CscSourceFileType, ByVal ToDocumentIndex As Long)

A document can be added from files (ppSourceFilenames) to a specified position (ToDocumentIndex) in a folder (pParentXFolder) .Source files containing multiple pages are not supported. The added document does not have any processing results and it is initially set to invalid.

Merge Documents

Batch.MergeDocuments(ByVal pFirstXDocInfo As CscXDocInfo, ByVal pSecondXDocInfo As CscXDocInfo)

A document (pSecondXDocInfo) can be merged to another document (pFirstXDocInfo), the classification result of the first document is retained and the pages of the second document are appended to the first document. Initially the merged document is set to invalid. If the second document is removed from a different folder that folder is also initially set to invalid because a document is removed from its document list.

Move a Document

Batch.MoveDocument(ByValpXFolder As CscXFolder, ByVal FromIndex As Long, ByVal ToIndex As Long)

Batch.MoveDocumentTo(ByVal pFromXFolder As CscXFolder, ByVal FromIndex As Long, ByValpToXFolder As CscXFolder, ByVal ToIndex As Long)

A document can be moved inside a folder (pXFolder) or via MoveDocumentTo also to another folder (pFromXFolder, pToXFolder) by specifying its new position in the target folder (ToIndex). Initially all involved folders are set to invalid.

Split a Document

Batch.SplitDocumentAfterPage(ByVal pXDocInfo As CscXDocInfo, ByVal PageIndex As Long)

A document (pXDocInfo) can be split into two documents, the document is split after the given page (PageIndex). The new document is inserted behind the source document and remains unclassified. This can be changed by applying the ChangeClass method. All data attached to the removed pages stays with the page it belongs to. Fields whose results are connected to the removed or not moved pages are cleared. Initially both new documents are set to invalid.

Create a Document

Batch.CreateDocumentFromPage (pXDocInfo As CscXDocInfo, PageIndex As Long) As Long

Batch.CreateDocumentFromPageTo (pXDocInfo As CscXDocInfo, PageIndex As Long, pToXFolder As CscXFolder, ToDocIndex As Long) As Long

A document can be created from a specified page (PageIndex) and it is added to the end of the document collection the source document (pXDocInfo) belongs to. By calling CreateDocumentFromPageTo also the target folder (pToXFolder) and the position of the created document can be specified. The page the document is created from are removed from the source document. The returned index is the position of the newly created document. These methods are only applicable for documents that have more than one page.

The created document initially does not have a classification result assigned, you can change this by applying the ChangeClass method. Initially both documents, the source and the created one, are set to invalid.

Change a Class

Batch.ChangeClass(ByVal ClassName As String, ByVal pXDocInfo As CscXDocInfo, ByVal bValidate As Boolean)

The class a document (pXDocInfo) is assigned to can be changed by applying this method. The passed name of the class (ClassName) must be a valid classification result. Existing document data may be lost during this operation, if the fields are not existing in the new class, else the results are retained. The document state initially reflects the field state. The validation of the document can be directly forced by setting the flag bValidate to TRUE, then the defined validation rules are applied immediately and the document state is controlled by the validation.

Modifying Document Fields

oXDocInfo.XDocument.Fields.ItemByName("MyField").Text = "MyNewText"

During batch restructuring it is allowed to change document fields. These changes are synchronized back to Kofax Capture. By default, the validation of the batch is re-executed after batch restructuring so that the fields are checked against the defined formatting and validation rules.