com.groupdocs.redaction

Class Redactor

  • All Implemented Interfaces:
    Closeable, AutoCloseable


    public final class Redactor
    extends Object
    implements Closeable

    Represents a main class that controls document redaction process, allowing to open, redact and save documents.


    <b>Learn more</b>
    • Constructor Detail

      • Redactor

        public Redactor(String filePath)
                 throws Exception

        Initializes a new instance of Redactor class using file path.

        Parameters:
        filePath - Path to the file
        Throws:
        Exception
      • Redactor

        public Redactor(InputStream document)
                 throws Exception

        Initializes a new instance of Redactor class using stream.

        Parameters:
        document - Source stream of the document
        Throws:
        Exception
      • Redactor

        public Redactor(String filePath,
                LoadOptions loadOptions)
                 throws Exception

        Initializes a new instance of Redactor class for a password-protected document using its path.

        Parameters:
        filePath - Path to file.
        loadOptions - Options, including password.
        Throws:
        Exception
      • Redactor

        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.

        Parameters:
        filePath - Path to file.
        loadOptions - File-dependent options, including password.
        settings - Default settings for redaction process.
        Throws:
        Exception
      • Redactor

        public Redactor(InputStream document,
                LoadOptions loadOptions)
                 throws Exception

        Initializes a new instance of Redactor class for a password-protected document using stream.

        Parameters:
        document - Source input stream.
        loadOptions - Options, including password.
        Throws:
        Exception
      • Redactor

        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.

        Parameters:
        document - Source input stream.
        loadOptions - Options, including password.
        settings - Default settings for redaction process.
        Throws:
        Exception
    • Method Detail

      • apply

        public final RedactorChangeLog apply(Redaction redaction)

        Applies a redaction to the document.

        Parameters:
        redaction - An instance of Redaction to apply
        Returns:
        Success or failure and error message in this case
      • apply

        public final RedactorChangeLog apply(Redaction[] redactions)

        Applies a set of redactions to the document.

        Parameters:
        redactions - An array of redactions to apply
        Returns:
        Success or failure and error message in this case
      • apply

        public final RedactorChangeLog apply(RedactionPolicy policy)

        Applies a redaction policy to the document.

        Parameters:
        policy - Redaction policy
        Returns:
        Success or failure and error message in this case
      • save

        public final String save()
                          throws Exception

        Saves the document to a file with the following options: AddSuffix = true, RasterizeToPDF = true.

        Returns:
        Path to redacted document
        Throws:
        Exception
      • save

        public final String save(SaveOptions saveOptions)
                          throws Exception

        Saves the document to a file.

        Parameters:
        saveOptions - Options to add suffix or rasterize
        Returns:
        Path to redacted document
        Throws:
        Exception
      • save

        public final void save(OutputStream document,
                RasterizationOptions rasterizationOptions)
                        throws Exception

        Saves the document to a stream, including custom location.

        Parameters:
        document - Target stream
        rasterizationOptions - Options to rasterize or not and to specify pages for rasterization
        Throws:
        Exception
      • generatePreview

        public final void generatePreview(PreviewOptions previewOptions)
                                   throws Exception

        Generates preview images of specific pages in a given image format.

        Parameters:
        previewOptions - Image properties and page range settings
        Throws:
        Exception
      • getDocumentInfo

        public final IDocumentInfo getDocumentInfo()
                                            throws Exception

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

        Returns:
        An instance of IDocumentInfo
        Throws:
        Exception