Redactor
Leave feedback
On this page
Inheritance: java.lang.Object
All Implemented Interfaces: java.io.Closeable, com.groupdocs.redaction.integration.IPreviewable
public final class Redactor implements Closeable, IPreviewable
Represents a main class that controls document redaction process, allowing to open, redact and save documents.
Learn more
- More details about applying redactions: Redaction basics
- More advanced redaction topics: Advanced usage
| Constructor | Description |
|---|---|
| Redactor(String filePath) | Initializes a new instance of |
| Redactor | |
| class using file path. | |
| Redactor(InputStream document) | Initializes a new instance of |
| Redactor | |
| class using stream. | |
| 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. | |
| 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. | |
| Method | Description |
|---|---|
| close() | Releases resources. |
| apply(Redaction redaction) | Applies a redaction to the document. |
| apply(Redaction[] redactions) | Applies a set of redactions to the document. |
| apply(RedactionPolicy policy) | Applies a redaction policy to the document. |
| save() | Saves the document to a file with the following options: AddSuffix = true, RasterizeToPDF = true. |
| save(SaveOptions saveOptions) | Saves the document to a file. |
| save(OutputStream document) | Saves the document to a stream. |
| save(OutputStream document, RasterizationOptions rasterizationOptions) | Saves the document to a stream, including custom location. |
| generatePreview(PreviewOptions previewOptions) | Generates preview images of specific pages in a given image format. |
| getDocumentInfo() | Gets the general information about the document - size, page count, etc. |
public Redactor(String filePath)
Initializes a new instance of Redactor class using file path.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| filePath | java.lang.String | 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
}
```
|
public Redactor(InputStream document)
Initializes a new instance of Redactor class using stream.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| document | java.io.InputStream | 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
}
}
```
|
public Redactor(String filePath, LoadOptions loadOptions)
Initializes a new instance of Redactor class for a password-protected document using its path.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| filePath | java.lang.String | Path to file. |
| loadOptions | LoadOptions | Options, including password. |
public Redactor(String filePath, LoadOptions loadOptions, RedactorSettings settings)
Initializes a new instance of Redactor class for a password-protected document using its path and settings.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| filePath | java.lang.String | Path to file. |
| loadOptions | LoadOptions | File-dependent options, including password. |
| settings | RedactorSettings | Default settings for redaction process. |
public Redactor(InputStream document, LoadOptions loadOptions)
Initializes a new instance of Redactor class for a password-protected document using stream.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| document | java.io.InputStream | Source input stream. |
| loadOptions | LoadOptions | Options, including password. |
public Redactor(InputStream document, LoadOptions loadOptions, RedactorSettings settings)
Initializes a new instance of Redactor class for a password-protected document using stream and settings.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| document | java.io.InputStream | Source input stream. |
| loadOptions | LoadOptions | Options, including password. |
| settings | RedactorSettings | Default settings for redaction process. |
public final void close()
Releases resources.
public final RedactorChangeLog apply(Redaction redaction)
Applies a redaction to the document.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| redaction | Redaction | An instance of Redaction to apply |
Returns: RedactorChangeLog - Success or failure and error message in this case
public final RedactorChangeLog apply(Redaction[] redactions)
Applies a set of redactions to the document.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| redactions | Redaction[] | An array of redactions to apply |
Returns: RedactorChangeLog - Success or failure and error message in this case
public final RedactorChangeLog apply(RedactionPolicy policy)
Applies a redaction policy to the document.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| policy | RedactionPolicy | Redaction policy |
Returns: RedactorChangeLog - Success or failure and error message in this case
public final String save()
Saves the document to a file with the following options: AddSuffix = true, RasterizeToPDF = true.
Returns: java.lang.String - Path to redacted document
public final String save(SaveOptions saveOptions)
Saves the document to a file.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| saveOptions | SaveOptions | Options to add suffix or rasterize |
Returns: java.lang.String - Path to redacted document
public final void save(OutputStream document)
Saves the document to a stream.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| document | java.io.OutputStream | Target stream |
public final void save(OutputStream document, RasterizationOptions rasterizationOptions)
Saves the document to a stream, including custom location.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| document | java.io.OutputStream | Target stream |
| rasterizationOptions | RasterizationOptions | Options to rasterize or not and to specify pages for rasterization |
public final void generatePreview(PreviewOptions previewOptions)
Generates preview images of specific pages in a given image format.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| previewOptions | PreviewOptions | Image properties and page range settings |
public final IDocumentInfo getDocumentInfo()
Gets the general information about the document - size, page count, etc.
Returns: IDocumentInfo - An instance of IDocumentInfo
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.