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):
- Indicate path to image.
- Define new object FileInfo from System.IO namespace:
string imagePath = "D:\\Demo.tif";
FileInfo file = new FileInfo(imagePath); - Identify length of image via length method from FileInfo:
long len = file.Length;
- 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); - Allocate block of memory for array and copy here content:
IntPtr handle = Marshal.AllocHGlobal((int)len);
Marshal.Copy(byteArray, 0, handle, (int)len); - 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); - Process document.
Comments
0 comments
Please sign in to leave a comment.