LoadOptions
Inheritance: java.lang.Object
public class LoadOptions
Provides options that are used to open a file.
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.
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
}
Constructors
Constructor | Description |
---|---|
LoadOptions() | Initializes a new instance of the LoadOptions class. |
LoadOptions(FileType fileType) | Initializes a new instance of the LoadOptions class. |
Fields
Field | Description |
---|---|
DEFAULT_URL_CONNECT_TIMEOUT | |
DEFAULT_URL_READ_TIMEOUT |
Methods
Method | Description |
---|---|
getFileType() | Gets the type of the file to open. |
setFileType(FileType value) | Sets the type of the file to open. |
getPassword() | Gets the password for opening an encrypted file. |
setPassword(String value) | Sets the password for opening an encrypted file. |
getCharset() | The charset used when opening text-based files or email messages such as FileType.CSV, FileType.TXT, and FileType.MSG. |
setCharset(Charset value) | The charset used when opening text-based files or email messages such as FileType.CSV, FileType.TXT, and FileType.MSG. |
isDetectCharset() | This option enables FileType.TXT, FileType.TSV, and FileType.CSV files charset detection. |
setDetectCharset(boolean detectCharset) | This option enables FileType.TXT, FileType.TSV, and FileType.CSV files charset detection. |
getResourceLoadingTimeout() | Gets the timeout for loading external resources, such as graphics. |
setResourceLoadingTimeout(int resourceLoadingTimeout) | Sets the timeout for loading external resources, such as graphics. |
getUrlConnectTimeout() | Gets the connection timeout for creating a Viewer using java.net.URL to load a document. |
setUrlConnectTimeout(int urlConnectTimeout) | Sets the connection timeout for creating a Viewer using java.net.URL to load a document. |
getUrlReadTimeout() | Gets the read timeout for creating a Viewer using java.net.URL to load a document. |
setUrlReadTimeout(int urlReadTimeout) | Sets the read timeout for creating a Viewer using java.net.URL to load a document. |
getArchiveSecurityOptions() | Gets the security options to control the process of extracting archives. |
setArchiveSecurityOptions(ArchiveSecurityOptions archiveSecurityOptions) | Sets the security options to control the process of extracting archives. |
LoadOptions()
public LoadOptions()
Initializes a new instance of the LoadOptions class.
LoadOptions(FileType fileType)
public LoadOptions(FileType fileType)
Initializes a new instance of the LoadOptions class.
Parameters:
Parameter | Type | Description |
---|---|---|
fileType | FileType | The type of the file to open. |
DEFAULT_URL_CONNECT_TIMEOUT
public static final int DEFAULT_URL_CONNECT_TIMEOUT
DEFAULT_URL_READ_TIMEOUT
public static final int DEFAULT_URL_READ_TIMEOUT
getFileType()
public final FileType getFileType()
Gets the type of the file to open.
Returns: FileType - the file type.
setFileType(FileType value)
public final void setFileType(FileType value)
Sets the type of the file to open.
Parameters:
Parameter | Type | Description |
---|---|---|
value | FileType | The file type. |
getPassword()
public final String getPassword()
Gets the password for opening an encrypted file.
Returns: java.lang.String - the password for opening the file.
setPassword(String value)
public final void setPassword(String value)
Sets the password for opening an encrypted file.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | The password for opening the file. |
getCharset()
public final Charset getCharset()
The charset used when opening text-based files or email messages such as FileType.CSV, FileType.TXT, and FileType.MSG.
Default value is java.nio.charset.StandardCharsets#UTF_8.UTF_8.
Learn more
- Render Excel and Apple Numbers spreadsheets as HTML, PDF, and image files
- Render text documents as HTML, PDF, and image files
- Render email messages as HTML, PDF, PNG, and JPEG files
Example:
LoadOptions loadOptions = new LoadOptions();
loadOptions.setCharset(StandardCharsets.US_ASCII); // Set the charset
try (Viewer viewer = new Viewer("message.txt", loadOptions)) {
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
viewer.view(viewOptions);
}
Returns: java.nio.charset.Charset
setCharset(Charset value)
public final void setCharset(Charset value)
The charset used when opening text-based files or email messages such as FileType.CSV, FileType.TXT, and FileType.MSG.
Default value is java.nio.charset.StandardCharsets#UTF_8.UTF_8.
Learn more
- Render Excel and Apple Numbers spreadsheets as HTML, PDF, and image files
- Render text documents as HTML, PDF, and image files
- Render email messages as HTML, PDF, PNG, and JPEG files
Example:
LoadOptions loadOptions = new LoadOptions();
loadOptions.setCharset(StandardCharsets.US_ASCII); // Set the charset
try (Viewer viewer = new Viewer("message.txt", loadOptions)) {
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
viewer.view(viewOptions);
}
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.nio.charset.Charset |
isDetectCharset()
public boolean isDetectCharset()
This option enables FileType.TXT, FileType.TSV, and FileType.CSV files charset detection. In case the charset can’t be detected the default getCharset() is used.
Learn more about rendering text and tab/comma delimited files
- Render text documents as HTML, PDF, and image files
- Render Excel and Apple Numbers spreadsheets as HTML, PDF, and image files
Example:
LoadOptions loadOptions = new LoadOptions();
loadOptions.setDetectCharset(true); // Enable encoding detection
try (Viewer viewer = new Viewer("employees.csv", loadOptions)) {
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
viewer.view(viewOptions);
}
Returns: boolean
setDetectCharset(boolean detectCharset)
public void setDetectCharset(boolean detectCharset)
This option enables FileType.TXT, FileType.TSV, and FileType.CSV files charset detection. In case the charset can’t be detected the default getCharset() is used.
Learn more about rendering text and tab/comma delimited files
- Render text documents as HTML, PDF, and image files
- Render Excel and Apple Numbers spreadsheets as HTML, PDF, and image files
Example:
LoadOptions loadOptions = new LoadOptions();
loadOptions.setDetectCharset(true); // Enable encoding detection
try (Viewer viewer = new Viewer("employees.csv", loadOptions)) {
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
viewer.view(viewOptions);
}
Parameters:
Parameter | Type | Description |
---|---|---|
detectCharset | boolean |
getResourceLoadingTimeout()
public int getResourceLoadingTimeout()
Gets 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.
Returns: int - the loading timeout, milliseconds.
setResourceLoadingTimeout(int resourceLoadingTimeout)
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.
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.
setArchiveSecurityOptions(ArchiveSecurityOptions archiveSecurityOptions)
public void setArchiveSecurityOptions(ArchiveSecurityOptions archiveSecurityOptions)
Sets the security options to control the process of extracting archives.
Note: Not each archive type supports all options.
Parameters:
Parameter | Type | Description |
---|---|---|
archiveSecurityOptions | com.groupdocs.viewer.options.ArchiveSecurityOptions | The options object to configure the process of extracting archives. |