<img height="1" width="1" style="display:none;" alt="" src="https://px.ads.linkedin.com/collect/?pid=6889170&amp;fmt=gif">
Skip to content
  • There are no suggestions because the search field is empty.

Overview | 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.

ResourceFileItem (Common 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

Natives

A NativeItem is the original source file for a document (e.g. a Word document, PDF, or email).

Checking and Reading

C# Copy
if (document.HasNative())
{
    var native = document.GetNative();
    var fullPath = native.GetFullPath();
    var extension = native.FileExtension;
}

Replacing a Native

Create a new native reference and assign it:

C# Copy
var newNative = document.GetNewNative(newFilePath);
document.SetNative(newNative);
script.UpdateDocument(document);

Removing a Native

C# Copy
document.RemoveNative();
script.UpdateDocument(document);

Pages

Pages are image files (typically TIFF or JPEG) associated with a document. Each PageItem carries metadata about dimensions, resolution, and color.

Checking and Reading

C# Copy
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;
    }
}

Page Properties

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

Adding Pages

C# Copy
var page = document.GetNewPage("IMG-0001", pageFilePath);
document.AddPage(page);
script.UpdateDocument(document);

Removing Pages

Remove a specific page or clear all pages:

C# Copy
document.RemovePage(page);
script.UpdateDocument(document);
C# Copy
document.ClearPages();
script.UpdateDocument(document);

 

Reassigning Page Numbers

After adding or removing pages, call ReassignPageNumbers() to renumber them sequentially:

C# Copy
document.ReassignPageNumbers();
script.UpdateDocument(document);

Multi-Frame Detection

Use IsMultiFrame() to check whether a document's native file contains multiple image frames (e.g. a multi-page TIFF):

C# Copy
if (document.IsMultiFrame())
{
    // Native contains multiple image frames
}

First and Last Page

C# Copy
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.

Text

TextItem resources hold extracted or OCR text for a document. A document can have multiple text files.

Checking and Reading

C# Copy
if (document.HasText())
{
    int count = document.GetTextCount();
    var textItems = document.GetText();  // Returns List<TextItem>

    foreach (var text in textItems)
    {
        var path = text.GetFullPath();
    }
}

Adding Text

C# Copy
var textItem = document.GetNewText(textFilePath);
document.AddText(textItem);
script.UpdateDocument(document);

Replacing Text

SetText() replaces all existing text with a single text resource:

C# Copy
var textItem = document.GetNewText(newTextFilePath);
document.SetText(textItem);
script.UpdateDocument(document);

Removing Text

Remove a specific text resource or clear all text:

C# Copy
document.RemoveText(textItem);
script.UpdateDocument(document);
C# Copy
document.ClearText();
script.UpdateDocument(document);

 

Full Example

This example reads each document's native, checks its extension, and logs the page count:

C# Copy
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);
        }
    }
}