Skip to main content

PresentationSanitizeOptions Class

Contains options that control presentation sanitization.

Declaration

public class PresentationSanitizeOptions extends SanitizeOptions

Remarks

Call the Presentation.sanitize() method to remove potentially dangerous or private content with default sanitization options.

Use the Presentation.sanitize(PresentationSanitizeOptions options) overload to specify content types to be sanitized.

The sanitize() method returns a list of PresentationSanitizeResult objects. Each result describes a sanitization operation performed on the presentation.

The following code snippet applies a predefined sanitization policy:

package presentation;

import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;

import java.io.*;
import java.nio.file.*;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {
        try (FileInputStream inputStream = new FileInputStream("Presentation.pptx");
            Presentation presentation = new Presentation(inputStream)) {

            PresentationSanitizeOptions sanitizeOptions = new PresentationSanitizeOptions();

            sanitizeOptions.setRemoveNotes(true);
            sanitizeOptions.setRemoveOffSlideContent(true);
            sanitizeOptions.setRemoveMacros(true);
            sanitizeOptions.setRemoveActiveXContent(true);
            sanitizeOptions.setRemoveOleObjects(true);
            sanitizeOptions.setMetadata(MetadataRemovalScope.ALL);
            sanitizeOptions.setHiddenSlides(HiddenContentSanitizeMode.REMOVE);
            sanitizeOptions.setHiddenShapes(HiddenContentSanitizeMode.IGNORE);

            List<PresentationSanitizeResult> results = presentation.sanitize(sanitizeOptions);

            Path outputDir = Path.of("output");
            Files.createDirectories(outputDir);

            // Save the sanitized presentation.
            try (FileOutputStream fileStream = new FileOutputStream(
                    outputDir.resolve("Presentation_Sanitized.pptx").toFile())) {

                presentation.saveDocument(fileStream);
            }
        }
    }
}

Refer to the following help topic for additional information: Sanitize Presentation Content.

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
JavaObject
SanitizeOptions
PresentationSanitizeOptions

PresentationSanitizeOptions()

Initializes a new instance of the PresentationSanitizeOptions class.

Declaration

public PresentationSanitizeOptions()

Methods

getHiddenShapes() Method

Returns the action applied to hidden shapes during sanitization.

Declaration

public HiddenContentSanitizeMode getHiddenShapes()

Returns

Type Description
HiddenContentSanitizeMode

The action applied to hidden content during presentation sanitization.

getHiddenSlides() Method

Returns the action applied to hidden slides during sanitization.

Declaration

public HiddenContentSanitizeMode getHiddenSlides()

Returns

Type Description
HiddenContentSanitizeMode

The action applied to hidden slides during presentation sanitization.

getRemoveNotes() Method

Returns whether to remove notes during sanitization.

Declaration

public boolean getRemoveNotes()

Returns

Type Description
boolean

true to remove notes during sanitization; otherwise, false.

getRemoveOffSlideContent() Method

Returns whether off-slide content is removed during sanitization.

Declaration

public boolean getRemoveOffSlideContent()

Returns

Type Description
boolean

true to remove off-slide content; otherwise, false.

setHiddenShapes(HiddenContentSanitizeMode value) Method

Sets the action applied to hidden shapes during presentation sanitization.

Declaration

public void setHiddenShapes(HiddenContentSanitizeMode value)

Parameters

Name Type Description
value HiddenContentSanitizeMode

The action applied to hidden content during sanitization.

setHiddenSlides(HiddenContentSanitizeMode value) Method

Sets the action applied to hidden slides during sanitization.

Declaration

public void setHiddenSlides(HiddenContentSanitizeMode value)

Parameters

Name Type Description
value HiddenContentSanitizeMode

The action applied to hidden slides during sanitization.

setRemoveNotes(boolean value) Method

Sets whether to remove notes during sanitization.

Declaration

public void setRemoveNotes(boolean value)

Parameters

Name Type Description
value boolean

true to remove notes during sanitization; otherwise, false.

setRemoveOffSlideContent(boolean value) Method

Sets whether off-slide content is removed during sanitization.

Declaration

public void setRemoveOffSlideContent(boolean value)

Parameters

Name Type Description
value boolean

true to remove off-slide content; otherwise, false.