DocumentFormatInstance class

DocumentFormatInstance class

Represents a specific format of a document and can be implemented to add custom document types.

Learn more

The DocumentFormatInstance type exposes the following members:

Methods

Method Description
initialize Initializes the document format handler instance.
initialize_document_format_configuration
is_redaction_accepted Checks for IRedactionCallback implementation and invokes it, if specified.
is_redaction_accepted_redaction_description
load Loads the document from a stream.
load_stream
load_streams
perform_binary_check Checks if the given stream contains a document supported by this format instance.
perform_binary_check_stream
perform_binary_check_streams
save Saves the document to a stream.
save_stream
save_streams

Properties

Property Description
password The password for password-protected documents.

Example

class DummyDocument(DocumentFormatInstance):
    def load(self, output: io.RawIOBase) -> None:
        # load file content
        pass

    def save(self, output: io.RawIOBase) -> None:
        # save changes to file
        pass
class MyCustomHandler(DocumentFormatInstance):
    def __init__(self):
        self.my_property = None

    def initialize(self, config: DocumentFormatConfiguration) -> None:
        super().initialize(config)
        if "MyProperty" in config.initialization_data:
            self.my_property = config.initialization_data["MyProperty"]

See Also