How to exclude pages from recognition in FlexiCapture 12 Distributed?


How to exclude pages from recognition?


  1. Advanced workflow is required.
  2. Create an automatic script stage before recognition for batch processing. This script should remove the pages, save them as regular files in a temporary directory, save the name of the temp files and their amount:

    int from=1; // first page is 0
    int to=1;
    Random r = new Random();
    string fileName = "d://temp"+r.Next(1000000).ToString()+"_";

    //let's save the values for restoring

    //save file and remove it from recognition
    for(int i=from;i<count&&i<to;i++){
    Documents[i].SaveAs(fileName + i.ToString() + ".jpg");


  3. Create additional automatic stage after recognition. Here you just need to load saved pages into an already recognized document:

    for(int i=Batch.Properties.Get("from"); i<Batch.Properties.Get("to"); i++){
    string fn = Batch.Properties.Get("fileName") + i.ToString() + ".jpg";
    IEditablePictureObject img = FCTools.LoadImage(fn);


  4. You can see that the second page is a part of the document. The counter in the License Manager has been decreased by one.

Additional information

Using scripts in ABBYY FlexiCapture
Workflow setup

Was this article helpful?

2 out of 2 found this helpful

Have more questions? Submit a request



  • Avatar

    Nikita Shevchenko

    You can use Attachments instead of disk storage. Please use the next code as an example to skip recognition for some particular pages. In the next example, I have sent two images and the second one is skipped. 

    Perhaps we can skip converting to Base64 and attach an image directly. 

    //before recognition batch processing script
    using System;
    using System.Drawing;
    using System.IO;
    using System.Drawing.Imaging;

    //convert to base64
    ImageCodecInfo myImageCodecInfo;
    Encoder myEncoder;
    EncoderParameter myEncoderParameter;
    EncoderParameters myEncoderParameters;

    string mimeType = "image/jpeg";
    int j;
    ImageCodecInfo[] encoders;
    encoders = ImageCodecInfo.GetImageEncoders();
    for(j = 0; j < encoders.Length; ++j)
    if(encoders[j].MimeType == mimeType){
        myImageCodecInfo =  encoders[j];

    myEncoder = Encoder.Quality;
    myEncoderParameters = new EncoderParameters(1);
    myEncoderParameter = new EncoderParameter(myEncoder, 25L);
    myEncoderParameters.Param[0] = myEncoderParameter;

    System.Drawing.Image image = System.Drawing.Image.FromHbitmap((System.IntPtr)Documents[1].Pages[0].Picture.Handle, (System.IntPtr)Documents[1].Pages[0].Picture.hPal);

    FCTools.ShowMessage("Image has been created:"+(image==null).ToString());
    using (MemoryStream m = new MemoryStream())
    FCTools.ShowMessage("Saving stream");
    //image.Save(m, image.RawFormat,myEncoderParameters);
    image.Save(m, System.Drawing.Imaging.ImageFormat.Jpeg);
    byte[] imageBytes = m.ToArray();
    // Convert byte[] to Base64 String
    string base64String = Convert.ToBase64String(imageBytes);

    //add an attachment
    var t = Documents[0].Attachments.AddNew("image");
    t.AsString = base64String;

    }catch(Exception ex){FCTools.ShowMessage("Exception "+ex.Message);}

    //after Recognition batch processing script
    using System;
    using System.Drawing;
    using System.IO;

    //read an attachment
    string base64String = Documents[0].Attachments.Get("image").AsString;
    Bitmap bmpReturn = null;
                //Convert Base64 string to byte[]
                FCTools.ShowMessage("converting bytes");
                byte[] byteBuffer = Convert.FromBase64String(base64String);
                MemoryStream memoryStream = new MemoryStream(byteBuffer);

                memoryStream.Position = 0;
    FCTools.ShowMessage("Converting stream");
                bmpReturn = (Bitmap)Bitmap.FromStream(memoryStream);
                FCTools.ShowMessage("creating picture");
      IPictureObject po = FCTools.PictureFromHBitmap( bmpReturn.GetHbitmap().ToInt32() );
    FCTools.ShowMessage("adding image");

                memoryStream = null;
                byteBuffer = null;
  • Avatar

    Daniel Salazar

    Hi, thanks for sharing this example.

    Correct me if I am wrong, but this script would only work if the whole document is separated into pages. And there is only one document in the batch?

    Is there a way to do this but instead have several documents in one batch? These documents are already assembled.


    Best regards


Please sign in to leave a comment.