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,
RasterizationOptions rasterizationOptions)
Saves the document to a stream, including custom location.
|
String |
save(SaveOptions saveOptions)
Saves the document to a file.
|
public 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
}
Exception
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
}
}
Exception
public 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.Exception
public 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.Exception
public 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.Exception
public 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.Exception
public final void close()
Releases resources.
close
in interface Closeable
close
in interface AutoCloseable
public 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 String save() throws Exception
Saves the document to a file with the following options: AddSuffix = true, RasterizeToPDF = true.
Exception
public final String save(SaveOptions saveOptions) throws Exception
Saves the document to a file.
saveOptions
- Options to add suffix or rasterizeException
public 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 rasterizationException
public final void generatePreview(PreviewOptions previewOptions) throws Exception
Generates preview images of specific pages in a given image format.
generatePreview
in interface IPreviewable
previewOptions
- Image properties and page range settingsException
public final IDocumentInfo getDocumentInfo() throws Exception
Gets the general information about the document - size, page count, etc.
getDocumentInfo
in interface IPreviewable
Exception