The LoadOptions class encapsulates various settings and parameters that can be used to specify how a file should be opened and loaded in the GroupDocs.Viewer component. For details, see this page and its children.
Example usage:
LoadOptions options = new LoadOptions();
options.setPassword("myPassword");
options.setFileType(PDF);
options.setCharset(Charset.forName("UTF-8"));
try (Viewer viewer = new Viewer(pdfFileInputStream, options)) {
// Use the viewer object for further operations
}
The list of URL fragments corresponding to external resources that should be loaded when #isSkipExternalResources().isSkipExternalResources() is set to true.
Sets the list of URL fragments corresponding to external resources that should be loaded when #isSkipExternalResources().isSkipExternalResources() is set to true.
LoadOptions()
public LoadOptions()
Initializes a new instance of the LoadOptions class.
public void setResourceLoadingTimeout(int resourceLoadingTimeout)
Sets the timeout for loading external resources, such as graphics.
Note: The default value is 30 seconds.
This option is supported for Word Processing documents that contain external resources. The default value is 30 seconds. For code example, see the documentation.
Parameters:
Parameter
Type
Description
resourceLoadingTimeout
int
The loading timeout, milliseconds.
getUrlConnectTimeout()
public int getUrlConnectTimeout()
Gets the connection timeout for creating a Viewer using java.net.URL to load a document.
Note: The default value is 5 seconds.
Returns:
int - the connection timeout.
setUrlConnectTimeout(int urlConnectTimeout)
public void setUrlConnectTimeout(int urlConnectTimeout)
Sets the connection timeout for creating a Viewer using java.net.URL to load a document.
Note: The default value is 5 seconds.
Parameters:
Parameter
Type
Description
urlConnectTimeout
int
The connection timeout.
getUrlReadTimeout()
public int getUrlReadTimeout()
Gets the read timeout for creating a Viewer using java.net.URL to load a document.
Note: The default value is 30 seconds.
Returns:
int - the read timeout.
setUrlReadTimeout(int urlReadTimeout)
public void setUrlReadTimeout(int urlReadTimeout)
Sets the read timeout for creating a Viewer using java.net.URL to load a document.
Note: The default value is 30 seconds.
Parameters:
Parameter
Type
Description
urlReadTimeout
int
The read timeout.
getArchiveSecurityOptions()
public ArchiveSecurityOptions getArchiveSecurityOptions()
Gets the security options to control the process of extracting archives.
Note: Not each archive type supports all options.
Returns:
com.groupdocs.viewer.options.ArchiveSecurityOptions - the options object to configure the process of extracting archives.
LoadOptions loadOptions = new LoadOptions();
loadOptions.setSkipExternalResources(true); // Skip loading of external resources
try (Viewer viewer = new Viewer("business-flyer.docx", loadOptions)) {
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
viewer.view(viewOptions);
}
Parameters:
Parameter
Type
Description
skipExternalResources
boolean
The flag to enable or disable loading of external resources.
getWhitelistedResources()
public List<String> getWhitelistedResources()
The list of URL fragments corresponding to external resources that should be loaded when #isSkipExternalResources().isSkipExternalResources() is set to true.
This option applies to the following file formats:
LoadOptions loadOptions = new LoadOptions();
loadOptions.setSkipExternalResources(true); // Skip loading of external resources
loadOptions.getWhitelistedResources().add("avatars.githubusercontent.com"); // Enable loading of external resources that have 'avatars.githubusercontent.com' fragment in resource URL.
try (Viewer viewer = new Viewer("business-flyer.docx", loadOptions)) {
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
viewer.view(viewOptions);
}
public void setWhitelistedResources(List<String> whitelistedResources)
Sets the list of URL fragments corresponding to external resources that should be loaded when #isSkipExternalResources().isSkipExternalResources() is set to true.
This option applies to the following file formats:
LoadOptions loadOptions = new LoadOptions();
loadOptions.setSkipExternalResources(true); // Skip loading of external resources
loadOptions.setWhitelistedResources(Arrays.asList("avatars.githubusercontent.com")); // Enable loading of external resources that have 'avatars.githubusercontent.com' fragment in resource URL.
try (Viewer viewer = new Viewer("business-flyer.docx", loadOptions)) {
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
viewer.view(viewOptions);
}
Parameters:
Parameter
Type
Description
whitelistedResources
java.util.List<java.lang.String>
The list of URL fragments corresponding to external resources that should be loaded.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.