public final class Redactor extends Object implements Closeable, IPreviewable
Represents a main class that controls document redaction process, allowing to open, redact and save documents.
Learn more
| Constructor and Description |
|---|
Redactor(InputStream document)
Initializes a new instance of
Redactor class using stream. |
Redactor(InputStream document,
LoadOptions loadOptions)
Initializes a new instance of
Redactor class for a password-protected document using stream. |
Redactor(InputStream document,
LoadOptions loadOptions,
RedactorSettings settings)
Initializes a new instance of
Redactor class for a password-protected document using stream and settings. |
Redactor(String filePath)
Initializes a new instance of
Redactor class using file path. |
Redactor(String filePath,
LoadOptions loadOptions)
Initializes a new instance of
Redactor class for a password-protected document using its path. |
Redactor(String filePath,
LoadOptions loadOptions,
RedactorSettings settings)
Initializes a new instance of
Redactor class for a password-protected document using its path and settings. |
| Modifier and Type | Method and Description |
|---|---|
RedactorChangeLog |
apply(Redaction redaction)
Applies a redaction to the document.
|
RedactorChangeLog |
apply(Redaction[] redactions)
Applies a set of redactions to the document.
|
RedactorChangeLog |
apply(RedactionPolicy policy)
Applies a redaction policy to the document.
|
void |
close()
Releases resources.
|
void |
generatePreview(PreviewOptions previewOptions)
Generates preview images of specific pages in a given image format.
|
IDocumentInfo |
getDocumentInfo()
Gets the general information about the document - size, page count, etc.
|
String |
save()
Saves the document to a file with the following options: AddSuffix = true, RasterizeToPDF = true.
|
void |
save(OutputStream document)
Saves the document to a stream.
|
void |
save(OutputStream document,
RasterizationOptions rasterizationOptions)
Saves the document to a stream, including custom location.
|
String |
save(SaveOptions saveOptions)
Saves the document to a file.
|
public Redactor(InputStream document) throws Exception
Initializes a new instance of Redactor class using stream.
document - Source stream of the document
The following example demonstrates how to open a document from stream.
try (InputStream stream = new FileInputStream("C:\\sample.pdf"))
{
try (Redactor redactor = new Redactor(stream))
{
// Here we can use document instance to perform redactions
}
}
Exceptionpublic Redactor(InputStream document, LoadOptions loadOptions) throws Exception
Initializes a new instance of Redactor class for a password-protected document using stream.
document - Source input stream.loadOptions - Options, including password.Exceptionpublic Redactor(InputStream document, LoadOptions loadOptions, RedactorSettings settings) throws Exception
Initializes a new instance of Redactor class for a password-protected document using stream and settings.
document - Source input stream.loadOptions - Options, including password.settings - Default settings for redaction process.Exceptionpublic Redactor(String filePath) throws Exception
Initializes a new instance of Redactor class using file path.
filePath - Path to the file
The following example demonstrates how to open a document for redaction.
try (Redactor redactor = new Redactor("C:\\sample.pdf"))
{
// Here we can use document instance to perform redactions
}
Exceptionpublic Redactor(String filePath, LoadOptions loadOptions) throws Exception
Initializes a new instance of Redactor class for a password-protected document using its path.
filePath - Path to file.loadOptions - Options, including password.Exceptionpublic Redactor(String filePath, LoadOptions loadOptions, RedactorSettings settings) throws Exception
Initializes a new instance of Redactor class for a password-protected document using its path and settings.
filePath - Path to file.loadOptions - File-dependent options, including password.settings - Default settings for redaction process.Exceptionpublic final RedactorChangeLog apply(Redaction redaction)
Applies a redaction to the document.
redaction - An instance of Redaction to applypublic final RedactorChangeLog apply(Redaction[] redactions)
Applies a set of redactions to the document.
redactions - An array of redactions to applypublic final RedactorChangeLog apply(RedactionPolicy policy)
Applies a redaction policy to the document.
policy - Redaction policypublic final void close()
Releases resources.
close in interface Closeableclose in interface AutoCloseablepublic final void generatePreview(PreviewOptions previewOptions) throws Exception
Generates preview images of specific pages in a given image format.
generatePreview in interface IPreviewablepreviewOptions - Image properties and page range settingsExceptionpublic final IDocumentInfo getDocumentInfo() throws Exception
Gets the general information about the document - size, page count, etc.
getDocumentInfo in interface IPreviewableExceptionpublic final String save() throws Exception
Saves the document to a file with the following options: AddSuffix = true, RasterizeToPDF = true.
Exceptionpublic final void save(OutputStream document) throws Exception
Saves the document to a stream.
document - Target streamExceptionpublic final void save(OutputStream document, RasterizationOptions rasterizationOptions) throws Exception
Saves the document to a stream, including custom location.
document - Target streamrasterizationOptions - Options to rasterize or not and to specify pages for rasterizationExceptionpublic final String save(SaveOptions saveOptions) throws Exception
Saves the document to a file.
saveOptions - Options to add suffix or rasterizeExceptionCopyright © 2025. All rights reserved.