Documentation
¶
Index ¶
- func FromImage(src image.Image) *semantic.Image
- func ImageFromFile(path string) (*semantic.Image, error)
- type AppearanceGenerator
- type CellPadding
- type Color
- type FormBuilder
- type HAlign
- type ImageOptions
- type LineOptions
- type Outline
- type PDFBuilder
- type PageBuilder
- type PathOptions
- type RectOptions
- type Table
- type TableCell
- type TableOptions
- type TableRow
- type TextOptions
- type VAlign
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AppearanceGenerator ¶
AppearanceGenerator handles the generation of appearance streams for form fields.
func NewAppearanceGenerator ¶
func NewAppearanceGenerator(form *semantic.AcroForm) *AppearanceGenerator
type CellPadding ¶
type CellPadding struct {
Top, Right, Bottom, Left float64
}
CellPadding defines per-side padding.
type FormBuilder ¶
type FormBuilder interface {
// SetText sets the value of a text field.
SetText(name, value string) FormBuilder
// SetCheckbox sets the state of a checkbox.
SetCheckbox(name string, checked bool) FormBuilder
// SetChoice sets the selected value of a choice field (combo box or list box).
SetChoice(name, value string) FormBuilder
// Finish returns to the PDFBuilder.
Finish() PDFBuilder
}
FormBuilder provides a fluent API for form filling.
type ImageOptions ¶
ImageOptions configures image drawing.
type LineOptions ¶
type LineOptions struct {
StrokeColor Color
LineWidth float64
LineCap contentstream.LineCap
DashPattern []float64
DashPhase float64
}
LineOptions configures line drawing.
type Outline ¶
type Outline struct {
Title string
Page *semantic.Page
PageIndex int
X *float64
Y *float64
Zoom *float64
Children []Outline
}
Outline defines a bookmark entry for the builder API. Page or PageIndex can be set; if both are provided, Page takes precedence.
type PDFBuilder ¶
type PDFBuilder interface {
NewPage(width, height float64) PageBuilder
AddPage(page *semantic.Page) PDFBuilder
SetInfo(info *semantic.DocumentInfo) PDFBuilder
SetMetadata(xmp []byte) PDFBuilder
SetLanguage(lang string) PDFBuilder
SetMarked(marked bool) PDFBuilder
AddPageLabel(pageIndex int, prefix string) PDFBuilder
AddOutline(out Outline) PDFBuilder
SetEncryption(ownerPassword, userPassword string, perms raw.Permissions, encryptMetadata bool) PDFBuilder
RegisterFont(name string, font *semantic.Font) PDFBuilder
RegisterTrueTypeFont(name string, data []byte) PDFBuilder
AddEmbeddedFile(file semantic.EmbeddedFile) PDFBuilder
SetCalculationOrder(fields []semantic.FormField) PDFBuilder
Form() FormBuilder
Build() (*semantic.Document, error)
}
PDFBuilder provides a fluent API for PDF construction.
type PageBuilder ¶
type PageBuilder interface {
DrawText(text string, x, y float64, opts TextOptions) PageBuilder
DrawPath(path *contentstream.Path, opts PathOptions) PageBuilder
DrawImage(img *semantic.Image, x, y, width, height float64, opts ImageOptions) PageBuilder
DrawRectangle(x, y, width, height float64, opts RectOptions) PageBuilder
DrawLine(x1, y1, x2, y2 float64, opts LineOptions) PageBuilder
DrawTable(table Table, opts TableOptions) PageBuilder
AddAnnotation(ann semantic.Annotation) PageBuilder
AddFormField(field semantic.FormField) PageBuilder
SetMediaBox(box semantic.Rectangle) PageBuilder
SetCropBox(box semantic.Rectangle) PageBuilder
SetRotation(degrees int) PageBuilder
Finish() PDFBuilder
}
PageBuilder provides a fluent API for page construction.
type PathOptions ¶
type PathOptions struct {
StrokeColor Color
FillColor Color
LineWidth float64
LineCap contentstream.LineCap
LineJoin contentstream.LineJoin
DashPattern []float64
DashPhase float64
Fill bool
Stroke bool
}
PathOptions configures path drawing.
type RectOptions ¶
type RectOptions = PathOptions
RectOptions configures rectangle drawing (defaults to stroke if neither fill nor stroke is set).
type TableCell ¶
type TableCell struct {
Text string
Font string
FontSize float64
Padding *CellPadding
BackgroundColor Color
TextColor Color
BorderColor Color
BorderWidth float64
ColSpan int
HAlign HAlign
VAlign VAlign
Tag string
}
TableCell configures individual table cell rendering.
type TableOptions ¶
type TableOptions struct {
X float64
Y float64
RowHeight float64
CellPadding float64
BorderColor Color
BorderWidth float64
HeaderFill Color
RepeatHeaders bool
Tagged bool
BottomMargin float64
DefaultFont string
DefaultSize float64
TopMargin float64
LeftMargin float64
}
TableOptions configures table rendering.
type TextOptions ¶
type TextOptions struct {
Font string
FontSize float64
Color Color
RenderMode contentstream.TextRenderMode
CharSpacing float64
WordSpacing float64
HorizScaling float64
Rise float64
Tag string
MCID *int
Rotate float64 // Rotation in degrees (counter-clockwise)
}
TextOptions configures text drawing.