Working with metadata in MOBI e-books

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Metadata MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-metadata -- dnx GroupDocs.Metadata.Mcp --yes
Folders, licensing and more →

What is MOBI?

MOBI (Mobipocket) is an e-book format used by early Kindle readers. A MOBI file is a Palm Database (PDB) file: it starts with a PDB header, followed by a MOBI header that describes the book.

GroupDocs.Metadata for Java exposes both headers through the MobiPackage class:

  • PDBHeader: the database name, type and creator, the creation, modification and last backup dates, the number of records, and other database fields.
  • MobiHeader: the full name of the book, the MOBI type and the text encoding.

Reading MOBI format-specific properties

  1. Load a MOBI e-book
  2. Get the root metadata package
  3. Extract the native metadata package using the MobiRootPackage.getMobiPackage method
  4. Read the properties of the PDB and MOBI headers

advanced_usage.managing_metadata_for_specific_formats.ebook.MobiReadProperties

try (Metadata metadata = new Metadata(Constants.InputMobi)) {
    MobiRootPackage root = metadata.getRootPackageGeneric();
    PDBHeader pdbHeader = root.getMobiPackage().getPDBHeader();
    MobiHeader mobiHeader = root.getMobiPackage().getMobiHeader();

    System.out.println(pdbHeader.getName());
    System.out.println(pdbHeader.getType());
    System.out.println(pdbHeader.getCreator());
    System.out.println(pdbHeader.getCreationDate());
    System.out.println(pdbHeader.getModificationDate());

    System.out.println(mobiHeader.getFullName());
    System.out.println(mobiHeader.getMobiType());
    System.out.println(mobiHeader.getTextEncoding());
}

The database name in the PDB header is limited to 31 characters, so it often holds a shortened title such as The_Geography_of_Bliss__One_Gru. The full title of the book is stored in the MOBI header.

Updating the full name of a book

The full name of the book can be changed with the MobiHeader.setFullName method.

try (Metadata metadata = new Metadata(Constants.InputMobi)) {
    MobiRootPackage root = metadata.getRootPackageGeneric();

    root.getMobiPackage().getMobiHeader().setFullName("The Updated Title");

    metadata.save(Constants.OutputMobi);
}

More resources

GitHub examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free online document metadata management App

Along with full featured Java library we provide simple, but powerful free Apps.

You are welcome to view and edit metadata of PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, emails, images and more with our free online Free Online Document Metadata Viewing and Editing App.