LoadOptions Class
Specifies options used to load a presentation.
Declaration
public class LoadOptions extends JavaObject
Remarks
Refer to the following help topic for additional information: Create, Load, and Save PowerPoint Presentations.
Inherited Members
Inheritance
LoadOptions()
Initializes a new instance of the LoadOptions class.
Declaration
public LoadOptions()
Methods
getDocumentFormat() Method
Returns the document format used to load the presentation.
Declaration
public DocumentFormat getDocumentFormat()
Returns
| Type | Description |
|---|---|
| DocumentFormat | The document format used to load the presentation. A new |
Remarks
Note
The Presentation API cannot determine the format of encrypted files. You must call the LoadOptions.setDocumentFormat() method to specify the document format explicitly.
Refer to the following help topic for additional information: Encrypt Presentations.
getPassword() Method
Returns the password used to load an encrypted presentation.
Declaration
public String getPassword()
Returns
| Type | Description |
|---|---|
| String | The password used to load an encrypted presentation. |
Remarks
Refer to the following help topic for additional information: Encrypt Presentations.
getSecurityLoadingHandler() Method
Returns the handler that processes security loading violations.
Declaration
public ISecurityLoadingHandler getSecurityLoadingHandler()
Returns
| Type | Description |
|---|---|
| ISecurityLoadingHandler | Sets the handler that handles security violations that occur when the Presentation API loads a presentation. |
Remarks
Refer to the following help topic for additional information: Secure Presentation Processing.
getSecurityLoadingLimits() Method
Returns security loading limits.
Declaration
public PresentationSecurityLoadingLimits getSecurityLoadingLimits()
Returns
| Type | Description |
|---|---|
| PresentationSecurityLoadingLimits | An object that specifies limits for presentation loading. |
Remarks
Use the LoadOptions.getSecurityLoadingLimits() method to access the PresentationSecurityLoadingLimits object and configure limits before you load the presentation.
The following security loading limits are available:
- Maximum presentation file size.
- Maximum number of XML elements.
- Maximum XML element nesting depth.
- Maximum number of slides.
- Maximum number of shapes per slide.
The following code snippet configures loading options, handles security violations, and loads a presentation with the specified security settings. The example throws an exception if the presentation exceeds a configured limit or contains restricted content, and logs the violation to the console:
package presentation;
import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
// Create load options.
LoadOptions loadOptions = new LoadOptions();
// Configure security loading limits.
PresentationSecurityLoadingLimits limits = new PresentationSecurityLoadingLimits();
limits.setMaxFileSize(50L * 1024 * 1024);
limits.setMaxSlideCount(100);
limits.setMaxShapeCountPerSlide(500);
loadOptions.setSecurityLoadingLimits(limits);
// Configure security loading options.
PresentationSecurityLoadingOptions securityLoadingOptionsOptions = new PresentationSecurityLoadingOptions();
securityLoadingOptionsOptions.setRemoveMacros(true);
securityLoadingOptionsOptions.setRemoveOleObjects(true);
securityLoadingOptionsOptions.setRemoveActiveXContent(true);
securityLoadingOptionsOptions.setRemoveCustomXMLParts(true);
loadOptions.setSecurityLoadingOptions(securityLoadingOptionsOptions);
// Handle security loading violations.
loadOptions.setSecurityLoadingHandler(new ISecurityLoadingHandler() {
@Override
public SecurityLimitAction handleLimitExceeded(
SecurityLimitExceededParams parameters) {
System.out.println("Security limit exceeded: " + parameters.getPropertyName());
return SecurityLimitAction.THROW;
}
@Override
public SecurityViolationAction handleOptionsViolation(
SecurityOptionsViolationParams parameters) {
System.out.println("Security option violated: " + parameters.getPropertyName());
return SecurityViolationAction.REMOVE;
}
});
try(FileInputStream inputStream = new FileInputStream("Presentation.pptx");
Presentation presentation = new Presentation(inputStream, loadOptions)) {
//...
}
}
}
Refer to the following help topic for additional information: Secure Presentation Processing.
getSecurityLoadingOptions() Method
Returns security loading options.
Declaration
public PresentationSecurityLoadingOptions getSecurityLoadingOptions()
Returns
| Type | Description |
|---|---|
| PresentationSecurityLoadingOptions | A |
Remarks
Use the LoadOptions.getSecurityLoadingOptions() method to access the PresentationSecurityLoadingOptions object. This object specifies content that the Presentation API should remove when it loads a presentation.
Configure security loading options before you load the presentation.
The following code snippet specifies content type restrictions and loads the presentation with configured options:
package presentation;
import com.devexpress.docs.presentation.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
// Create load options.
LoadOptions loadOptions = new LoadOptions();
// Configure security loading options.
PresentationSecurityLoadingOptions securityLoadingOptions = new PresentationSecurityLoadingOptions();
securityLoadingOptions.setRemoveMacros(true);
securityLoadingOptions.setRemoveOleObjects(true);
securityLoadingOptions.setRemoveActiveXContent(true);
securityLoadingOptions.setRemoveCustomXMLParts(true);
loadOptions.setSecurityLoadingOptions(securityLoadingOptions);
try(FileInputStream inputStream = new FileInputStream("Presentation.pptx");
Presentation presentation = new Presentation(inputStream, loadOptions)) {
//...
}
}
}
Refer to the following help topic for additional information: Secure Presentation Processing.
setDocumentFormat(DocumentFormat value) Method
Sets the document format used to load the presentation.
Declaration
public void setDocumentFormat(DocumentFormat value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | DocumentFormat | The document format used to load the presentation. |
setPassword(String value) Method
Sets the password used to load an encrypted presentation.
Declaration
public void setPassword(String value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | String | The password used to load an encrypted presentation. |
Remarks
Create a LoadOptions object with the specified password and document type. Pass the LoadingOptions object to the Presentation constructor to load an encrypted presentation.
The EncryptionOptions constructor requires a non-empty password. The API throws an exception if you pass null or an empty string.
The following code snippet loads an encrypted presentation:
package presentation;
import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;
import java.nio.file.*;
public class Main {
public static void main(String[] args) throws Exception {
LoadOptions loadOptions = new LoadOptions();
loadOptions.setPassword("password");
loadOptions.setDocumentFormat(DocumentFormat.PPTX);
try(Presentation presentation =
new Presentation(
Files.readAllBytes(Path.of("EncryptedPresentation.pptx")),
loadOptions)) {
// ...
}
}
}
Refer to the following help topic for additional information: Encrypt Presentations.
setSecurityLoadingHandler(ISecurityLoadingHandler value) Method
Sets the handler that handles security violations that occur when the Presentation API loads a presentation
Declaration
public void setSecurityLoadingHandler(ISecurityLoadingHandler value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | ISecurityLoadingHandler | The handler that processes security loading violations. |
Remarks
Refer to the following help topic for additional information: Secure Presentation Processing.
The following code snippet configures loading options, handles security violations, and loads a presentation with the specified security settings. The example throws an exception if the presentation exceeds a configured limit or contains restricted content, and logs the violation to the console:
package presentation;
import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
// Create load options.
LoadOptions loadOptions = new LoadOptions();
// Configure security loading limits.
PresentationSecurityLoadingLimits limits = new PresentationSecurityLoadingLimits();
limits.setMaxFileSize(50L * 1024 * 1024);
limits.setMaxSlideCount(100);
limits.setMaxShapeCountPerSlide(500);
loadOptions.setSecurityLoadingLimits(limits);
// Configure security loading options.
PresentationSecurityLoadingOptions securityLoadingOptionsOptions = new PresentationSecurityLoadingOptions();
securityLoadingOptionsOptions.setRemoveMacros(true);
securityLoadingOptionsOptions.setRemoveOleObjects(true);
securityLoadingOptionsOptions.setRemoveActiveXContent(true);
securityLoadingOptionsOptions.setRemoveCustomXMLParts(true);
loadOptions.setSecurityLoadingOptions(securityLoadingOptionsOptions);
// Handle security loading violations.
loadOptions.setSecurityLoadingHandler(new ISecurityLoadingHandler() {
@Override
public SecurityLimitAction handleLimitExceeded(
SecurityLimitExceededParams parameters) {
System.out.println("Security limit exceeded: " + parameters.getPropertyName());
return SecurityLimitAction.THROW;
}
@Override
public SecurityViolationAction handleOptionsViolation(
SecurityOptionsViolationParams parameters) {
System.out.println("Security option violated: " + parameters.getPropertyName());
return SecurityViolationAction.REMOVE;
}
});
try(FileInputStream inputStream = new FileInputStream("Presentation.pptx");
Presentation presentation = new Presentation(inputStream, loadOptions)) {
//...
}
}
}
setSecurityLoadingLimits(PresentationSecurityLoadingLimits value) Method
Sets security loading limits.
Declaration
public void setSecurityLoadingLimits(PresentationSecurityLoadingLimits value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | PresentationSecurityLoadingLimits | An object that specifies limits for presentation loading. |
Remarks
Use the LoadOptions.setSecurityLoadingLimits() method to assign the PresentationSecurityLoadingLimits object that configures limits (before you load the presentation).
The following security loading limits are available:
- Maximum presentation file size.
- Maximum number of XML elements.
- Maximum XML element nesting depth.
- Maximum number of slides.
- Maximum number of shapes per slide.
Refer to the following help topic for additional information: Secure Presentation Processing.
setSecurityLoadingOptions(PresentationSecurityLoadingOptions value) Method
Sets security loading options.
Declaration
public void setSecurityLoadingOptions(PresentationSecurityLoadingOptions value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | PresentationSecurityLoadingOptions | A |
Remarks
Use the LoadOptions.setSecurityLoadingOptions() method to assign the PresentationSecurityLoadingOptions object. This object specifies content that the Presentation API should remove when it loads a presentation.
Configure security loading options before you load the presentation.
Refer to the following help topic for additional information: Secure Presentation Processing.