LoadOptions

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.slides.ILoadOptions

public class LoadOptions implements ILoadOptions

Allows to specify additional options (such as format or default font) when loading a presentation.

Constructors

ConstructorDescription
LoadOptions()Creates new default load options.
LoadOptions(int loadFormat)Creates new load options.

Methods

MethodDescription
getLoadFormat()Returns or sets format of a presentation to load.
setLoadFormat(int value)Returns or sets format of a presentation to load.
getDefaultRegularFont()Returns or sets Regular font used in case source font is not found.
setDefaultRegularFont(String value)Returns or sets Regular font used in case source font is not found.
getDefaultSymbolFont()Returns or sets Symbol font used in case source font is not found.
setDefaultSymbolFont(String value)Returns or sets Symbol font used in case source font is not found.
getDefaultAsianFont()Returns or sets Asian font used in case source font is not found.
setDefaultAsianFont(String value)Returns or sets Asian font used in case source font is not found.
getPassword()Gets or sets the password.
setPassword(String value)Gets or sets the password.
getOnlyLoadDocumentProperties()This property makes sense, if presentation file is password protected.
setOnlyLoadDocumentProperties(boolean value)This property makes sense, if presentation file is password protected.
getWarningCallback()Returns or sets an object which receives warnings and decides whether loading process will continue or will be aborted.
setWarningCallback(IWarningCallback value)Returns or sets an object which receives warnings and decides whether loading process will continue or will be aborted.
getBlobManagementOptions()Represents the options which can be used to manage Binary Large Objects (BLOBs) handling behavior, such as using of temporary files or max BLOBs bytes in memory.
setBlobManagementOptions(IBlobManagementOptions value)Represents the options which can be used to manage Binary Large Objects (BLOBs) handling behavior, such as using of temporary files or max BLOBs bytes in memory.
getDocumentLevelFontSources()Specifies sources for external fonts to be used by the presentation.
setDocumentLevelFontSources(IFontSources value)Specifies sources for external fonts to be used by the presentation.
getInterruptionToken()The token to monitor for interruption requests.
setInterruptionToken(IInterruptionToken value)The token to monitor for interruption requests.
getResourceLoadingCallback()Returns or sets callback interface which manages external resources loading.
setResourceLoadingCallback(IResourceLoadingCallback value)Returns or sets callback interface which manages external resources loading.
getSpreadsheetOptions()Gets options for spreadsheets.
setSpreadsheetOptions(ISpreadsheetOptions value)Gets options for spreadsheets.
getDefaultTextLanguage()Returns or sets the default language for presentation text.
setDefaultTextLanguage(String value)Returns or sets the default language for presentation text.
getDeleteEmbeddedBinaryObjects()Determines if Aspose.Slides will delete all embedded binary objects while presentation loading.
setDeleteEmbeddedBinaryObjects(boolean value)Determines if Aspose.Slides will delete all embedded binary objects while presentation loading.

LoadOptions()

public LoadOptions()

Creates new default load options.

LoadOptions(int loadFormat)

public LoadOptions(int loadFormat)

Creates new load options.

Parameters:

ParameterTypeDescription
loadFormatintFormat of a presentation to load.

getLoadFormat()

public final int getLoadFormat()

Returns or sets format of a presentation to load. Read/write LoadFormat.

Returns: int

setLoadFormat(int value)

public final void setLoadFormat(int value)

Returns or sets format of a presentation to load. Read/write LoadFormat.

Parameters:

ParameterTypeDescription
valueint

getDefaultRegularFont()

public final String getDefaultRegularFont()

Returns or sets Regular font used in case source font is not found. Read/write String.


The following example shows how to set default fonts for rendering PowerPoint Presentation.
 
 // Use load options to define the default regular and asian fonts
 LoadOptions loadOptions = new LoadOptions(LoadFormat.Auto);
 loadOptions.setDefaultRegularFont("Wingdings");
 loadOptions.setDefaultAsianFont("Wingdings");
 // Load the presentation
 Presentation pres = new Presentation("DefaultFonts.pptx", loadOptions);
 try {
     // Generate slide thumbnail
     BufferedImage slideImage = pres.getSlides().get_Item(0).getThumbnail(1, 1);
     ImageIO.write(slideImage, "PNG", new File("output_out.png"));
     // Generate PDF
     pres.save("output_out.pdf", SaveFormat.Pdf);
     // Generate XPS
     pres.save("output_out.xps", SaveFormat.Xps);
 } catch(IOException e) {
 } finally {
     if (pres != null) pres.dispose();
 }

Returns: java.lang.String

setDefaultRegularFont(String value)

public final void setDefaultRegularFont(String value)

Returns or sets Regular font used in case source font is not found. Read/write String.


The following example shows how to set default fonts for rendering PowerPoint Presentation.
 
 // Use load options to define the default regular and asian fonts
 LoadOptions loadOptions = new LoadOptions(LoadFormat.Auto);
 loadOptions.setDefaultRegularFont("Wingdings");
 loadOptions.setDefaultAsianFont("Wingdings");
 // Load the presentation
 Presentation pres = new Presentation("DefaultFonts.pptx", loadOptions);
 try {
     // Generate slide thumbnail
     BufferedImage slideImage = pres.getSlides().get_Item(0).getThumbnail(1, 1);
     ImageIO.write(slideImage, "PNG", new File("output_out.png"));
     // Generate PDF
     pres.save("output_out.pdf", SaveFormat.Pdf);
     // Generate XPS
     pres.save("output_out.xps", SaveFormat.Xps);
 } catch(IOException e) {
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

ParameterTypeDescription
valuejava.lang.String

getDefaultSymbolFont()

public final String getDefaultSymbolFont()

Returns or sets Symbol font used in case source font is not found. Read/write String.

Returns: java.lang.String

setDefaultSymbolFont(String value)

public final void setDefaultSymbolFont(String value)

Returns or sets Symbol font used in case source font is not found. Read/write String.

Parameters:

ParameterTypeDescription
valuejava.lang.String

getDefaultAsianFont()

public final String getDefaultAsianFont()

Returns or sets Asian font used in case source font is not found. Read/write String.

Returns: java.lang.String

setDefaultAsianFont(String value)

public final void setDefaultAsianFont(String value)

Returns or sets Asian font used in case source font is not found. Read/write String.

Parameters:

ParameterTypeDescription
valuejava.lang.String

getPassword()

public final String getPassword()

Gets or sets the password. Read/write String.


The following sample code shows how to open password protected PowerPoint Presentation.
 
 LoadOptions loadOptions = new LoadOptions();
 loadOptions.setPassword("YOUR_PASSWORD");
 Presentation pres = new Presentation("pres.pptx", loadOptions);
 try {
 // work with decrypted presentation
 } finally {
     if (pres != null) pres.dispose();
 }

Value: The password.

Returns: java.lang.String

setPassword(String value)

public final void setPassword(String value)

Gets or sets the password. Read/write String.


The following sample code shows how to open password protected PowerPoint Presentation.
 
 LoadOptions loadOptions = new LoadOptions();
 loadOptions.setPassword("YOUR_PASSWORD");
 Presentation pres = new Presentation("pres.pptx", loadOptions);
 try {
 // work with decrypted presentation
 } finally {
     if (pres != null) pres.dispose();
 }

Value: The password.

Parameters:

ParameterTypeDescription
valuejava.lang.String

getOnlyLoadDocumentProperties()

public final boolean getOnlyLoadDocumentProperties()

This property makes sense, if presentation file is password protected. Value of true means that only document properties must be loaded from an encrypted presentation file and password must be ignored. Value of false means that entire encrypted presentation must be loaded with use of right password. If presentation isn’t encrypted then property value is always ignored. If document properties of an encrypted file aren’t public and property value is true then document properties cannot be loaded and exception will be thrown. Read/write boolean.

Returns: boolean

setOnlyLoadDocumentProperties(boolean value)

public final void setOnlyLoadDocumentProperties(boolean value)

This property makes sense, if presentation file is password protected. Value of true means that only document properties must be loaded from an encrypted presentation file and password must be ignored. Value of false means that entire encrypted presentation must be loaded with use of right password. If presentation isn’t encrypted then property value is always ignored. If document properties of an encrypted file aren’t public and property value is true then document properties cannot be loaded and exception will be thrown. Read/write boolean.

Parameters:

ParameterTypeDescription
valueboolean

getWarningCallback()

public final IWarningCallback getWarningCallback()

Returns or sets an object which receives warnings and decides whether loading process will continue or will be aborted. Read/write IWarningCallback.

Returns: IWarningCallback

setWarningCallback(IWarningCallback value)

public final void setWarningCallback(IWarningCallback value)

Returns or sets an object which receives warnings and decides whether loading process will continue or will be aborted. Read/write IWarningCallback.

Parameters:

ParameterTypeDescription
valueIWarningCallback

getBlobManagementOptions()

public final IBlobManagementOptions getBlobManagementOptions()

Represents the options which can be used to manage Binary Large Objects (BLOBs) handling behavior, such as using of temporary files or max BLOBs bytes in memory. These options intended to set up the best performance/memory consumption ratio for a perticular environment or requirements.


A Binary Large Object (BLOB) is a binary data stored as a single entity - i.e. BLOB can be an audio, video or presentation itself.

Returns: IBlobManagementOptions

setBlobManagementOptions(IBlobManagementOptions value)

public final void setBlobManagementOptions(IBlobManagementOptions value)

Represents the options which can be used to manage Binary Large Objects (BLOBs) handling behavior, such as using of temporary files or max BLOBs bytes in memory. These options intended to set up the best performance/memory consumption ratio for a perticular environment or requirements.


A Binary Large Object (BLOB) is a binary data stored as a single entity - i.e. BLOB can be an audio, video or presentation itself.

Parameters:

ParameterTypeDescription
valueIBlobManagementOptions

getDocumentLevelFontSources()

public final IFontSources getDocumentLevelFontSources()

Specifies sources for external fonts to be used by the presentation. These fonts are available to the presentation throughout its lifetime and are not shared with other presentations


The following example shows how to specify custom fonts used with PowerPoint Presentation.
 
 byte[] memoryFont1 = Files.readAllBytes(Paths.get("customfonts\\CustomFont1.ttf"));
 byte[] memoryFont2 = Files.readAllBytes(Paths.get("customfonts\\CustomFont2.ttf"));
 LoadOptions loadOptions = new LoadOptions();
 loadOptions.getDocumentLevelFontSources().setFontFolders(new String[] { "assets\\fonts", "global\\fonts" });
 loadOptions.getDocumentLevelFontSources().setMemoryFonts(new byte[][] { memoryFont1, memoryFont2 });
 IPresentation presentation = new Presentation("MyPresentation.pptx", loadOptions);
 try {
 //work with the presentation
 //CustomFont1, CustomFont2 as well as fonts from assets\fonts & global\fonts folders and their subfolders are available to the presentation
 } finally {
     if (presentation != null) presentation.dispose();
 }

Returns: IFontSources

setDocumentLevelFontSources(IFontSources value)

public final void setDocumentLevelFontSources(IFontSources value)

Specifies sources for external fonts to be used by the presentation. These fonts are available to the presentation throughout its lifetime and are not shared with other presentations


The following example shows how to specify custom fonts used with PowerPoint Presentation.
 
 byte[] memoryFont1 = Files.readAllBytes(Paths.get("customfonts\\CustomFont1.ttf"));
 byte[] memoryFont2 = Files.readAllBytes(Paths.get("customfonts\\CustomFont2.ttf"));
 LoadOptions loadOptions = new LoadOptions();
 loadOptions.getDocumentLevelFontSources().setFontFolders(new String[] { "assets\\fonts", "global\\fonts" });
 loadOptions.getDocumentLevelFontSources().setMemoryFonts(new byte[][] { memoryFont1, memoryFont2 });
 IPresentation presentation = new Presentation("MyPresentation.pptx", loadOptions);
 try {
 //work with the presentation
 //CustomFont1, CustomFont2 as well as fonts from assets\fonts & global\fonts folders and their subfolders are available to the presentation
 } finally {
     if (presentation != null) presentation.dispose();
 }

Parameters:

ParameterTypeDescription
valueIFontSources

getInterruptionToken()

public final IInterruptionToken getInterruptionToken()

The token to monitor for interruption requests.


This token manages the whole IPresentation instance lifetime. Any long-running operation, such as loading or saving of presentation, will be interrupted via calling of the InterruptionTokenSource.interrupt method of the InterruptionTokenSource.

Returns: IInterruptionToken

setInterruptionToken(IInterruptionToken value)

public final void setInterruptionToken(IInterruptionToken value)

The token to monitor for interruption requests.


This token manages the whole IPresentation instance lifetime. Any long-running operation, such as loading or saving of presentation, will be interrupted via calling of the InterruptionTokenSource.interrupt method of the InterruptionTokenSource.

Parameters:

ParameterTypeDescription
valueIInterruptionToken

getResourceLoadingCallback()

public final IResourceLoadingCallback getResourceLoadingCallback()

Returns or sets callback interface which manages external resources loading. Read/write IResourceLoadingCallback.

Returns: IResourceLoadingCallback

setResourceLoadingCallback(IResourceLoadingCallback value)

public final void setResourceLoadingCallback(IResourceLoadingCallback value)

Returns or sets callback interface which manages external resources loading. Read/write IResourceLoadingCallback.

Parameters:

ParameterTypeDescription
valueIResourceLoadingCallback

getSpreadsheetOptions()

public final ISpreadsheetOptions getSpreadsheetOptions()

Gets options for spreadsheets. For example, these options affect calculating formulas for charts.

Returns: ISpreadsheetOptions

setSpreadsheetOptions(ISpreadsheetOptions value)

public final void setSpreadsheetOptions(ISpreadsheetOptions value)

Gets options for spreadsheets. For example, these options affect calculating formulas for charts.

Parameters:

ParameterTypeDescription
valueISpreadsheetOptions

getDefaultTextLanguage()

public final String getDefaultTextLanguage()

Returns or sets the default language for presentation text. Read/write String.


Example:
  
 // Use load options to define the default text culture
 LoadOptions loadOptions = new LoadOptions();
 loadOptions.setDefaultTextLanguage("en-US");
 Presentation pres = new Presentation(loadOptions);
 try {
     // Add new rectangle shape with text
     IAutoShape shp = pres.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 50, 50, 150, 50);
     shp.getTextFrame().setText("New Text");
     // Check the first portion language
     System.out.println(shp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getLanguageId());
 } finally {
     if (pres != null) pres.dispose();
 }

Returns: java.lang.String

setDefaultTextLanguage(String value)

public final void setDefaultTextLanguage(String value)

Returns or sets the default language for presentation text. Read/write String.


Example:
  
 // Use load options to define the default text culture
 LoadOptions loadOptions = new LoadOptions();
 loadOptions.setDefaultTextLanguage("en-US");
 Presentation pres = new Presentation(loadOptions);
 try {
     // Add new rectangle shape with text
     IAutoShape shp = pres.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 50, 50, 150, 50);
     shp.getTextFrame().setText("New Text");
     // Check the first portion language
     System.out.println(shp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getLanguageId());
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

ParameterTypeDescription
valuejava.lang.String

getDeleteEmbeddedBinaryObjects()

public final boolean getDeleteEmbeddedBinaryObjects()

Determines if Aspose.Slides will delete all embedded binary objects while presentation loading.

The types of the embedded binary objects:

Read/write boolean .


The following example shows how to load the presentation without any embedded binary objects.
 
 LoadOptions loadOptions = new LoadOptions();
 loadOptions.setDeleteEmbeddedBinaryObjects(true);
 Presentation pres = new Presentation("pres.ppt", loadOptions);
 try {
     pres.save("output_WithoutBinaryObjects.ppt", SaveFormat.Ppt);
 } finally {
     if (pres != null) pres.dispose();
 }

Default is false .

Returns: boolean

setDeleteEmbeddedBinaryObjects(boolean value)

public final void setDeleteEmbeddedBinaryObjects(boolean value)

Determines if Aspose.Slides will delete all embedded binary objects while presentation loading.

The types of the embedded binary objects:

Read/write boolean .


The following example shows how to load the presentation without any embedded binary objects.
 
 LoadOptions loadOptions = new LoadOptions();
 loadOptions.setDeleteEmbeddedBinaryObjects(true);
 Presentation pres = new Presentation("pres.ppt", loadOptions);
 try {
     pres.save("output_WithoutBinaryObjects.ppt", SaveFormat.Ppt);
 } finally {
     if (pres != null) pres.dispose();
 }

Default is false .

Parameters:

ParameterTypeDescription
valueboolean