Redactor

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


Constructors

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.

Methods

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.

Redactor(String filePath)

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
 }
 
``` 

|

Redactor(InputStream document)

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
     }
 }
 
``` 

|

Redactor(String filePath, LoadOptions loadOptions)

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.

Redactor(String filePath, LoadOptions loadOptions, RedactorSettings settings)

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.

Redactor(InputStream document, LoadOptions loadOptions)

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.

Redactor(InputStream document, LoadOptions loadOptions, RedactorSettings settings)

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.

close()

public final void close()

Releases resources.

apply(Redaction redaction)

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

apply(Redaction[] redactions)

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

apply(RedactionPolicy policy)

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

save()

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

save(SaveOptions saveOptions)

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

save(OutputStream document)

public final void save(OutputStream document)

Saves the document to a stream.

Parameters:

Parameter Type Description
document java.io.OutputStream Target stream

save(OutputStream document, RasterizationOptions rasterizationOptions)

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

generatePreview(PreviewOptions previewOptions)

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

getDocumentInfo()

public final IDocumentInfo getDocumentInfo()

Gets the general information about the document - size, page count, etc.

Returns: IDocumentInfo - An instance of IDocumentInfo