Page Ordering Based on Field Values

  • Last Post 10 February 2019
MarkEMarkEMark posted this 02 February 2019


Suppose I will be scanning batches of multiple documents, where the pages can be completely out of order - even document pages amongst other documents. (e.g. Doc 2 Page 1, Doc 1 Page 2, Doc 1 Page 1, Doc 2 Page 2)

However, on every single page is a page number bar code and a document number bar code that have been successfully read into two bar code fields.

I'm totally comfortable with scripting

Is there a way to script the ordering and separation of batches like this, as early on in the workflow as possible (so a user can run verification with all the documents and pages already in the correct order)?

There are no samples as yet - we are at the design form stage, and are expecting people just shoving all the pages of the household (i.e. multiple docs per envelope) together in any order (as they have historically)


Thanks for any assistance!

MarkEMarkEMark posted this 10 February 2019

I've figured this out myself.

- I created Batch Processing Script workflow stage

- Fields can be read and pages can be moved there.

Here's a script that gathers all the info and shows how to move a page (you need to add as a reference too)


using System.Collections.Generic;

using System.IO;


using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\ABBYYScriptLog.txt")) {

    foreach(IDocument doc in Batch.Documents) {

        file.WriteLine("Doc ID: " + doc.Id + "  Doc Index: " + doc.Index + "  Doc Definition Name" + doc.DefinitionName);


        foreach(IField section in doc.Sections) {

            file.WriteLine("-> Section Name: " + section.Name);

            foreach(IField field in section.Children) {

                file.WriteLine("---> (Field) " + field.Name + " : " + field.Text);




        foreach (IPage page in doc.Pages) {

            file.WriteLine("-> Page: " + page.Id);



        //Comment out this code for creating XML description of each document

        string infoName;

        infoName = @"C:\Doc" + doc.Index + ".xml";





    //test - move fixed

    Batch.MovePage(Batch.Documents[0], Batch.Documents[1], 0, 1);