thumbnail property
BuiltInDocumentProperties.thumbnail property
Gets or sets the thumbnail of the document.
@property
def thumbnail(self) -> bytes:
...
@thumbnail.setter
def thumbnail(self, value: bytes):
...
Exceptions
exception | condition |
---|---|
RuntimeError (Proxy error(InvalidOperationException)) | Thrown if the image is invalid or its format is unsupported for specific format of document. |
Remarks
For now this property is used only when a document is being exported to ePub, it’s not read from and written to other document formats.
Image of arbitrary format can be set to this property, but the format is checked during export.
Only gif, jpeg and png images can be used for ePub publication.
Examples
Shows how to add a thumbnail to a document that we save as an Epub.
doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
builder.writeln('Hello world!')
# If we save a document, whose "Thumbnail" property contains image data that we added, as an Epub,
# a reader that opens that document may display the image before the first page.
properties = doc.built_in_document_properties
thumbnail_bytes = system_helper.io.File.read_all_bytes(IMAGE_DIR + 'Logo.jpg')
properties.thumbnail = thumbnail_bytes
doc.save(file_name=ARTIFACTS_DIR + 'DocumentProperties.Thumbnail.epub')
# We can extract a document's thumbnail image and save it to the local file system.
thumbnail = doc.built_in_document_properties.get_by_name('Thumbnail')
system_helper.io.File.write_all_bytes(ARTIFACTS_DIR + 'DocumentProperties.Thumbnail.gif', thumbnail.to_byte_array())
See Also
- module aspose.words.properties
- class BuiltInDocumentProperties