com.groupdocs.redaction

Class Redactor

    • 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

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

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

        Specified by:
        generatePreview in interface IPreviewable
        Parameters:
        previewOptions - Image properties and page range settings
        Throws:
        Exception