epub

package module
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 30 Imported by: 0

README ΒΆ

Go EPUB Library

EPUB Go Reference Go Version License GitHub

A robust, feature-rich Go library for reading and writing EPUB publications with full support for the EPUB 3.3 specification.

πŸ“š Documentation β€’ πŸš€ Quick Start β€’ ✨ Features β€’ πŸ“¦ Installation


πŸ“‹ Table of Contents


✨ Features

Core Reading Capabilities
  • βœ… Parse EPUB 3.3 container, metadata, manifest, spine, guide, and navigation structures
  • βœ… Full support for EPUB 2 and EPUB 3 specifications
  • βœ… Multiple package rendition support for flexible reading layouts
Content Processing
  • πŸ“„ Read content documents in multiple formats:
    • XHTML (native support)
    • Markdown (auto-converted from HTML)
    • SVG (scalable vector graphics)
  • πŸ”„ Automatic HTML-to-Markdown conversion with customizable options
  • 🎯 Precise HTML node parsing and manipulation
Resource Management
  • πŸ“¦ Extract and access all publication resources (images, stylesheets, fonts, etc.)
  • πŸ–ΌοΈ Extract images in raw bytes or as image.Image objects
  • πŸ” Query resources by ID or href reference
Metadata & Navigation
  • 🏷️ Complete metadata access (title, author, language, identifier, etc.)
  • πŸ“‘ Table of Contents (TOC) support for both NAV (EPUB 3) and NCX (EPUB 2)
  • πŸ—ΊοΈ Navigation structure abstraction for seamless cross-version compatibility
  • πŸ“Š JSON serializable TOC for external tools and integrations
Writing Capabilities
  • πŸ› οΈ Generate new EPUB files programmatically
  • πŸ“ Add content documents (XHTML/HTML)
  • πŸ–ΌοΈ Embed images with automatic format detection
  • βš™οΈ Full package metadata configuration
  • πŸ“š Automatic spine and manifest generation

πŸ“¦ Installation

go get github.com/raitucarp/epub

Requires Go 1.25.3 or higher


πŸš€ Quick Start

Reading EPUB Files
package main

import (
	"fmt"
	"log"
	"github.com/raitucarp/epub"
)

func main() {
	// Open an EPUB file
	r, err := epub.OpenReader("example.epub")
	if err != nil {
		log.Fatal(err)
	}

	// Access basic metadata
	fmt.Println("Title:", r.Title())
	fmt.Println("Author:", r.Author())
	fmt.Println("Language:", r.Language())
	fmt.Println("Identifier:", r.Identifier())
	fmt.Println("Version:", r.Version())

	// Iterate through content documents
	ids := r.ListContentDocumentIds()
	for _, id := range ids {
		html := r.ReadContentHTMLById(id)
		fmt.Printf("Content for %s: %v\n", id, html)
	}

	// Access table of contents
	toc := r.TOC()
	fmt.Printf("TOC: %s\n", toc.Title)
}
Writing EPUB Files
package main

import (
	"log"
	"time"
	"github.com/raitucarp/epub"
)

func main() {
	// Create a new EPUB writer
	w := epub.New("pub-id-001")
	w.Title("My First Book")
	w.Author("Jane Doe")
	w.Language("en")
	w.Date(time.Now())
	w.Description("An example EPUB publication")
	w.Publisher("Indie Press")

	// Add HTML content
	w.AddContent("chapter1.xhtml", []byte(`
		<html>
			<body>
				<h1>Chapter 1: The Beginning</h1>
				<p>Once upon a time...</p>
			</body>
		</html>
	`))

	// Add an image
	imageData := []byte{/* ... */}
	w.AddImageContent("cover.png", imageData)

	// Write to disk
	if err := w.Write("output.epub"); err != nil {
		log.Fatal(err)
	}
}

🎯 Core Capabilities

Metadata Access

Access comprehensive publication metadata:

r, _ := epub.OpenReader("book.epub")

// Basic metadata
title := r.Title()
author := r.Author()
language := r.Language()
identifier := r.Identifier()
uid := r.UID()                    // Unique identifier
version := r.Version()            // EPUB version
metadata := r.Metadata()          // Full metadata map
cover := r.GetCover()             // Cover image
Content Processing

Read and process content in multiple formats:

// Get HTML content node
htmlNode := r.ReadContentHTMLById("chapter1")
htmlByHref := r.ReadContentHTMLByHref("text/chapter1.xhtml")

// Convert HTML to Markdown
markdown := r.ReadContentMarkdownById("chapter1")
markdownByHref := r.ReadContentMarkdownByHref("text/chapter1.xhtml")

// Access raw content
rawContent := r.ReadContentById("chapter1")
Resource Management

Manage and access publication resources:

// Get all resources
resources := r.Resources()

// Select specific resources
resource := r.SelectResourceById("img001")
resource := r.SelectResourceByHref("images/cover.jpg")

// Extract images
imageObj := r.ReadImageById("cover-image")
imageObj := r.ReadImageByHref("images/cover.jpg")
imageBytes := r.ReadImageBytesById("cover-image")
Navigation Support

Work with table of contents:

// Get TOC
toc := r.TOC()
fmt.Println("Title:", toc.Title)
fmt.Println("Href:", toc.Href)

// Access nested items
for _, item := range toc.Items {
	fmt.Println("- ", item.Title, "->", item.Href)
}

// Serialize to JSON
jsonBytes, _ := toc.JSON()

// Select multiple renditions
r.SelectPackageRendition("default")
r.SelectPackageRendition("alternative")
currentPackage := r.CurrentSelectedPackage()
Image Handling

Work with images in multiple formats:

// Supported formats: JPEG, PNG, GIF, WebP, SVG

// Get image as image.Image
img := r.ReadImageById("image001")

// Get raw bytes
bytes := r.ReadImageBytesById("image001")

// Get cover image
cover := r.GetCover()

// List image resources
for _, resource := range r.Resources() {
	if isImageType(resource.MIMEType) {
		img := r.ReadImageByHref(resource.Href)
		// Process image...
	}
}

πŸ“š Reader API Overview

type Reader

// Constructor functions
func NewReader(b []byte) (reader Reader, err error)
func OpenReader(name string) (reader Reader, err error)

// Metadata methods
func (r *Reader) Title() string
func (r *Reader) Author() string
func (r *Reader) Identifier() string
func (r *Reader) Language() string
func (r *Reader) UID() string
func (r *Reader) Version() string
func (r *Reader) Metadata() map[string]any
func (r *Reader) GetCover() *image.Image

// Content access
func (r *Reader) ReadContentHTMLById(id string) *html.Node
func (r *Reader) ReadContentHTMLByHref(href string) *html.Node
func (r *Reader) ReadContentMarkdownById(id string) string
func (r *Reader) ReadContentMarkdownByHref(href string) string
func (r *Reader) ReadContentById(id string) []byte
func (r *Reader) ListContentDocumentIds() []string

// Resource management
func (r *Reader) Resources() []PublicationResource
func (r *Reader) SelectResourceById(id string) *PublicationResource
func (r *Reader) SelectResourceByHref(href string) *PublicationResource

// Image handling
func (r *Reader) ReadImageById(id string) *image.Image
func (r *Reader) ReadImageByHref(href string) *image.Image
func (r *Reader) ReadImageBytesById(id string) []byte
func (r *Reader) ReadImageBytesByHref(href string) []byte

// Navigation
func (r *Reader) TOC() *TOC
func (r *Reader) SelectPackageRendition(rendition string)
func (r *Reader) CurrentSelectedPackage() *pkg.Package

// Package selection
func (r *Reader) SelectPackageRendition(rendition string)
func (r *Reader) CurrentSelectedPackagePath() string

πŸ“ Writer API Overview

type Writer

// Constructor
func New(pubId string) *Writer

// Metadata configuration
func (w *Writer) Title(title string) *Writer
func (w *Writer) Author(author string) *Writer
func (w *Writer) Language(lang string) *Writer
func (w *Writer) Description(desc string) *Writer
func (w *Writer) Publisher(pub string) *Writer
func (w *Writer) Date(date time.Time) *Writer

// Content management
func (w *Writer) AddContent(href string, content []byte) (id string, err error)
func (w *Writer) AddImageContent(href string, imageData []byte) (id string, err error)
func (w *Writer) AddCover(imagePath string) (id string, err error)

// Output
func (w *Writer) Write(filename string) error
func (w *Writer) WriteBytes() ([]byte, error)

// Advanced options
func (w *Writer) SetTextDirection(direction string) *Writer
func (w *Writer) SetContentDir(dir string) *Writer

πŸ’‘ Advanced Usage

Working with Multiple Renditions

Some EPUB files contain multiple renditions (different layouts, languages, etc.):

r, _ := epub.OpenReader("book.epub")

// Switch between available renditions
r.SelectPackageRendition("default")
r.SelectPackageRendition("alternative")

// Get current package information
pkg := r.CurrentSelectedPackage()
fmt.Println("Manifest items:", len(pkg.Manifest.Items))
Full Metadata Extraction
metadata := r.Metadata()

// The metadata map contains:
// - Basic: title, author, language, identifier
// - Extended: publisher, rights, description, contributor
// - Meta: custom properties and relationships
// - Links: external references

for key, value := range metadata {
	fmt.Printf("%s: %v\n", key, value)
}
Building EPUBs from Scratch
w := epub.New("unique-pub-id")
w.Title("Novel: The Rising Sun")
w.Author("John Smith")
w.Language("en")
w.Publisher("Great Novels Inc")
w.Rights("Β© 2024 John Smith. All rights reserved.")
w.Description("An epic tale of adventure and discovery")

// Add chapters
chapters := []string{"chapter1.html", "chapter2.html", "chapter3.html"}
for _, ch := range chapters {
	content := readFile(ch)
	w.AddContent(ch, content)
}

// Add cover image
cover := readFile("cover.jpg")
w.AddCover(cover)

// Write final EPUB
w.Write("novel.epub")

πŸ“‹ Supported Content Types

Media Types
  • Documents: application/xhtml+xml (XHTML)
  • Navigation: application/x-dtbncx+xml (NCX), application/nav+xml (HTML NAV)
  • Styles: text/css (CSS Stylesheets)
  • Images: image/jpeg, image/png, image/gif, image/webp, image/svg+xml
  • Fonts: font/ttf, font/otf, application/font-woff
Spine Directions
  • ltr - Left-to-Right (default)
  • rtl - Right-to-Left
  • default - Browser default
Properties
  • nav - Navigation document
  • cover-image - Cover image
  • mathml - MathML support
  • svg - SVG support
  • scripted - JavaScript support
  • remote-resources - External resources
  • layout-pre-paginated - Fixed layout

πŸ“– Examples

Example 1: Extract All Text from an EPUB
package main

import (
	"fmt"
	"log"
	"strings"
	"github.com/raitucarp/epub"
)

func main() {
	r, err := epub.OpenReader("book.epub")
	if err != nil {
		log.Fatal(err)
	}

	for _, id := range r.ListContentDocumentIds() {
		html := r.ReadContentHTMLById(id)
		fmt.Printf("Content for %s: %v\n", id, html)
	}
}
Example 2: Create an EPUB from Markdown Files
package main

import (
	"log"
	"os"
	"path/filepath"
	"time"
	"github.com/raitucarp/epub"
)

func main() {
	w := epub.New("markdown-book-001")
	w.Title("My Markdown Book")
	w.Author("Author Name")
	w.Language("en")
	w.Date(time.Now())

	// Convert markdown files to HTML and add to EPUB
	files, _ := filepath.Glob("chapters/*.md")
	for _, file := range files {
		content, _ := os.ReadFile(file)
		// In production, convert markdown to HTML
		w.AddContent(filepath.Base(file), content)
	}

	w.Write("output.epub")
}
Example 3: Copy and Modify an EPUB
package main

import (
	"log"
	"time"
	"github.com/raitucarp/epub"
)

func main() {
	// Read original
	r, err := epub.OpenReader("original.epub")
	if err != nil {
		log.Fatal(err)
	}

	// Create new EPUB with modified metadata
	w := epub.New("new-pub-id")
	w.Title(r.Title() + " (Edition 2)")
	w.Author(r.Author())
	w.Language(r.Language())
	w.Date(time.Now())

	// Copy all content
	for _, id := range r.ListContentDocumentIds() {
		content := r.ReadContentById(id)
		w.AddContent(id, content)
	}

	// Add new cover
	cover := r.GetCover()
	if cover != nil {
		w.AddCover("new-cover.png")
	}

	w.Write("modified.epub")
}

πŸ”§ Dependencies

  • html-to-markdown: HTML to Markdown conversion
  • golang.org/x/image: Image processing (GIF, WebP support)
  • golang.org/x/net/html: HTML parsing
  • golang.org/x/text: Text normalization and Unicode handling

All dependencies are vendored and documented in go.mod.


🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup
git clone https://github.com/raitucarp/epub.git
cd epub
go mod download
go test ./...

Writer API Overview

type Writer

func New(pubId string) *Writer

func (w *Writer) Title(...string)
func (w *Writer) Author(string)
func (w *Writer) Languages(...string)
func (w *Writer) Date(time.Time)
func (w *Writer) Description(string)
func (w *Writer) Publisher(string)

func (w *Writer) AddContent(filename string, content []byte) PublicationResource
func (w *Writer) AddImage(name string, content []byte) PublicationResource
func (w *Writer) AddSpineItem(res PublicationResource)

func (w *Writer) Write(filename string) error

License

See LICENSE.md

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

This section is empty.

Types ΒΆ

type Epub ΒΆ

type Epub struct {
	// contains filtered or unexported fields
}

Epub represents a full EPUB publication, including metadata, package information, resources, and navigation.

func (*Epub) DefaultPackage ΒΆ added in v0.2.0

func (epub *Epub) DefaultPackage() *pkg.Package

func (*Epub) SelectPackage ΒΆ added in v0.2.0

func (epub *Epub) SelectPackage(name string) *pkg.Package

func (*Epub) SelectedPackage ΒΆ added in v0.2.0

func (epub *Epub) SelectedPackage() *pkg.Package

type PublicationResource ΒΆ

type PublicationResource struct {
	ID         string
	Href       string
	MIMEType   string
	Content    []byte
	Filepath   string
	Properties pkg.ManifestProperty
}

PublicationResource represents a single resource inside the EPUB container. Resources may include XHTML documents, images, stylesheets, SVG files, and auxiliary data referenced by the publication manifest.

type Reader ΒΆ

type Reader struct {
	// contains filtered or unexported fields
}

Reader provides an interface for reading and accessing EPUB publication data. It offers methods for retrieving metadata, navigation structures, content documents, resources, and images.

func NewReader ΒΆ

func NewReader(b []byte) (reader Reader, err error)

NewReader creates a new Reader instance from a raw EPUB byte slice. The byte slice must represent a valid EPUB container.

func OpenReader ΒΆ

func OpenReader(name string) (reader Reader, err error)

OpenReader opens an EPUB file from the provided file path and returns a Reader instance. The file must exist and be a valid EPUB container.

func (*Reader) Author ΒΆ

func (r *Reader) Author() (author string)

Author returns the author (creator) metadata of the publication.

func (*Reader) ContentDocumentMarkdown ΒΆ

func (r *Reader) ContentDocumentMarkdown() (documents map[string]string)

ContentDocumentMarkdown returns content documents converted into Markdown form. The returned map is keyed by EPUB manifest item ID.

func (*Reader) ContentDocumentSVG ΒΆ

func (r *Reader) ContentDocumentSVG() (documents map[string]*html.Node)

ContentDocumentSVG returns SVG content documents parsed into html.Node trees. The returned map is keyed by EPUB manifest item ID.

func (*Reader) ContentDocumentXHTML ΒΆ

func (r *Reader) ContentDocumentXHTML() (documents map[string]*html.Node)

ContentDocumentXHTML returns XHTML content documents parsed into html.Node trees. The returned map is keyed by EPUB manifest item ID.

func (*Reader) ContentDocumentXHTMLString ΒΆ

func (r *Reader) ContentDocumentXHTMLString() (documents map[string]string)

ContentDocumentXHTMLString returns XHTML content documents as raw strings. The returned map is keyed by EPUB manifest item ID.

func (*Reader) Cover ΒΆ

func (r *Reader) Cover() (cover *image.Image)

Cover returns the publication's cover image if present.

func (*Reader) CoverBytes ΒΆ added in v0.2.0

func (r *Reader) CoverBytes() (cover []byte, err error)

CoverBytes returns the raw byte representation of the cover image. An error is returned if the publication does not define a cover.

func (*Reader) CurrentSelectedPackage ΒΆ

func (r *Reader) CurrentSelectedPackage() *pkg.Package

CurrentSelectedPackage returns the currently active package rendition. EPUB publications may have multiple renditions.

func (*Reader) CurrentSelectedPackagePath ΒΆ

func (r *Reader) CurrentSelectedPackagePath() string

CurrentSelectedPackagePath returns the internal path to the currently selected package document.

func (*Reader) Description ΒΆ

func (r *Reader) Description() (description string)

Description returns the publication's description metadata if defined.

func (*Reader) Identifier ΒΆ added in v0.2.0

func (r *Reader) Identifier() (identifier string)

Identifier returns the primary identifier of the publication as declared in the package metadata (often equivalent to UID).

func (*Reader) ImageResources ΒΆ added in v0.2.0

func (r *Reader) ImageResources() (images map[string][]byte)

ImageResources returns all image resources in byte form, keyed by manifest ID. Useful when direct decoding to image.Image is not required.

func (*Reader) Images ΒΆ

func (r *Reader) Images() (images map[string]image.Image)

Images returns all image resources in the publication, keyed by manifest ID.

func (*Reader) Language ΒΆ added in v0.2.0

func (r *Reader) Language() (language string)

Language returns the primary language of the publication, as declared in the package metadata (dc:language).

func (*Reader) ListContentDocumentIds ΒΆ added in v0.1.2

func (r *Reader) ListContentDocumentIds() (ids []string)

ListContentDocumentIds returns the IDs of all content documents (XHTML/SVG) registered in the publication manifest.

func (*Reader) ListImageIds ΒΆ added in v0.1.2

func (r *Reader) ListImageIds() (ids []string)

ListImageIds returns the IDs of all image-based resources (e.g., PNG, JPEG, SVG) in the publication manifest.

func (*Reader) Metadata ΒΆ

func (r *Reader) Metadata() (metadata map[string]any)

Metadata returns the complete metadata block of the publication. The returned map may include standard as well as extended metadata fields.

func (*Reader) NavigationCenterExtended ΒΆ

func (r *Reader) NavigationCenterExtended() *ncx.NCX

NavigationCenterExtended returns the NCX navigation document (if available). This is primarily used for EPUB 2.x backward compatibility.

func (*Reader) ReadContentHTMLByHref ΒΆ added in v0.1.3

func (r *Reader) ReadContentHTMLByHref(href string) (doc *html.Node)

ReadContentHTMLByHref returns the content document associated with the given manifest href. The returned document is parsed into an html.Node tree.

func (*Reader) ReadContentHTMLById ΒΆ

func (r *Reader) ReadContentHTMLById(id string) (doc *html.Node)

ReadContentHTMLById returns the XHTML/HTML content document associated with the given manifest ID, parsed into an html.Node tree.

func (*Reader) ReadContentMarkdownById ΒΆ added in v0.1.1

func (r *Reader) ReadContentMarkdownById(id string) (md string)

ReadContentMarkdownById returns a Markdown string representation of the content document associated with the given manifest ID.

func (*Reader) ReadImageByHref ΒΆ

func (r *Reader) ReadImageByHref(href string) (img *image.Image)

ReadImageByHref returns the image resource referenced by the given href, if present in the manifest.

func (*Reader) ReadImageById ΒΆ

func (r *Reader) ReadImageById(id string) (img *image.Image)

ReadImageById returns the image resource associated with the given manifest ID.

func (*Reader) References ΒΆ added in v0.2.1

func (r *Reader) References() (references map[pkg.GuideReferenceType]*html.Node)

References returns the structural guide references defined in the package, such as "cover", "title-page", "toc", etc. The returned map is keyed by reference type and mapped to corresponding HTML content.

func (*Reader) Refines ΒΆ

func (r *Reader) Refines() (refines map[string]map[string][]string)

Refines returns metadata refinement relationships. The returned map is keyed by subject identifier, mapping to properties and their assigned values.

func (*Reader) Resources ΒΆ

func (r *Reader) Resources() (resources []PublicationResource)

Resources returns all publication resources declared in the manifest.

func (*Reader) SelectPackageRendition ΒΆ

func (r *Reader) SelectPackageRendition(rendition string)

SelectPackageRendition changes the active package rendition by its rendition identifier. Useful when multiple reading layouts are available.

func (*Reader) SelectResourceByHref ΒΆ

func (r *Reader) SelectResourceByHref(href string) (resource *PublicationResource)

SelectResourceByHref retrieves a resource referenced by its manifest href.

func (*Reader) SelectResourceById ΒΆ

func (r *Reader) SelectResourceById(id string) (resource *PublicationResource)

SelectResourceById retrieves a resource referenced by its manifest ID.

func (*Reader) Spine ΒΆ

func (r *Reader) Spine() (orderedResources []PublicationResource)

Spine returns publication's spines, ordered resources like table of contents.

func (*Reader) TableOfContents ΒΆ

func (r *Reader) TableOfContents() (toc TOC, err error)

TableOfContents returns the TOC version present (e.g., NAV or NCX). If both exist, behavior depends on publication version and priority rules.

func (*Reader) Title ΒΆ

func (r *Reader) Title() (title string)

Title returns the publication's title metadata.

func (*Reader) UID ΒΆ

func (r *Reader) UID() (identifier string)

UID returns the unique identifier of the publication.

func (*Reader) Version ΒΆ

func (r *Reader) Version() (version string)

Version returns the EPUB specification version of the publication.

type TOC ΒΆ added in v0.1.3

type TOC struct {
	Title string `json:"title,omitempty"`
	Href  string `json:"href,omitempty"`
	Items []TOC  `json:"items,omitempty"`
	// contains filtered or unexported fields
}

TOC represents the publication's table of contents in normalized form. The structure abstracts differences between NAV (EPUB 3) and NCX (EPUB 2) so higher-level code can work with a unified interface.

func (*TOC) JSON ΒΆ added in v0.1.3

func (t *TOC) JSON() (b []byte, err error)

JSON marshals the table of contents structure into JSON format. This is useful for external tools, logging, debugging, or serialization to other formats.

func (*TOC) ReadContentHTML ΒΆ added in v0.1.3

func (t *TOC) ReadContentHTML() (content *html.Node)

ReadContentHTML returns the content document associated with the currently selected table of contents entry. The returned document is parsed into an html.Node tree. Behavior depends on TOC internal navigation selection state.

type Writer ΒΆ

type Writer struct {
	// contains filtered or unexported fields
}

Writer provides an interface for constructing, modifying, and writing EPUB publications to disk or memory. Writer usage documentation is evolving.

func New ΒΆ added in v0.2.0

func New(pubId string) *Writer

New creates a new Writer with the given publication identifier. The identifier is assigned to the package metadata (dc:identifier).

func (*Writer) AddContent ΒΆ added in v0.2.0

func (w *Writer) AddContent(filename string, content []byte) (res PublicationResource)

AddContent adds a content file (such as XHTML or SVG) to the publication using the provided filename and raw bytes. Returns the created resource.

func (*Writer) AddContentFile ΒΆ added in v0.2.0

func (w *Writer) AddContentFile(name string) (res PublicationResource, err error)

AddContentFile adds a content file to the publication by reading the file from disk. Returns the created resource and any file access error.

func (*Writer) AddGuide ΒΆ added in v0.2.0

func (w *Writer) AddGuide(kind pkg.GuideReferenceType, href string, title string)

AddGuide adds a guide reference entry (e.g., "cover", "toc", "title-page") to the package metadata.

func (*Writer) AddImage ΒΆ added in v0.2.0

func (w *Writer) AddImage(name string, content []byte) (res PublicationResource)

AddImage adds an image resource from raw bytes to the publication.

func (*Writer) AddImageFile ΒΆ added in v0.2.0

func (w *Writer) AddImageFile(name string) (res PublicationResource)

AddImageFile adds an image resource to the publication by reading from disk.

func (*Writer) AddSpineItem ΒΆ added in v0.2.0

func (w *Writer) AddSpineItem(res PublicationResource)

AddSpineItem appends the given resource to the spine reading order.

func (*Writer) Author ΒΆ added in v0.2.0

func (w *Writer) Author(creator string)

Author sets the primary creator/author in the package metadata.

func (*Writer) Contributor ΒΆ added in v0.2.0

func (w *Writer) Contributor(kind string, contributor string)

Contributor adds a contributor entry of the specified role or type.

func (*Writer) Cover ΒΆ added in v0.2.0

func (w *Writer) Cover(cover []byte) (err error)

Cover sets the publication cover from a raw image byte slice.

func (*Writer) CoverFile ΒΆ added in v0.2.0

func (w *Writer) CoverFile(name string)

CoverFile sets the publication cover image by file path.

func (*Writer) CoverJPG ΒΆ added in v0.2.0

func (w *Writer) CoverJPG(cover image.Image) (err error)

CoverJPG sets the publication cover image from an image.Image encoded as JPEG.

func (*Writer) CoverPNG ΒΆ added in v0.2.0

func (w *Writer) CoverPNG(cover image.Image) (err error)

CoverPNG sets the publication cover image from an image.Image encoded as PNG

func (*Writer) Creator ΒΆ added in v0.2.0

func (w *Writer) Creator(id string, creator string)

Creator adds a creator with a specific identifier attribute to the metadata.

func (*Writer) Date ΒΆ added in v0.2.0

func (w *Writer) Date(date time.Time)

Date sets the publication date metadata.

func (*Writer) Description ΒΆ added in v0.2.0

func (w *Writer) Description(description string)

Description sets a short description or summary for the publication.

func (*Writer) Direction ΒΆ added in v0.2.0

func (w *Writer) Direction(dir string)

Direction sets the writing direction (ltr or rtl) used by the spine.

func (*Writer) DublinCores ΒΆ added in v0.2.0

func (w *Writer) DublinCores(keyVal map[string]string)

DublinCores sets multiple Dublin Core metadata fields at once.

func (*Writer) Identifiers ΒΆ added in v0.2.0

func (w *Writer) Identifiers(identifier ...string)

Identifiers adds one or more identifiers to the package metadata.

func (*Writer) Languages ΒΆ added in v0.2.0

func (w *Writer) Languages(language ...string)

Languages adds one or more language codes to the publication metadata.

func (*Writer) LongDescription ΒΆ added in v0.2.0

func (w *Writer) LongDescription(description string)

LongDescription sets an extended descriptive summary.

func (*Writer) Meta ΒΆ added in v0.2.0

func (w *Writer) Meta(meta pkg.Meta)

Meta adds a meta element to the package metadata as-is.

func (*Writer) MetaContent ΒΆ added in v0.2.0

func (w *Writer) MetaContent(keyVal map[string]string)

MetaContent adds metadata key/value entries that do not require refinements.

func (*Writer) MetaProperty ΒΆ added in v0.2.0

func (w *Writer) MetaProperty(id string, property string, value string)

MetaProperty adds a property-based metadata refinement entry.

func (*Writer) Publisher ΒΆ added in v0.2.0

func (w *Writer) Publisher(publisher string)

Publisher sets the publication publisher.

func (*Writer) Refines ΒΆ added in v0.2.0

func (w *Writer) Refines(refines string, property string, value string, otherAttributes ...pkg.Meta)

Refines applies a metadata refinement to an existing metadata item.

func (*Writer) Rights ΒΆ added in v0.2.0

func (w *Writer) Rights(rights string)

Rights sets the copyright or licensing information for the publication.

func (*Writer) SetContentDir ΒΆ added in v0.2.0

func (w *Writer) SetContentDir(dir string)

SetContentDir sets the directory used for storing content documents.

func (*Writer) SetImageDir ΒΆ added in v0.2.0

func (w *Writer) SetImageDir(dir string)

SetImageDir sets the directory used for storing image resources.

func (*Writer) SetTextDir ΒΆ added in v0.2.0

func (w *Writer) SetTextDir(dir string)

SetTextDir sets the directory used for text document organization.

func (*Writer) Subject ΒΆ added in v0.2.0

func (w *Writer) Subject(id string, subject string)

Subject adds a subject or theme classification to the publication.

func (*Writer) TableOfContents ΒΆ added in v0.2.0

func (w *Writer) TableOfContents(name string, toc TOC) (err error)

func (*Writer) Title ΒΆ added in v0.2.0

func (w *Writer) Title(title ...string)

Title sets one or more title entries in the metadata.

func (*Writer) Write ΒΆ added in v0.2.0

func (w *Writer) Write(filename string) (err error)

Write finalizes the EPUB structure and writes it to the specified filename.

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL