Documentation
¶
Overview ¶
Package assembly defines PDFConcat's domain values and the neutral job tree: the ordered PDFs, blank pages, and directory groups that both the plan decoder and the command-line shortcut compile to.
Index ¶
- Constants
- Variables
- func AddCounts(a, b, limit int64) (int64, error)
- func AlignNames() []string
- func AnchorNames() []string
- func CheckBlankCount(count int64) error
- func CheckPathText(path string) error
- func JoinDir(dir, name string) string
- func OverflowNames() []string
- func PageSizeNames() []string
- func ResolvePath(base, what, name string) (string, error)
- func ValidateTextValue(text string) error
- type Anchor
- type ArgumentSource
- type BlankItem
- type BlankSpec
- type BlankStyle
- type Code
- type Color
- type Contribution
- type Error
- type Errors
- type Field
- type Fill
- type FitTarget
- type Flattened
- type Font
- type FontDigest
- type FontDigests
- type FontFileUse
- type HorizontalPlacement
- type Item
- type ItemKind
- type Job
- type LayeredStyle
- type Layout
- type Length
- type Location
- type Operand
- type Origin
- type Overflow
- type PageDim
- type PageGeometry
- type PageRange
- type PageSize
- type PathClass
- type PathStyle
- type Placement
- type Ref
- type ResolvedSpec
- type Run
- type RunKind
- type SizeSource
- type Source
- type SourceFile
- type SourceGeometry
- type SpecKey
- type Stage
- type TextAlign
- type TextSpec
- type TextStyle
- type Totals
- type VerticalPlacement
Constants ¶
const ( // AnchorTopLeft and the eight anchors after it are the nine anchor points of a page, in grid order. AnchorTopLeft Anchor = 1 // AnchorTop is the top edge, centered. AnchorTop Anchor = 2 // AnchorTopRight is the top right corner. AnchorTopRight Anchor = 3 // AnchorLeft is the left edge, centered. AnchorLeft Anchor = 4 // AnchorCenter is the middle of the page. AnchorCenter Anchor = 5 // AnchorRight is the right edge, centered. AnchorRight Anchor = 6 // AnchorBottomLeft is the bottom left corner. AnchorBottomLeft Anchor = 7 // AnchorBottom is the bottom edge, centered. AnchorBottom Anchor = 8 // AnchorBottomRight is the bottom right corner. AnchorBottomRight Anchor = 9 // PlaceLeft puts the left edge of the block at the anchor. PlaceLeft HorizontalPlacement = 1 // PlaceCenter centers the block on the anchor. PlaceCenter HorizontalPlacement = 2 // PlaceRight puts the right edge of the block at the anchor. PlaceRight HorizontalPlacement = 3 // PlaceTop hangs the block below the anchor. PlaceTop VerticalPlacement = 1 // PlaceMiddle centers the block on the anchor. PlaceMiddle VerticalPlacement = 2 // PlaceBottom stands the block above the anchor. PlaceBottom VerticalPlacement = 3 )
const ( // StageJob is the structural validity of the job tree and its limits. StageJob Stage = "job" // StagePath is path and font-file resolution. StagePath Stage = "path" // StageStyle is the values of the non-geometric appearance fields. StageStyle Stage = "style" // StageGeometry is page sizes and page totals. StageGeometry Stage = "geometry" // CodeInvalidJob means the job tree breaks a structural rule or limit. CodeInvalidJob Code = "job_invalid" // CodeBaseNotAbsolute means a base directory is not absolute. CodeBaseNotAbsolute Code = "base_not_absolute" // CodePathDriveRelative means a Windows path names a drive without a root (C:x). CodePathDriveRelative Code = "path_drive_relative" // CodePathRootedWithoutDrive means a Windows path has a root but no drive (\x or /x). CodePathRootedWithoutDrive Code = "path_rooted_without_drive" // CodeStyleInvalid means an appearance value is outside its domain. CodeStyleInvalid Code = "style_invalid" // CodeSizeUnresolved means a blank inherits a page size and no source page is available. CodeSizeUnresolved Code = "size_unresolved" // CodeSizeOutOfRange means the inherited page size is outside what a generated page can have. CodeSizeOutOfRange Code = "size_out_of_range" // CodeSourceEmpty means a source reports no pages. CodeSourceEmpty Code = "source_empty" // CodePageTotalExceeded means a page total passes the backend's integer boundary or the generated-page limit. CodePageTotalExceeded Code = "page_total_exceeded" CodeFontUnavailable Code = "font_unavailable" // MaxRelated bounds Error.Related. MaxRelated = 8 )
const ( // MaxNodes bounds the structural nodes of a job: items (PDF paths, blanks, groups) and the blank, text, // and font objects that style them. MaxNodes = 250_000 // MaxGroupDepth bounds the nesting of directory groups. MaxGroupDepth = 64 // MaxContributions bounds the PDF and blank items after groups are flattened. MaxContributions = 100_000 // MaxBlankCount bounds the pages of one blank item, so that a typo such as an extra digit cannot // ask for billions of pages. MaxBlankCount = 1_000_000 // MaxGeneratedPages bounds the sum of all blank counts. MaxGeneratedPages = 1_000_000 // ItemPDF is a source PDF. ItemPDF ItemKind = 1 // ItemBlank is Count consecutive generated pages sharing one style. ItemBlank ItemKind = 2 // ItemGroup is a directory prefix for nested items; it has no other effect on the sequence. ItemGroup ItemKind = 3 )
const ( // SizeExplicit means the blank's size was written. SizeExplicit SizeSource = 1 // SizeFromPrecedingLast means the blank took the last page of the nearest preceding source. SizeFromPrecedingLast SizeSource = 2 // SizeFromFollowingFirst means a leading blank took the first page of the first source. SizeFromFollowingFirst SizeSource = 3 // SizeFitTarget means implicit/inherit canvas resolution used the effective fit target directly. SizeFitTarget SizeSource = 4 // RunSource is the pages of one source occurrence. RunSource RunKind = 1 // RunGenerated is one distinct generated page repeated. RunGenerated RunKind = 2 // MaxOutputPages bounds domain page-number arithmetic to signed 32 bits. // The selected backend applies its own, potentially smaller resource-policy limit. MaxOutputPages = math.MaxInt32 )
const ( // PathStylePOSIX is the syntax of Linux and macOS: only "/" separates, and only a leading "/" anchors. PathStylePOSIX PathStyle = 1 // PathStyleWindows is the syntax of Windows: "/" and "\" separate; a drive letter and colon, or two // leading separators (UNC, verbatim, and device paths), anchor. PathStyleWindows PathStyle = 2 // PathRelative is anchored to a base directory. PathRelative PathClass = 1 // PathAbsolute is anchored to the filesystem root: a POSIX "/x", a Windows "C:\x" or "C:/x", or a UNC // "\\server\share\x". PathAbsolute PathClass = 2 // PathDriveRelative is a Windows "C:x": relative to the current directory of drive C, which depends on // process state outside the job. PathDriveRelative PathClass = 3 // PathRootedWithoutDrive is a Windows "\x" or "/x": rooted on the current drive, which depends on // process state outside the job. PathRootedWithoutDrive PathClass = 4 )
const ( // MaxLeading is the largest line height, as a multiple of the font size. MaxLeading float64 = 10 // MinLeading is the smallest line height, as a multiple of the font size. MinLeading float64 = 1 // MinFontSize is the smallest font size. MinFontSize Length = 1 // MaxTextRunes is the longest text of one generated page, in Unicode scalar values. MaxTextRunes = 10000 )
Built-in appearance defaults for generated blanks, and the limits of the values.
const ( // AlignLeft starts every line at the left edge of the block. AlignLeft TextAlign = 1 // AlignCenter centers every line in the block. AlignCenter TextAlign = 2 // AlignRight ends every line at the right edge of the block. AlignRight TextAlign = 3 // AlignJustify stretches every line but the last of a paragraph to the block's width. AlignJustify TextAlign = 4 // OverflowError rejects text that is too wide, too tall, or outside the page. It is the default. OverflowError Overflow = 1 // OverflowAllow places the text as specified even when it extends beyond the page. OverflowAllow Overflow = 2 )
const DefaultFontName = "default"
DefaultFontName is the plan spelling of the built-in font.
Variables ¶
var ( // ErrInvalidLength reports text that is not a length. ErrInvalidLength = errors.New("invalid length") // ErrInvalidColor reports text that is not a color or background. ErrInvalidColor = errors.New("invalid color") // ErrInvalidPageSize reports text that is not a page size. ErrInvalidPageSize = errors.New("invalid page size") // ErrUnknownName reports a name that is not one of the allowed names of an enumeration. ErrUnknownName = errors.New("unknown name") // ErrOutOfRange reports a value outside its documented domain: not finite, too small, or too large. ErrOutOfRange = errors.New("value out of range") // ErrInvalidText reports text that is not valid UTF-8 or is too long. ErrInvalidText = errors.New("invalid text") // ErrInvalidPath reports a path that no filesystem can hold. ErrInvalidPath = errors.New("invalid path") // ErrInvalidJob reports a structural fault in a job: an empty sequence, a malformed item, or a crossed limit. ErrInvalidJob = errors.New("invalid job") // ErrUnresolvedSize reports a generated page that inherits its size when no source page is available. ErrUnresolvedSize = errors.New(`page size "inherit" has no source page to inherit from; give the blank an explicit size`) )
Sentinel errors for the domain values. Every error returned by a parser or validator wraps one of them, so callers can classify a failure with errors.Is while the message stays specific.
var ErrBaseNotAbsolute = errors.New("base directory is not absolute")
ErrBaseNotAbsolute reports a base directory that is not an absolute path.
var ErrSourceGeometry = errors.New("source geometry does not match the flattened sources")
ErrSourceGeometry reports inspection results that do not match the flattened sources.
Functions ¶
func AddCounts ¶
AddCounts returns a+b, or an error when either is negative or the sum exceeds limit. It is the checked addition for page totals, so a sum can neither wrap nor pass its declared bound.
func CheckBlankCount ¶
CheckBlankCount checks that count is between 1 and MaxBlankCount.
func CheckPathText ¶
CheckPathText rejects paths that JSON cannot represent losslessly or that no filesystem can hold.
func JoinDir ¶
JoinDir resolves name against the base directory dir lexically: an absolute name stands alone, an empty name is dir itself, and otherwise the two are joined with "/". No filesystem is consulted.
func PageSizeNames ¶
func PageSizeNames() []string
PageSizeNames lists the paper names ParsePageSize accepts, in the order the documentation uses.
func ResolvePath ¶
ResolvePath resolves name against the absolute base directory base, lexically and under the rules of the host: an absolute name stands alone, and the result is cleaned. The text is a literal path, not a pattern or a URL, and no filesystem is consulted, so ".." is collapsed lexically. A name that depends on process state (a Windows "C:x" or "\x") is rejected, and what names the field in the message.
func ValidateTextValue ¶
ValidateTextValue checks that text is valid UTF-8 of at most MaxTextRunes characters.
Types ¶
type Anchor ¶
type Anchor uint8
Anchor selects the point on the page that a text block is attached to.
func ParseAnchor ¶
ParseAnchor resolves an anchor name (exact lower case).
func (Anchor) Horizontal ¶
func (a Anchor) Horizontal() HorizontalPlacement
Horizontal returns the horizontal component of the anchor, which is its column in the grid.
func (Anchor) Vertical ¶
func (a Anchor) Vertical() VerticalPlacement
Vertical returns the vertical component of the anchor, which is its row in the grid.
type ArgumentSource ¶
type ArgumentSource struct{}
ArgumentSource is the Source of jobs compiled from command-line operands. Ref N is the operand at zero-based position N, excluding the executable name.
type BlankItem ¶
type BlankItem struct {
// Style layers over the job defaults.
Style BlankStyle
// CountOrigin locates the "count" value, or the item when the count is implicit.
CountOrigin Origin
// Count is the number of consecutive pages, 1 to MaxBlankCount (see CheckBlankCount).
Count int64
}
BlankItem is the payload of an ItemBlank.
type BlankSpec ¶
BlankSpec is a fully resolved, directly renderable blank page. It is comparable and carries no provenance, so identical blanks can be rendered once and reused.
type BlankStyle ¶
BlankStyle is the partial, layerable description of a generated blank page. Layers combine with Over: per-item over plan defaults over the built-ins that Resolve applies.
func (*BlankStyle) IsZero ¶
func (s *BlankStyle) IsZero() bool
IsZero reports whether no field is set.
func (*BlankStyle) Over ¶
func (s *BlankStyle) Over(base *BlankStyle) BlankStyle
Over returns a style in which fields set on s win and the remaining fields come from base.
type Code ¶
type Code string
Code is a stable snake_case diagnostic identifier. Messages are not stable; codes are.
type Color ¶
type Color struct {
R, G, B uint8
}
Color is an sRGB color.
func ParseColor ¶
ParseColor parses #RGB or #RRGGBB (hexadecimal digits of either case).
type Contribution ¶
type Contribution struct {
// TextOverrides references the original item declarations, independent of appearance deduplication.
TextOverrides *TextStyle
// Path is the absolute, lexically cleaned path of a PDF; empty for a blank.
Path string
// Origin is the item that wrote the contribution; explain it with Locate.
Origin Origin
// Count is the number of pages of a blank; for a PDF it is 1, one occurrence of the source.
Count int64
// Index is the position of the contribution in Flattened.Contributions.
Index int
// File indexes Flattened.Files for a PDF and is -1 for a blank.
File int
// Style indexes Flattened.Styles for a blank and is -1 for a PDF.
Style int
Kind ItemKind
}
Contribution is one PDF or blank entry of the flattened sequence. Counts stay compact: a blank of a million pages is one Contribution.
type Error ¶
type Error struct {
// Consumers lists every affected flattened contribution in instruction order.
Consumers []Origin
// Err is the underlying cause, matched by [errors.Is] and [errors.As].
Err error
// Message states what is wrong and how to repair it.
Message string
Code Code
Stage Stage
// Related locates further contributions with the same problem, in input order, at most MaxRelated.
Related []Location
// Location is where the problem was written; for a shared problem, its first contribution.
Location Location
// Affected is the number of contributions the problem applies to.
Affected int64
}
Error is one located, coded problem found while resolving a job. Its shape matches the plan decoder's error: stage, code, location, and an actionable message.
func NewSharedError ¶
NewSharedError builds an error about a problem shared by several contributions. It is located at the first of origins, with the following origins (at most MaxRelated) as related locations; member is appended to each node's pointer. template supplies Stage, Code, Err, Message, and Affected.
type Errors ¶
type Errors []*Error
Errors is every problem one resolution step found, in input order. It is the error those steps return, so a caller reports all problems rather than the first.
func Diagnostics ¶
Diagnostics returns the diagnostics carried by err: those of an Errors, or err alone as an uncoded error when it is any other error, and nil for a nil error.
type Field ¶
type Field[T comparable] struct { Value T Origin Origin // contains filtered or unexported fields }
Field is a value of a layered style together with where it was written. The zero Field is unset.
func (Field[T]) ApplyTo ¶
func (f Field[T]) ApplyTo(target *T)
ApplyTo stores the held value in *target, and leaves *target alone when the field is unset.
type Fill ¶
Fill is the background of a generated page: a color, or no painting. The zero value paints nothing.
type FitTarget ¶ added in v0.2.0
type FitTarget string
FitTarget is an explicitly requested portrait paper target. The empty value means no fitting.
func ParseFitTarget ¶ added in v0.2.0
ParseFitTarget accepts only the two supported spellings; dimensions come from namedPageSizes.
type Flattened ¶
type Flattened struct {
// Source explains every Origin.
Source Source
// TextDefaults references the job defaults; callers must keep job declarations immutable.
TextDefaults *TextStyle
Contributions []Contribution
Files []SourceFile
Fonts []FontFileUse
Styles []LayeredStyle
// FitTo retains the effective global target declaration.
FitTo Field[FitTarget]
// GeneratedPages is the sum of the blank counts.
GeneratedPages int64
}
Flattened is the job as an ordered list of contributions with its distinct sources, fonts, and appearances, each in order of first use. Resolve turns it into a Layout once the sources' page geometry is known.
func Flatten ¶
Flatten expands the job's groups into the ordered contributions in one pass, resolving every path against its group's directory. It does not expand counts, copy subtrees, or deduplicate anything in the sequence. It retains references to the job's text declarations for exact provenance; callers must not mutate those declarations while using the flattened job. Validation ensures every limit; the problems found while resolving paths and appearance values are returned together as a Errors.
func (*Flattened) Resolve ¶
func (f *Flattened) Resolve(sources []SourceGeometry, fonts FontDigests) (*Layout, error)
Resolve takes the inspected sources (parallel to f.Files) and the loaded fonts' identities, and resolves every generated page's size, the distinct generated appearances, the output ranges and the compact runs. Leading blanks inherit the first page of the first source; every other blank inherits the last page of the nearest preceding source; an explicit size changes nothing for later blanks. All problems found are returned together as a Errors, in input order.
type Font ¶
type Font struct {
// File is the declared path of a font file; empty selects the built-in font.
File string
// Base is the directory File resolves against: the base of the scope that declared the font. It is
// fixed where the font is declared, before any layering, so a font keeps its own base wherever it is used.
Base string
}
Font selects the font of generated text: the built-in default, or a TrueType file. A font choice is one atomic value; it never layers member by member.
func FontFile ¶
FontFile returns a file-backed font declared in a scope whose base directory is base.
type FontDigest ¶
FontDigest is the SHA-256 identity of font file content.
type FontDigests ¶
type FontDigests func(path string) (FontDigest, bool)
FontDigests returns the content identity of the font file at an absolute path, or of the built-in font for the empty path. It reports false when the font was not loaded.
type FontFileUse ¶
type FontFileUse struct {
// Path is the absolute, lexically cleaned path.
Path string
// Declarations are each distinct declaration of this captured file, in input order.
Declarations []Origin
}
FontFileUse is one distinct font file a blank's text asks for.
type HorizontalPlacement ¶
type HorizontalPlacement uint8
HorizontalPlacement is where a text block sits relative to its anchor's x coordinate.
type Item ¶
type Item struct {
// Items are the members of an ItemGroup; never empty.
Items []Item
// Path is the declared path of an ItemPDF, relative to its group's base unless absolute.
Path string
// Blank is set for an ItemBlank.
Blank *BlankItem
// Dir is the declared directory of an ItemGroup, relative to the enclosing base unless absolute.
Dir Field[string]
Origin Origin
Kind ItemKind
}
Item is one entry of the ordered sequence.
func NewBlankItem ¶
func NewBlankItem(origin Origin, style *BlankStyle, count int64) (Item, error)
NewBlankItem returns an ItemBlank of count pages.
func NewGroupItem ¶
NewGroupItem returns an ItemGroup holding items.
type Job ¶
type Job struct {
// Source explains every Origin in the tree.
Source Source
// Items is the ordered sequence; never empty.
Items []Item
// Base is the initial base directory: the plan's directory, the --base-dir value, or the working
// directory. Plan output and the default font resolve against it.
Base string
// Output is the declared output path; unset when the job names none. It resolves against Base.
Output Field[string]
// FitTo is the optional global portrait target.
FitTo Field[FitTarget]
// Dir is the declared directory for the top-level items, relative to Base.
Dir Field[string]
// Defaults is the style every blank layers over. Its font resolves against Base.
Defaults BlankStyle
// Origin is the root.
Origin Origin
}
Job is the complete, unresolved description of an assembly. It is a bounded tree built once; flattening it into contributions is a separate step that keeps every Origin.
func NewOperandJob ¶
NewOperandJob compiles ordered direct operands into the same Job a plan produces. Paths resolve against workingDir, which must be absolute; each Origin is the operand's argv position. The result is validated.
type LayeredStyle ¶
type LayeredStyle struct {
Style BlankStyle
// FirstUse is the first blank that has this appearance.
FirstUse Origin
}
LayeredStyle is one distinct appearance after item over job defaults, before page sizes are known. Values deduplicate independently of declaration origins; each consumer retains its original declaration layer. A file font's effective path is absolute with no base.
type Layout ¶
type Layout struct {
Source Source
Flat *Flattened
// Placements parallels Flat.Contributions.
Placements []Placement
Specs []ResolvedSpec
Runs []Run
Totals Totals
}
Layout is the resolved output order: every contribution's pages, the distinct generated appearances, and the compact runs the engine assembles. Every sum was checked.
type Length ¶
type Length float64
Length is a distance in PDF user-space units (points, 1/72 inch).
const ( // MaxLength bounds the magnitude of every length: the PDF implementation limit for page dimensions // (200 inches). MaxLength Length = 14400 )
func ParseLength ¶
ParseLength parses a decimal number with an optional unit suffix (pt, mm, cm, in) and no surrounding space. A bare number is in points. The result is finite and within ±MaxLength.
type Location ¶
Location is an Origin explained: where a value was written.
type Operand ¶
type Operand struct {
// Path is the PDF path, taken literally; unused for a blank.
Path string
// Position is the zero-based position of the argument in argv, excluding the executable name.
Position int
// Blank marks the --blank directive: one generated page that inherits its size.
Blank bool
}
Operand is one ordered direct operand of the command line: a PDF path, or the --blank directive.
type Origin ¶
type Origin struct {
// Offset is the absolute byte offset of the value in the original document, including any
// leading byte order mark. It is zero for command-line sources.
Offset int64
// Ref is the item (or the root) that contains the value.
Ref Ref
}
Origin locates one value in the job's Source. It is small because every styled field carries one.
type Overflow ¶
type Overflow uint8
Overflow is the policy for text that does not fit its box or page.
func ParseOverflow ¶
ParseOverflow resolves an overflow policy name (exact lower case).
type PageDim ¶
type PageDim struct {
Width, Height Length
}
PageDim is the displayed width and height of one page, in points.
func NewPageDim ¶
NewPageDim checks that both sides are finite and between MinPageSide and MaxPageSide.
type PageGeometry ¶
type PageGeometry struct {
Width, Height float64
}
PageGeometry is the visible size of one source page in physical points.
type PageRange ¶
type PageRange struct {
Start, End, Count int64
}
PageRange is a run of output pages, 1-based and inclusive.
type PageSize ¶
PageSize describes the page size of a generated blank: either the size inherited from a neighboring source page or an explicit size.
func ParsePageSize ¶
ParsePageSize parses "inherit", a paper name (A3, A4, A5, B4, B5, Letter, Legal, Tabloid; portrait, exact case), or WIDTHxHEIGHT with an optional unit shared by both sides, such as 210x297mm or 8.5x11in.
type PathClass ¶
type PathClass uint8
PathClass says how a path is anchored.
func ClassifyPath ¶
ClassifyPath says how path is anchored under the syntax rules of style. It reads the text only; it never consults a filesystem, so it makes no claim that a path means the same thing on another host.
type PathStyle ¶
type PathStyle uint8
PathStyle is a family of path syntax rules. Classification is pure string work, so the rules of every style are testable on every host; only HostPathStyle ever decides a real resolution.
func HostPathStyle ¶
func HostPathStyle() PathStyle
HostPathStyle returns the style of the running operating system.
type Placement ¶
type Placement struct {
// Range is the output pages the contribution covers.
Range PageRange
// Spec indexes Layout.Specs for a blank and is -1 for a PDF.
Spec int
// SizeFrom is the contribution whose page supplied an inherited size; -1 unless SizeSource is
// not SizeExplicit.
SizeFrom int
// Size says how a blank got its size.
Size SizeSource
}
Placement is the resolved position of one contribution in the output.
type Ref ¶
type Ref uint32
Ref identifies a node of a job's source. A JSON plan numbers its nodes in reading order from the root (Ref 0); a command line numbers its operands from zero, excluding the executable name. The Source that created a job turns a Ref into a pointer.
type ResolvedSpec ¶
type ResolvedSpec struct {
// Origins locates the first contributions that use the spec, in input order, at most MaxRelated+1.
Origins []Origin
Spec BlankSpec
Declared TextStyle
// Uses is the number of contributions that use the spec.
Uses int64
FontDigest FontDigest
}
ResolvedSpec is one distinct generated page appearance.
type Run ¶
type Run struct {
// Index is the Layout.Specs index of a generated run, or the Flattened.Files index of a source run.
Index int
// FirstPage is the first source page of a source run (always 1, whole files); 0 for a generated run.
FirstPage int64
// Count is the number of source pages, or the repeat count of a generated page.
Count int64
Kind RunKind
}
Run is a compact piece of the output order for the engine.
type Source ¶
type Source interface {
// Name is the file name, "<stdin>", "<inline>", or "argv".
Name() string
// Pointer returns the JSON pointer of the node (such as "/items/42/items/3"), with member appended
// for a field of that node (such as "/count"), or "argv:N" for a command-line operand.
Pointer(ref Ref, member string) string
// Position returns the 1-based line and byte column of an offset, or 0, 0 when the source has none.
Position(offset int64) (int, int)
}
Source describes the document a job was read from, so an Origin can be explained. Implementations are the plan decoder's document and ArgumentSource.
type SourceFile ¶
type SourceFile struct {
Path string
// FirstUse is the first contribution that names the file.
FirstUse Origin
// Uses is the number of occurrences; repeated sources are never merged in the sequence.
Uses int
}
SourceFile is one distinct source PDF, identified by its normalized path.
type SourceGeometry ¶
type SourceGeometry struct {
First, Last PageGeometry
Pages int64
}
SourceGeometry is what inspecting one source tells the layout: its page count and the visible geometry of its first and last pages.
type SpecKey ¶
type SpecKey struct {
Spec BlankSpec
FontDigest FontDigest
}
SpecKey identifies a distinct generated page: the resolved appearance plus the font's content.
type TextAlign ¶
type TextAlign uint8
TextAlign is the justification of lines within a text block.
func ParseTextAlign ¶
ParseTextAlign resolves an alignment name (exact lower case).
type TextSpec ¶
type TextSpec struct {
Value string
Font Font
Size Length
X, Y Length
Width Length
Leading float64
Color Color
Anchor Anchor
Align TextAlign
Overflow Overflow
}
TextSpec is the fully resolved text of a blank. An empty Value means no text.
type TextStyle ¶
type TextStyle struct {
Font Field[Font]
Value Field[string]
Size Field[Length]
Color Field[Color]
Anchor Field[Anchor]
X Field[Length]
Y Field[Length]
Width Field[Length]
Align Field[TextAlign]
Leading Field[float64]
Overflow Field[Overflow]
}
TextStyle is the partial, layerable description of the text printed on a blank. An empty Value means no text.
type Totals ¶
type Totals struct {
Source, Generated, Total int64
}
Totals are the page counts of an output.
type VerticalPlacement ¶
type VerticalPlacement uint8
VerticalPlacement is where a text block sits relative to its anchor's y coordinate.