Working with Resources |
Documents in ReadySuite can have three types of resources: natives (the original file), pages (images produced during processing), and text (extracted or OCR text). All three share a common base — ResourceFileItem — which provides path and file-extension properties.
Every resource type exposes these properties:
| Property | Description |
|---|---|
| FileFolder | Folder path relative to the root |
| FileName | File name including extension |
| FileExtension | Extension (e.g. .pdf, .tif) |
| FilePath | Relative path (folder + file name) |
| RootPath | Absolute root path on disk |
| GetFullPath() | Returns the full absolute path to the file |
A NativeItem is the original source file for a document (e.g. a Word document, PDF, or email).
if (document.HasNative()) { var native = document.GetNative(); var fullPath = native.GetFullPath(); var extension = native.FileExtension; }
Create a new native reference and assign it:
var newNative = document.GetNewNative(newFilePath);
document.SetNative(newNative);
script.UpdateDocument(document);document.RemoveNative(); script.UpdateDocument(document);
Pages are image files (typically TIFF or JPEG) associated with a document. Each PageItem carries metadata about dimensions, resolution, and color.
if (document.HasPages()) { var pages = document.GetPages(); int count = document.GetPageCount(); foreach (var page in pages) { var path = page.GetFullPath(); int width = page.Width; int height = page.Height; } }
| Property | Type | Description |
|---|---|---|
| Identifier | string | Page identifier (e.g. bates number) |
| Prefix | string | Identifier prefix |
| Padding | int | Zero-padding length |
| Counter | long | Numeric counter value |
| Width | int | Image width in pixels |
| Height | int | Image height in pixels |
| ResolutionX | int | Horizontal DPI |
| ResolutionY | int | Vertical DPI |
| BitDepth | int | Color depth |
| HasColor | bool? | Whether the image contains color |
| IsBlank | bool? | Whether the page is blank |
| PixelFormat | string | Pixel format description |
| TiffCompression | string | TIFF compression type |
var page = document.GetNewPage("IMG-0001", pageFilePath); document.AddPage(page); script.UpdateDocument(document);
Remove a specific page or clear all pages:
document.RemovePage(page); script.UpdateDocument(document);
document.ClearPages(); script.UpdateDocument(document);
After adding or removing pages, call ReassignPageNumbers() to renumber them sequentially:
document.ReassignPageNumbers(); script.UpdateDocument(document);
Use IsMultiFrame() to check whether a document's native file contains multiple image frames (e.g. a multi-page TIFF):
if (document.IsMultiFrame()) { // Native contains multiple image frames }
var first = document.GetFirstPage(); var last = document.GetLastPage();
These are useful for reading bates ranges — BatesBeg and BatesEnd on DocumentItem are derived from the first and last page identifiers.
TextItem resources hold extracted or OCR text for a document. A document can have multiple text files.
if (document.HasText()) { int count = document.GetTextCount(); var textItems = document.GetText(); // Returns List<TextItem> foreach (var text in textItems) { var path = text.GetFullPath(); } }
var textItem = document.GetNewText(textFilePath);
document.AddText(textItem);
script.UpdateDocument(document);SetText() replaces all existing text with a single text resource:
var textItem = document.GetNewText(newTextFilePath);
document.SetText(textItem);
script.UpdateDocument(document);Remove a specific text resource or clear all text:
document.RemoveText(textItem); script.UpdateDocument(document);
document.ClearText(); script.UpdateDocument(document);
This example reads each document's native, checks its extension, and logs the page count:
public override void Run(IScriptContext script) { base.Run(script); while (script.ReadDocument()) { var document = script.Document; if (document.HasNative()) { var native = document.GetNative(); script.AddMessage(string.Format("{0}: {1}", document.DocId, native.FileExtension)); } if (document.HasPages()) { document.SetFieldData(options.PageCountField, document.GetPageCount().ToString()); script.UpdateDocument(document); } } }