How to process office format documents in FineReader Engine 12?

Question

How to process office format files, such as docx, rtf, txt in FineReader Engine 12?

Answer

From storage 

It is same as work with pdf documents: FRDocument >AddImageFile with path to image and page Indices.

From memory

It's not implemented yet. But It is possible to load image-related formats by following steps (C# example):

  1. Indicate path to image.
  2. Define new object FileInfo from System.IO namespace:
    string imagePath = "D:\\Demo.tif";
    FileInfo file = new FileInfo(imagePath);
  3. Identify length of image via length method from FileInfo:
    long len = file.Length;
  4. Open image in binary view via BinaryReader from System.IO namespace and read bytes to bytes array:
    BinaryReader br = new BinaryReader(File.Open(imagePath, FileMode.Open));
    byte[] byteArray = br.ReadBytes((int)len);
  5. Allocate block of memory for array and copy here content:
    IntPtr handle = Marshal.AllocHGlobal((int)len);
    Marshal.Copy(byteArray, 0, handle, (int)len);
  6. Use AddImageFileFromMemory method of FRDocument to load file from memory and don't forget to free allocated memory:
    document.AddImageFileFromMemory((Int64)handle, null, null, null, "Demo.tif");
    Marshal.FreeHGlobal(handle);
  7. Process document.

 

 

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.

Recently viewed