<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 | Built-in Utilities

ReadySuite provides two static utility classes — ScriptUtil and PdfUtil — that offer common helper methods for file operations, encoding detection, image inspection, and PDF processing.

GetResourcePath

Returns the full path to a resource file on disk, given a document and a resource reference:

C# Copy
var native = document.GetNative();
string fullPath = ScriptUtil.GetResourcePath(document, native);

TryDetectTextFileEncoding

Detects the encoding of a text file. Returns true if the encoding was detected, with the result in the out parameter:

C# Copy
Encoding encoding;
if (ScriptUtil.TryDetectTextFileEncoding(filePath, out encoding))
{
    // Use the detected encoding
    var text = File.ReadAllText(filePath, encoding);
}

GetImageFrameCount

Returns the number of frames in an image file. Useful for detecting multi-page TIFFs:

C# Copy
int frameCount = ScriptUtil.GetImageFrameCount(imageFilePath);
if (frameCount > 1)
{
    script.AddMessage("Multi-frame image detected.");
}

RetrieveDelimitedFileHeaders

Reads the first row of a delimited file and returns the column headers. Requires a ScriptContainer reference for configuration:

C# Copy
var headers = ScriptUtil.RetrieveDelimitedFileHeaders(this, filePath);
foreach (var header in headers)
{
    script.AddMessage(header);
}

PdfUtil

PdfUtil provides methods for reading PDF metadata, manipulating PDF documents, and converting between PDF formats.

Getting a PDF Document

Open a PDF from a file path or from an in-memory stream:

C# Copy
var pdf = PdfUtil.GetPdfDocument(filePath);
var pdf = PdfUtil.GetPdfDocument(stream);

A stream overload accepts a password for encrypted files:

C# Copy
var pdf = PdfUtil.GetPdfDocument(stream, password);

Creating a New PDF Document

C# Copy
var pdf = PdfUtil.GetNewPdfDocument();

Reading PDF Metadata

Retrieve metadata without opening the full document:

C# Copy
var metadata = PdfUtil.GetPdfMetadata(filePath);

Password and stream overloads are also available:

C# Copy
var metadata = PdfUtil.GetPdfMetadata(filePath, password);
var metadata = PdfUtil.GetPdfMetadata(stream);
var metadata = PdfUtil.GetPdfMetadata(stream, password);

IPdfMetadata Properties

Property Type Description
Author string Document author
Creator string Creating application
Keywords string Keywords
Producer string PDF producer
Subject string Document subject
Title string Document title
CreatedDate DateTime Creation date
ModifiedDate DateTime Last modified date
PageCount int Number of pages
IsEncrypted bool Whether the file is encrypted
IsValidPdfFile bool Whether the file is a valid PDF
HasOpenPassword bool Whether a password is needed to open
HasEditPassword bool Whether a password is needed to edit
HasCollection bool Whether the PDF contains a portfolio/collection

IPdfDocument Operations

Once you have an IPdfDocument, you can inspect, convert, optimize, and extract content.

Properties

Property Type Description
IsEncrypted bool Whether the document is encrypted
IsPdfACompliant bool Whether the document is PDF/A compliant
IsPdfUaCompliant bool Whether the document is PDF/UA compliant
Format PdfFormat The document's PDF format

Methods

Method Description
GetPageCount() Returns the number of pages
GetText() Extracts text from the entire document
GetText(PdfTextFormattingMode mode) Extracts text with formatting control
GetPdfFormat() Returns the detected PDF format
GetEmbeddedFileCount() Returns the number of embedded files
Save(string path) Saves the document to a file
CopyPage(IPdfDocument source, int page) Copies a page from another document
Convert(PdfFormat format) Converts to a different PDF format
Validate(PdfFormat format) Validates against a PDF format
Optimize(IPdfOptimizationOptions options) Optimizes the document

Text Extraction

Extract text from the document:

C# Copy
var pdf = PdfUtil.GetPdfDocument(filePath);
string text = pdf.GetText();

Control formatting with PdfTextFormattingMode:

C# Copy
string text = pdf.GetText(PdfTextFormattingMode.Pure);
Mode Description
Raw Preserves the original text order from the PDF stream
Pure Attempts to reconstruct the visual layout
Flatten Returns text with minimal formatting

PDF Optimization

Create optimization options and apply them:

C# Copy
var options = PdfUtil.GetNewOptimizationOptions();
options.CompressImages = true;
options.ImageQuality = 75;
options.RemoveUnusedObjects = true;
options.LinkDuplicateStreams = true;

var pdf = PdfUtil.GetPdfDocument(filePath);
pdf.Optimize(options);
pdf.Save(outputPath);

IPdfOptimizationOptions

Property Type Default Description
RemoveUnusedObjects bool — Remove objects not referenced
RemoveUnusedStreams bool — Remove unused data streams
LinkDuplicateStreams bool — Link identical streams to save space
AllowReusePageContent bool — Allow reuse of identical page content
UnembedFonts bool — Remove embedded fonts
CompressObjects bool — Compress PDF objects
CompressImages bool — Compress image resources
ImageQuality int — JPEG quality (1–100)
ResizeImages bool — Resize images to max resolution
MaxResolution int — Maximum image resolution (DPI)
FastCompression bool — Use faster but less effective compression

PDF Format Conversion

Convert a document to a specific PDF format:

C# Copy
var pdf = PdfUtil.GetPdfDocument(filePath);
pdf.Convert(PdfFormat.PDF_A_1B);
pdf.Save(outputPath);

 The PdfFormat enum includes formats such as PDF_A_1A, PDF_A_1B, PDF_A_2A, PDF_A_2B, PDF_A_3A, PDF_A_3B, and many others. 

Getting a Document's PDF Path

Resolve the path to a document's PDF representation:

C# Copy
string pdfPath = PdfUtil.GetDocumentPdfPath(document);