pdfexport

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package pdfexport owns the printable export pipeline: adapter registration, JSONL ingestion, payload building, ordering, and PDF rendering.

Index

Constants

View Source
const (
	SansFontFamily   = sansFontFamily
	PDFFontSizeDelta = pdfFontSizeDelta

	PrimaryTextGray   = primaryTextGray
	SecondaryTextGray = secondaryTextGray
	RuleTextGray      = ruleTextGray
	DimTextGray       = dimTextGray

	ThinGridLineMM    = thinGridLineMM
	MajorGridLineMM   = majorGridLineMM
	OuterBorderLineMM = outerBorderLineMM

	InstructionLineHMM = instructionLineHMM

	PuzzleBottomInsetMM = puzzleBottomInsetMM
	WordSearchGridGapMM = wordSearchGridListGap

	PuzzleWordBankFontSize = puzzleWordBankFontSize
	PuzzleWordBankHeadSize = puzzleWordBankHeadSize
)
View Source
const ExportSchemaV1 = "puzzletea.export.v1"

Variables

This section is empty.

Functions

func CenteredOrigin

func CenteredOrigin(area Rect, cols, rows int, cellSize float64) (float64, float64)

func ClampStandardCellFontSize

func ClampStandardCellFontSize(fontSize float64) float64

func FitCompactCellSize

func FitCompactCellSize(cols, rows int, area Rect) float64

func FitHashiCellSize

func FitHashiCellSize(cols, rows int, area Rect) float64

func FitNonogramCellSize

func FitNonogramCellSize(cols, rows int, area Rect) float64

func FitSudokuCellSize

func FitSudokuCellSize(cols, rows int, area Rect) float64

func FitTableCellSize

func FitTableCellSize(cols, rows int, area Rect) float64

func FitWordSearchCellSize

func FitWordSearchCellSize(cols, rows int, area Rect) float64

func HasPrintAdapter added in v1.8.0

func HasPrintAdapter(gameType string) bool

func InstructionLineCount added in v1.9.0

func InstructionLineCount(pdf *fpdf.Fpdf, width float64, rules []string) int

func InstructionY

func InstructionY(boardBottom, pageH float64, lineCount int) float64

func IsNilPrintPayload added in v1.8.0

func IsNilPrintPayload(payload any) bool

func RegisterPrintAdapter added in v1.8.0

func RegisterPrintAdapter(adapter PrintAdapter)

func RenderInstructions added in v1.9.0

func RenderInstructions(pdf *fpdf.Fpdf, x, y, width float64, rules []string) int

func SetInstructionStyle

func SetInstructionStyle(pdf *fpdf.Fpdf)

func StandardCellFontSize

func StandardCellFontSize(cellSize, scale float64) float64

func WritePDF

func WritePDF(outputPath string, docs []PackDocument, puzzles []Puzzle, cfg RenderConfig) error

Types

type DifficultyConfidence

type DifficultyConfidence string
const (
	DifficultyConfidenceHigh   DifficultyConfidence = "high"
	DifficultyConfidenceMedium DifficultyConfidence = "medium"
)

type FillominoData

type FillominoData struct {
	Width  int
	Height int
	Givens [][]int
}

func ParseFillominoPrintData

func ParseFillominoPrintData(saveData []byte) (*FillominoData, error)

type GridTable

type GridTable struct {
	Rows         [][]string
	HasHeaderRow bool
	HasHeaderCol bool
}

type HashiData

type HashiData struct {
	Width   int
	Height  int
	Islands []HashiIsland
}

func ParseHashiPrintData

func ParseHashiPrintData(saveData []byte) (*HashiData, error)

type HashiIsland

type HashiIsland struct {
	X        int
	Y        int
	Required int
}

type HitoriData

type HitoriData struct {
	Size    int
	Numbers [][]string
}

func ParseHitoriPrintData

func ParseHitoriPrintData(saveData []byte) (*HitoriData, error)

type JSONLPackMeta

type JSONLPackMeta struct {
	Generated     string `json:"generated"`
	Version       string `json:"version"`
	Category      string `json:"category"`
	ModeSelection string `json:"mode_selection"`
	Count         int    `json:"count"`
	Seed          string `json:"seed"`
}

type JSONLPuzzle

type JSONLPuzzle struct {
	Index int             `json:"index"`
	Name  string          `json:"name"`
	Game  string          `json:"game"`
	Mode  string          `json:"mode"`
	Save  json.RawMessage `json:"save"`
}

type JSONLRecord

type JSONLRecord struct {
	Schema string        `json:"schema"`
	Pack   JSONLPackMeta `json:"pack"`
	Puzzle JSONLPuzzle   `json:"puzzle"`
}

type NetwalkData added in v1.9.0

type NetwalkData struct {
	Size      int
	Masks     [][]uint8
	Rotations [][]uint8
	RootX     int
	RootY     int
}

func ParseNetwalkPrintData added in v1.9.0

func ParseNetwalkPrintData(saveData []byte) (*NetwalkData, error)

type NonogramData

type NonogramData struct {
	Width    int
	Height   int
	RowHints [][]int
	ColHints [][]int
	Grid     [][]string
}

func ParseNonogramPrintData

func ParseNonogramPrintData(saveData []byte) (*NonogramData, error)

type NurikabeData

type NurikabeData struct {
	Width  int
	Height int
	Clues  [][]int
}

func ParseNurikabePrintData

func ParseNurikabePrintData(saveData []byte) (*NurikabeData, error)

type PackDocument

type PackDocument struct {
	SourcePath string
	Metadata   PackMetadata
	Puzzles    []Puzzle
}

func ParseJSONLFile

func ParseJSONLFile(path string) (PackDocument, error)

func ParseJSONLFiles

func ParseJSONLFiles(paths []string) ([]PackDocument, error)

type PackMetadata

type PackMetadata struct {
	GeneratedRaw   string
	GeneratedAt    time.Time
	Version        string
	Category       string
	ModeSelection  string
	Count          int
	Seed           string
	Format         string
	SourceFileName string
}

type PrintAdapter added in v1.8.0

type PrintAdapter interface {
	CanonicalGameType() string
	Aliases() []string
	BuildPDFPayload(save []byte) (any, error)
	RenderPDFBody(pdf *fpdf.Fpdf, payload any) error
}

func LookupPrintAdapter added in v1.8.0

func LookupPrintAdapter(gameType string) (PrintAdapter, bool)

type Puzzle

type Puzzle struct {
	SourcePath           string
	SourceFileName       string
	Category             string
	ModeSelection        string
	Name                 string
	Index                int
	Body                 string
	SaveData             []byte
	PrintPayload         any
	DifficultyScore      float64
	DifficultyConfidence DifficultyConfidence
	DifficultySource     string
}

func OrderPuzzlesForPrint

func OrderPuzzlesForPrint(puzzles []Puzzle, seed string) []Puzzle

type Rect

type Rect struct {
	X float64
	Y float64
	W float64
	H float64
}

func PuzzleBoardRect

func PuzzleBoardRect(pageW, pageH float64, pageNo, ruleLines int) Rect

func PuzzleBodyRect

func PuzzleBodyRect(pageW, pageH float64, pageNo int) Rect

type RenderConfig

type RenderConfig struct {
	Title         string
	CoverSubtitle string
	HeaderText    string
	VolumeNumber  int
	AdvertText    string
	GeneratedAt   time.Time
	ShuffleSeed   string
	SheetLayout   SheetLayout
}

type RippleEffectCage

type RippleEffectCage struct {
	Size  int                `json:"size"`
	Cells []RippleEffectCell `json:"cells"`
}

type RippleEffectCell

type RippleEffectCell struct {
	X int `json:"x"`
	Y int `json:"y"`
}

type RippleEffectData

type RippleEffectData struct {
	Width  int
	Height int
	Givens [][]int
	Cages  []RippleEffectCage
}

func ParseRippleEffectPrintData

func ParseRippleEffectPrintData(saveData []byte) (*RippleEffectData, error)

type SheetLayout added in v1.9.0

type SheetLayout int
const (
	SheetLayoutHalfLetter SheetLayout = iota
	SheetLayoutDuplexBooklet
)

type ShikakuData

type ShikakuData struct {
	Width  int
	Height int
	Clues  [][]int
}

func ParseShikakuPrintData

func ParseShikakuPrintData(saveData []byte) (*ShikakuData, error)

type SudokuData

type SudokuData struct {
	Givens [9][9]int `json:"givens"`
}

func ParseSudokuPrintData

func ParseSudokuPrintData(saveData []byte) (*SudokuData, error)

func ParseSudokuRGBPrintData added in v1.8.0

func ParseSudokuRGBPrintData(saveData []byte) (*SudokuData, error)

type TakuzuData

type TakuzuData struct {
	Size                int
	Givens              [][]string
	HorizontalRelations [][]string
	VerticalRelations   [][]string
	GroupEveryTwo       bool
}

func ParseTakuzuPlusPrintData added in v1.8.0

func ParseTakuzuPlusPrintData(saveData []byte) (*TakuzuData, error)

func ParseTakuzuPrintData

func ParseTakuzuPrintData(saveData []byte) (*TakuzuData, error)

type WordSearchData

type WordSearchData struct {
	Width  int        `json:"width"`
	Height int        `json:"height"`
	Grid   [][]string `json:"grid"`
	Words  []string   `json:"words"`
}

func ParseWordSearchPrintData

func ParseWordSearchPrintData(saveData []byte) (*WordSearchData, error)

Jump to

Keyboard shortcuts

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