Skip to end of metadata
Go to start of metadata
Contents Summary
 

Since version 19.3, the EPUB format also supports the hierarchical metadata arrangement (as described in this article)

The code sample in below examples uses some methods defined in Working with Common Utilities.

Handling Metadata in EPUB Document Using GroupDocs.Metadata API

GroupDocs Metadata API also deals with metadata attached with EPUB document. Following are some basic features provided by the said API.

Getting Metadata in EPUB Document

To access Metadata in EPUB Document, GroupDocs.Metadata API provides EpubMedata.GetEpubMetadata() function which returns all metadata properties. Following are the steps to access metadata in EPUB Document:

  1. Initialize EpubFormat 
  2. Get metadata using EpubFormat.GetEpubMetadata()

Following code snippet gets metadata of EPUB document file. 

Getting Metadata in EPUB Document using Stream

You can also get EPUB Document metadata using a stream. Following are the steps to access metadata in EPUB Document:

  1. Initialize stream using Stream stream = File.Open("D:\test.epub", FileMode.Open, FileAccess.ReadWrite)
  2. Initialize EpubFormat 
  3. Get metadata using EpubFormat.GetDublinCore()

Following code snippet gets metadata of EPUB document file using stream. 

Getting DublinCore Metadata from EPUB Document

GroupDocs.Metadata API also provides a way of getting DublinCore Metadata from EPUB Document. Follow steps to get DublinCore Metadata:

  1. Initialize EpubFormat 
  2. Get DublinCore metadata using EpubFormat.GetDublinCore()

Following code snippet gets DublinCore metadata from EPUB Document.

Detecting EPUB File Format

 GroupDocs.Metadata API allows you to detect EPUB File Format. There are two ways of detecting EPUB file format:

  1. Using (EpubFormat) FormatFactory.RecognizeFormat(file)
  2. Using new EpubFormat (file)

Following code snippet detects EPUB file format.

Reading Image Cover from EPUB File Format 

This feature is supported by version 18.9 or greater.

 GroupDocs.Metadata API allows you to read image cover from EPUB file format.

  1. Initialize EpubFormat 
  2. Get the image cover data and MIME type using EpubFormat.ReadThumbnail()
  3. Get metadata properties e.g MimeType using ThumbnailMetadata.MimeType

Following code snippet reads image cover and MIME type from EPUB file format.

Reading Version of EPUB Package

This feature is supported by version 18.2 or greater.

 GroupDocs.Metadata API allows you to read version of EPUB file format.

  1. Initialize EpubFormat 
  2. Read metadata using EpubFormat.GetEpubMetadata()
  3. Read version using EpubMetadata.Version

Following code snippet reads version of EPUB file format.

Reading Image Cover using MetadataUtility  

This feature is supported by version 18.4 or greater.

GroupDocs.Metadata API allows you to read image cover using a unified approach. You can read image cover using MetadataUtility class and cast it to ThumbnailMetadata. Follow steps to read image cover:

  1. Read image cover using (ThumbnailMetadata)MetadataUtility.ExtractSpecificMetadata("D:\sample.epub", MetadataType.Thumbnail)
  2. Read MimeType using ThumbnailMetadata.MimeType

Following code snippet reads image cover using MetadataUtility class.

Download Sample File

You can download sample Epub file used in this article.

Following is the path of sample Epub file used in code sample:

Labels
  • No labels