Documentation
¶
Overview ¶
Package splash builds 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.
Output is deterministic: the same input and options always produce byte-identical files. See SPEC.md for the full specification.
Index ¶
- type Book
- func (b *Book) AddPage(data []byte, p Placement) error
- func (b *Book) Author(name string) *Book
- func (b *Book) Cover(data []byte) error
- func (b *Book) Direction(d Direction) *Book
- func (b *Book) Identifier(id string) *Book
- func (b *Book) Language(tag string) *Book
- func (b *Book) Modified(t time.Time) *Book
- func (b *Book) Orientation(o Orientation) *Book
- func (b *Book) Publisher(name string) *Book
- func (b *Book) Series(name string, position float64) *Book
- func (b *Book) Spread(s Spread) *Book
- func (b *Book) WriteEPUB(w io.Writer) error
- type Direction
- type Orientation
- type Placement
- type Spread
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Book ¶
type Book struct {
// contains filtered or unexported fields
}
Book accumulates metadata and pages, then writes them as an EPUB. Construct with New; metadata setters chain. Setter errors accumulate internally and surface at the write call; AddPage and Cover also return their error immediately.
func New ¶
New returns a Book with the given title. Direction defaults to LTR, Spread to SpreadLandscape, Orientation to OrientationAuto.
func (*Book) AddPage ¶
AddPage appends a page in reading order. data must be an encoded JPEG, PNG, or GIF image; format and pixel dimensions are sniffed from it.
func (*Book) Cover ¶
Cover appends a page flagged as the cover: its image carries the cover-image manifest property. If Cover is never called, the first page is the cover. At most one page may be the cover.
func (*Book) Identifier ¶
Identifier sets the book's unique identifier (any URN/URI). When unset, an identifier is derived deterministically from the book's metadata and page bytes.
func (*Book) Language ¶
Language sets the book's language as a BCP 47 tag (e.g. "en", "ja"). Required.
func (*Book) Modified ¶
Modified sets the publication's last-modified time (dcterms:modified). Defaults to the Unix epoch — a fixed value, not the wall clock, so output stays deterministic.
func (*Book) Orientation ¶
func (b *Book) Orientation(o Orientation) *Book
Orientation sets the rendition:orientation hint.
type Orientation ¶
type Orientation int
Orientation is the rendition:orientation rendering hint.
const ( OrientationAuto Orientation = iota // default OrientationLandscape OrientationPortrait )
type Placement ¶
type Placement int
Placement controls which side of a facing-page spread a page lands on, emitted as the page's spine spread property.
const ( // PlacementAuto resolves at write time: the first page is centered (a // cover faces no partner), then pages alternate — RTL: right, left, // right, …; LTR: left, right, left, … — so consecutive pages land as // facing pairs. Explicit placements re-anchor the alternation. PlacementAuto Placement = iota PlacementLeft PlacementRight PlacementCenter )