Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OCF

Simple wrapper around the JSZip package to create an OCF specific packaging for EPUB. The constructor generates and adds the required content files, as described in the EPUB Specification, namely:

  • The mimetype file
  • The container.xml file, see the value in container_xml.

Both of these files are stored uncompressed.

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new OCF(name: string): OCF
  • Parameters

    • name: string

      the file name of the final package. This is based on the short name of the document, or the name provided in the configuration file.

    Returns OCF

Properties

Private _container

_container: JSZip

Private _name

_name: string

Private content

content: Buffer | Blob = null

Accessors

container

  • get container(): JSZip
  • Returns the underlying ZIP container; this is used when creating a "collection", ie, when the the final content is generated from several zip containers.

    Returns JSZip

name

  • get name(): string
  • Return the name of the final file, as provided at constructor time. This is based on the short name of the document, or the name provided in the configuration file.

    Returns string

Methods

append

  • append(content: string | stream.Readable, path_name: string): void
  • Store a compressed content in the OCF file. The input can be a simple text or a Stream (the relevant archiver function takes care of disambiguation).

    Parameters

    • content: string | stream.Readable

      Content to be stored

    • path_name: string

      Path name of the file for the content

    Returns void

get_content

  • get_content(): Promise<Buffer | Blob>
  • Return the final content of the book all packed up. If not yet done, the content is generated using the relevant jszip function, packaging all content that has been added.

    async

    Returns Promise<Buffer | Blob>