The DDJVU API provides for efficiently decoding and displaying DjVu documents. It provides for displaying images without waiting for the complete DjVu data. Images can be displayed as soon as sufficient data is available. A higher quality image might later be displayed when further data is available. The DjVu library achieves this using a complicated scheme involving multiple threads. The DDJVU API hides this complexity with a familiar event model.
Version of the DDJVU API.
This method is called, in a separate thread, for every received message, before any blocking method finishes.
By default do something roughly equivalent to:
if message.job is not None:
message.job.message_queue.put(message)
elif message.document is not None:
message.document.message_queue.put(message)
else:
message.context.message_queue.put(message)
You may want to override this method to change this behaviour.
All exceptions raised by this method will be ignored.
Return the internal message queue.
Get message from the internal context queue.
Returns: | a Message instance |
---|---|
Returns: | None if wait is false and no message is available. |
Creates a decoder for a DjVu document and starts decoding. This method returns immediately. The decoding job then generates messages to request the raw data and to indicate the state of the decoding process.
uri specifies an optional URI for the document. The URI follows the usual syntax (protocol://machine/path). It should not end with a slash. It only serves two purposes:
Setting argument cache to a true vaule indicates that decoded pages should be cached when possible.
It is important to understand that the URI is not used to access the data. The document generates NewStreamMessage messages to indicate which data is needed. The caller must then provide the raw data using a NewStreamMessage.stream object.
To open a local file, provide a FileUri instance as an uri.
Localized characters in uri should be in URI-encoded.
Return type: | Document |
---|---|
Raises JobFailed: | |
on failure. |
A job.
Get message from the internal job queue.
Returns: | a Message instance. |
---|---|
Returns: | None if wait is false and no message is available. |
Indicate whether the decoding job is done.
Indicate whether the decoding job is done.
Returns: | the internal message queue. |
---|
Returns: | a JobException subclass indicating the job status. |
---|
Attempt to cancel the job.
This is a best effort method. There no guarantee that the job will actually stop.
Wait until the job is done.