DocumentFormatInstance
Leave feedback
On this page
Inheritance: java.lang.Object
public abstract class DocumentFormatInstance
Represents a specific format of a document. Implement this class to add your own document types.
Learn more
- More details about implementing custom formats: Create custom format handler
The following example demonstrates how to create an empty stub for a custom format handler.
public class DummyDocument extends DocumentFormatInstance
{
{@literal @}Override
public void load(InputStream output) throws java.lang.Exception
{
// load file content
}
{@literal @}Override
public void save(OutputStream output) throws java.lang.Exception
{
// save changes to file;
}
}
| Constructor | Description |
|---|---|
| DocumentFormatInstance() |
| Method | Description |
|---|---|
| createInstance(Class docType) | |
| getPassword() | Gets a password for password protected documents. |
| setPassword(String value) | Sets a password for password protected documents. |
| getRequiresRasterization() | Gets value, indicating if the format instance is read-only and cannot be saved in original format. |
| isAccessGranted() | |
| initialize(DocumentFormatConfiguration config, RedactorSettings settings) | Performs initialization of the instance of document format handler. |
| load(InputStream input) | Loads the document from a stream. |
| save(OutputStream output) | Saves the document to a stream. |
| isRedactionAccepted(RedactionDescription description) | Checks for IRedactionCallback implementation and invokes it, if specified. |
| performBinaryCheck(InputStream input) | Checks if the given stream contains a document, supported by this format instance. |
| getDefaultConfiguration() | Provides a singleton instance with default configuration of built-in formats. |
public DocumentFormatInstance()
public static DocumentFormatInstance createInstance(Class docType)
Parameters:
| Parameter | Type | Description |
|---|---|---|
| docType | java.lang.Class |
Returns: DocumentFormatInstance
public final String getPassword()
Gets a password for password protected documents.
Returns: java.lang.String - A password for password protected documents.
public final void setPassword(String value)
Sets a password for password protected documents.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | java.lang.String | A password for password protected documents. |
public boolean getRequiresRasterization()
Gets value, indicating if the format instance is read-only and cannot be saved in original format.
Returns: boolean - Value, indicating if the format instance is read-only and cannot be saved in original format.
public final boolean isAccessGranted()
Returns: boolean
public void initialize(DocumentFormatConfiguration config, RedactorSettings settings)
Performs initialization of the instance of document format handler.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| config | DocumentFormatConfiguration | Format configuration |
| settings | RedactorSettings | Default settings for redaction process. |
public void load(InputStream input)
Loads the document from a stream.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| input | java.io.InputStream | Stream to read from |
public abstract void save(OutputStream output)
Saves the document to a stream.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| output | java.io.OutputStream | Target stream to save the document |
public final boolean isRedactionAccepted(RedactionDescription description)
Checks for IRedactionCallback implementation and invokes it, if specified.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| description | RedactionDescription | Redaction description |
Returns: boolean - True (by default) if redaction is accepted
public boolean performBinaryCheck(InputStream input)
Checks if the given stream contains a document, supported by this format instance.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| input | java.io.InputStream | Document content stream |
Returns: boolean - True, if the document can be loaded by this format instance and false otherwise
public static RedactorConfiguration getDefaultConfiguration()
Provides a singleton instance with default configuration of built-in formats.
Returns: RedactorConfiguration - Configuration instance
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.