Build pre-paginated (fixed-layout) EPUB3 books from an ordered sequence of full-page images. A splash page is a page consisting of a single full-page image; every page this library emits is one — each input image becomes one page of the book, displayed full-bleed at its native dimensions.
- Deterministic — the same input and options always produce the same output bytes, so results can be golden-tested and content-addressed.
- Right-to-left aware —
page-progression-directionand facing-page spread placement (page-spread-left/-right) come out correct for RTL books, with sensible automatic alternation. - Zero non-stdlib dependencies.
See SPEC.md for the full specification.
go get github.com/ophymx/splash
book := splash.New("Uchuu no Hako").
Language("ja").
Direction(splash.RTL).
Series("Uchuu no Hako", 1).
Author("Aoyama Kawa")
if err := book.Cover(coverBytes); err != nil {
return err
}
for _, data := range pages { // encoded JPEG/PNG/GIF, in reading order
if err := book.AddPage(data, splash.PlacementAuto); err != nil {
return err
}
}
if err := book.WriteEPUB(out); err != nil {
return err
}Pages arrive as encoded bytes; format and pixel dimensions are sniffed
(JPEG, PNG, GIF). Each page gets an XHTML content document with a matching
viewport, so the reader scales it full-bleed. With PlacementAuto the
first page is centered (a cover faces no partner) and the rest alternate
into facing pairs by reading direction; pass an explicit PlacementLeft/
PlacementRight/PlacementCenter to re-anchor the alternation for books
whose pagination starts mid-spread.
If no identifier is set, a stable urn:uuid is derived from the book's
metadata and page bytes — same book in, same identifier out.
dcterms:modified defaults to the Unix epoch, not the wall clock; set
Modified(t) if you want a real timestamp.
go test validates generated files with epubcheck
when it is available — an epubcheck binary on PATH, or
EPUBCHECK=/path/to/epubcheck.jar with java installed — and skips the
check otherwise. epubcheck is test-only tooling, never a runtime
dependency.
Not yet: whether Kobo devices handle image-only fixed-layout books better
as KEPUB or as plain EPUB3 is an open question to settle by device
testing (see SPEC.md). If KEPUB wins, a WriteKEPUB built on
pgaskin/kepubify will be added; if plain EPUB3 wins, it won't be.