Class ZIP

class ooodev.io.zip.ZIP[source]

Class for managing ZIP files.

static get_zip_content_as_byte_array(doc, fnm)[source]

Gets the content of a file within the document as a byte array.

Parameters:
  • doc (Any) – A UNO Document the supports com.sun.star.frame.XStorable interface.

  • fnm (PathOrStr) – Path within the document to the file.

Raises:

Exception – If failed to read bytes.

Returns:

The content of the file as a byte array.

Return type:

Tuple[int, …]

Warning

The doc must be an existing doc. A newly created doc that has not been saved will not work.

Example

from ooodev.write import WriteDoc

doc = WriteDoc.from_current_doc()

content_xml_bytes = ZIP.get_zip_content_as_byte_array(doc.component, "content.xml")
styles_xml_bytes = ZIP.get_zip_content_as_byte_array(doc.component, "styles.xml")