HomeUniDoc
...

Package creator

Overview ▾

Package creator is used for quickly generating pages and content with a simple interface. It is built on top of the model package to provide access to the most common operations such as creating text and image reports and manipulating existing pages.

Index ▾

Constants
Variables
type AnchorPoint
type Background
    func (b *Background) SetBorderRadius(topLeft, topRight, bottomLeft, bottomRight float64)
type Block
    func NewBlock(width float64, height float64) *Block
    func NewBlockFromPage(page *model.PdfPage) (*Block, error)
    func (blk *Block) AddAnnotation(annotation *model.PdfAnnotation)
    func (blk *Block) Angle() float64
    func (blk *Block) Draw(d Drawable) error
    func (blk *Block) DrawTemplate(c *Creator, r io.Reader, data interface{}, options *TemplateOptions) error
    func (blk *Block) DrawWithContext(d Drawable, ctx DrawContext) error
    func (blk *Block) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (blk *Block) GetMargins() (float64, float64, float64, float64)
    func (blk *Block) Height() float64
    func (blk *Block) RotatedSize() (float64, float64)
    func (blk *Block) Scale(sx, sy float64)
    func (blk *Block) ScaleToHeight(h float64)
    func (blk *Block) ScaleToWidth(w float64)
    func (blk *Block) SetAngle(angleDeg float64)
    func (blk *Block) SetMargins(left, right, top, bottom float64)
    func (blk *Block) SetPos(x, y float64)
    func (blk *Block) Width() float64
type CellBorderSide
type CellBorderStyle
type CellHorizontalAlignment
type CellVerticalAlignment
type Chapter
    func (chap *Chapter) Add(d Drawable) error
    func (chap *Chapter) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (chap *Chapter) GetHeading() *Paragraph
    func (chap *Chapter) GetMargins() (float64, float64, float64, float64)
    func (chap *Chapter) NewSubchapter(title string) *Chapter
    func (chap *Chapter) SetIncludeInTOC(includeInTOC bool)
    func (chap *Chapter) SetMargins(left, right, top, bottom float64)
    func (chap *Chapter) SetShowNumbering(show bool)
type Chart
    func NewChart(chart render.ChartRenderable) *Chart
    func (c *Chart) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (c *Chart) GetMargins() (float64, float64, float64, float64)
    func (c *Chart) Height() float64
    func (c *Chart) SetMargins(left, right, top, bottom float64)
    func (c *Chart) SetPos(x, y float64)
    func (c *Chart) Width() float64
type Color
    func ColorCMYKFrom8bit(c, m, y, k byte) Color
    func ColorCMYKFromArithmetic(c, m, y, k float64) Color
    func ColorRGBFrom8bit(r, g, b byte) Color
    func ColorRGBFromArithmetic(r, g, b float64) Color
    func ColorRGBFromHex(hexStr string) Color
type ColorPoint
    func NewColorPoint(color Color, point float64) *ColorPoint
type Creator
    func New() *Creator
    func (c *Creator) AddPage(page *model.PdfPage) error
    func (c *Creator) Context() DrawContext
    func (c *Creator) CreateFrontPage(genFrontPageFunc func(args FrontpageFunctionArgs))
    func (c *Creator) CreateTableOfContents(genTOCFunc func(toc *TOC) error)
    func (c *Creator) Draw(d Drawable) error
    func (c *Creator) DrawFooter(drawFooterFunc func(footer *Block, args FooterFunctionArgs))
    func (c *Creator) DrawHeader(drawHeaderFunc func(header *Block, args HeaderFunctionArgs))
    func (c *Creator) DrawTemplate(r io.Reader, data interface{}, options *TemplateOptions) error
    func (c *Creator) EnableFontSubsetting(font *model.PdfFont)
    func (c *Creator) Finalize() error
    func (c *Creator) Flip(flipH, flipV bool) error
    func (c *Creator) GetOptimizer() model.Optimizer
    func (c *Creator) Height() float64
    func (c *Creator) MoveDown(dy float64)
    func (c *Creator) MoveRight(dx float64)
    func (c *Creator) MoveTo(x, y float64)
    func (c *Creator) MoveX(x float64)
    func (c *Creator) MoveY(y float64)
    func (c *Creator) NewChapter(title string) *Chapter
    func (c *Creator) NewCurve(x1, y1, cx, cy, x2, y2 float64) *Curve
    func (c *Creator) NewCurvePolygon(rings [][]draw.CubicBezierCurve) *CurvePolygon
    func (c *Creator) NewDivision() *Division
    func (c *Creator) NewEllipse(xc, yc, width, height float64) *Ellipse
    func (c *Creator) NewFilledCurve() *FilledCurve
    func (c *Creator) NewImage(img *model.Image) (*Image, error)
    func (c *Creator) NewImageFromData(data []byte) (*Image, error)
    func (c *Creator) NewImageFromFile(path string) (*Image, error)
    func (c *Creator) NewImageFromGoImage(goimg goimage.Image) (*Image, error)
    func (c *Creator) NewInvoice() *Invoice
    func (c *Creator) NewLine(x1, y1, x2, y2 float64) *Line
    func (c *Creator) NewLinearGradientColor(colorPoints []*ColorPoint) *LinearShading
    func (c *Creator) NewList() *List
    func (c *Creator) NewPage() *model.PdfPage
    func (c *Creator) NewPageBreak() *PageBreak
    func (c *Creator) NewParagraph(text string) *Paragraph
    func (c *Creator) NewPolyBezierCurve(curves []draw.CubicBezierCurve) *PolyBezierCurve
    func (c *Creator) NewPolygon(points [][]draw.Point) *Polygon
    func (c *Creator) NewPolyline(points []draw.Point) *Polyline
    func (c *Creator) NewRadialGradientColor(x float64, y float64, innerRadius float64, outerRadius float64, colorPoints []*ColorPoint) *RadialShading
    func (c *Creator) NewRectangle(x, y, width, height float64) *Rectangle
    func (c *Creator) NewStyledParagraph() *StyledParagraph
    func (c *Creator) NewStyledTOCLine(number, title, page TextChunk, level uint, style TextStyle) *TOCLine
    func (c *Creator) NewTOC(title string) *TOC
    func (c *Creator) NewTOCLine(number, title, page string, level uint) *TOCLine
    func (c *Creator) NewTable(cols int) *Table
    func (c *Creator) NewTextStyle() TextStyle
    func (c *Creator) PageFinalize(pageFinalizeFunc func(args PageFinalizeFunctionArgs) error)
    func (c *Creator) RotateDeg(angleDeg int64) error
    func (c *Creator) SetForms(form *model.PdfAcroForm) error
    func (c *Creator) SetOptimizer(optimizer model.Optimizer)
    func (c *Creator) SetOutlineTree(outlineTree *model.PdfOutlineTreeNode)
    func (c *Creator) SetPageLabels(pageLabels core.PdfObject)
    func (c *Creator) SetPageMargins(left, right, top, bottom float64)
    func (c *Creator) SetPageSize(size PageSize)
    func (c *Creator) SetPdfWriterAccessFunc(pdfWriterAccessFunc func(writer *model.PdfWriter) error)
    func (c *Creator) SetTOC(toc *TOC)
    func (c *Creator) TOC() *TOC
    func (c *Creator) Width() float64
    func (c *Creator) Write(ws io.Writer) error
    func (c *Creator) WriteToFile(outputPath string) error
type Curve
    func (c *Curve) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (c *Curve) SetColor(col Color)
    func (c *Curve) SetWidth(width float64)
type CurvePolygon
    func (p *CurvePolygon) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (p *CurvePolygon) SetBorderColor(color Color)
    func (p *CurvePolygon) SetBorderOpacity(opacity float64)
    func (p *CurvePolygon) SetBorderWidth(borderWidth float64)
    func (p *CurvePolygon) SetFillColor(color Color)
    func (p *CurvePolygon) SetFillOpacity(opacity float64)
type Division
    func (div *Division) Add(d VectorDrawable) error
    func (div *Division) EnablePageWrap(enable bool)
    func (div *Division) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (div *Division) Height() float64
    func (div *Division) Inline() bool
    func (div *Division) Margins() (left, right, top, bottom float64)
    func (div *Division) Padding() (left, right, top, bottom float64)
    func (div *Division) SetBackground(background *Background)
    func (div *Division) SetInline(inline bool)
    func (div *Division) SetMargins(left, right, top, bottom float64)
    func (div *Division) SetPadding(left, right, top, bottom float64)
    func (div *Division) Width() float64
type DrawContext
type Drawable
type Ellipse
    func (ell *Ellipse) BorderColor() Color
    func (ell *Ellipse) BorderOpacity() float64
    func (ell *Ellipse) BorderWidth() float64
    func (ell *Ellipse) FillColor() Color
    func (ell *Ellipse) FillOpacity() float64
    func (ell *Ellipse) FitMode() FitMode
    func (ell *Ellipse) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (ell *Ellipse) GetCoords() (float64, float64)
    func (ell *Ellipse) GetMargins() (float64, float64, float64, float64)
    func (ell *Ellipse) Height() float64
    func (ell *Ellipse) Positioning() Positioning
    func (ell *Ellipse) Scale(xFactor, yFactor float64)
    func (ell *Ellipse) ScaleToHeight(h float64)
    func (ell *Ellipse) ScaleToWidth(w float64)
    func (ell *Ellipse) SetBorderColor(col Color)
    func (ell *Ellipse) SetBorderOpacity(opacity float64)
    func (ell *Ellipse) SetBorderWidth(bw float64)
    func (ell *Ellipse) SetCoords(xc, yc float64)
    func (ell *Ellipse) SetFillColor(col Color)
    func (ell *Ellipse) SetFillOpacity(opacity float64)
    func (ell *Ellipse) SetFitMode(fitMode FitMode)
    func (ell *Ellipse) SetHeight(height float64)
    func (ell *Ellipse) SetMargins(left, right, top, bottom float64)
    func (ell *Ellipse) SetPositioning(position Positioning)
    func (ell *Ellipse) SetWidth(width float64)
    func (ell *Ellipse) Width() float64
type FilledCurve
    func (fc *FilledCurve) AppendCurve(curve draw.CubicBezierCurve) *FilledCurve
    func (fc *FilledCurve) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (fc *FilledCurve) SetBorderColor(color Color)
    func (fc *FilledCurve) SetFillColor(color Color)
type FitMode
type FooterFunctionArgs
type FrontpageFunctionArgs
type GraphicSVG
    func NewGraphicSVGFromFile(path string) (*GraphicSVG, error)
    func NewGraphicSVGFromString(svgStr string) (*GraphicSVG, error)
    func (gs *GraphicSVG) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (gs *GraphicSVG) GetMargins() (float64, float64, float64, float64)
    func (gs *GraphicSVG) Height() float64
    func (gs *GraphicSVG) Scale(xFactor, yFactor float64)
    func (gs *GraphicSVG) ScaleToHeight(h float64)
    func (gs *GraphicSVG) ScaleToWidth(w float64)
    func (gs *GraphicSVG) SetMargins(left, right, top, bottom float64)
    func (gs *GraphicSVG) SetPos(x, y float64)
    func (gs *GraphicSVG) Width() float64
type HeaderFunctionArgs
type HorizontalAlignment
type Image
    func (img *Image) ConvertToBinary() error
    func (img *Image) Crop(x0, y0, x1, y1 int)
    func (img *Image) FitMode() FitMode
    func (img *Image) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (img *Image) GetHorizontalAlignment() HorizontalAlignment
    func (img *Image) GetMargins() (float64, float64, float64, float64)
    func (img *Image) Height() float64
    func (img *Image) Lazy() bool
    func (img *Image) Scale(xFactor, yFactor float64)
    func (img *Image) ScaleToHeight(h float64)
    func (img *Image) ScaleToWidth(w float64)
    func (img *Image) SetAngle(angle float64)
    func (img *Image) SetEncoder(encoder core.StreamEncoder)
    func (img *Image) SetFitMode(fitMode FitMode)
    func (img *Image) SetHeight(h float64)
    func (img *Image) SetHorizontalAlignment(alignment HorizontalAlignment)
    func (img *Image) SetLazy(lazy bool)
    func (img *Image) SetMargins(left, right, top, bottom float64)
    func (img *Image) SetOpacity(opacity float64)
    func (img *Image) SetPos(x, y float64)
    func (img *Image) SetWidth(w float64)
    func (img *Image) Width() float64
type Invoice
    func (i *Invoice) AddInfo(description, value string) (*InvoiceCell, *InvoiceCell)
    func (i *Invoice) AddLine(values ...string) []*InvoiceCell
    func (i *Invoice) AddSection(title, content string)
    func (i *Invoice) AddTotalLine(desc, value string) (*InvoiceCell, *InvoiceCell)
    func (i *Invoice) AddressHeadingStyle() TextStyle
    func (i *Invoice) AddressStyle() TextStyle
    func (i *Invoice) AppendColumn(description string) *InvoiceCell
    func (i *Invoice) BuyerAddress() *InvoiceAddress
    func (i *Invoice) Columns() []*InvoiceCell
    func (i *Invoice) Date() (*InvoiceCell, *InvoiceCell)
    func (i *Invoice) DueDate() (*InvoiceCell, *InvoiceCell)
    func (i *Invoice) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (i *Invoice) InfoLines() [][2]*InvoiceCell
    func (i *Invoice) InsertColumn(index uint, description string) *InvoiceCell
    func (i *Invoice) Lines() [][]*InvoiceCell
    func (i *Invoice) Logo() *Image
    func (i *Invoice) NewCell(value string) *InvoiceCell
    func (i *Invoice) NewCellProps() InvoiceCellProps
    func (i *Invoice) NewColumn(description string) *InvoiceCell
    func (i *Invoice) NoteHeadingStyle() TextStyle
    func (i *Invoice) NoteStyle() TextStyle
    func (i *Invoice) Notes() (string, string)
    func (i *Invoice) Number() (*InvoiceCell, *InvoiceCell)
    func (i *Invoice) Sections() [][2]string
    func (i *Invoice) SellerAddress() *InvoiceAddress
    func (i *Invoice) SetAddressHeadingStyle(style TextStyle)
    func (i *Invoice) SetAddressStyle(style TextStyle)
    func (i *Invoice) SetBuyerAddress(address *InvoiceAddress)
    func (i *Invoice) SetColumns(cols []*InvoiceCell)
    func (i *Invoice) SetDate(date string) (*InvoiceCell, *InvoiceCell)
    func (i *Invoice) SetDueDate(dueDate string) (*InvoiceCell, *InvoiceCell)
    func (i *Invoice) SetLogo(logo *Image)
    func (i *Invoice) SetNoteHeadingStyle(style TextStyle)
    func (i *Invoice) SetNoteStyle(style TextStyle)
    func (i *Invoice) SetNotes(title, content string)
    func (i *Invoice) SetNumber(number string) (*InvoiceCell, *InvoiceCell)
    func (i *Invoice) SetSellerAddress(address *InvoiceAddress)
    func (i *Invoice) SetSubtotal(value string)
    func (i *Invoice) SetTerms(title, content string)
    func (i *Invoice) SetTitle(title string)
    func (i *Invoice) SetTitleStyle(style TextStyle)
    func (i *Invoice) SetTotal(value string)
    func (i *Invoice) Subtotal() (*InvoiceCell, *InvoiceCell)
    func (i *Invoice) Terms() (string, string)
    func (i *Invoice) Title() string
    func (i *Invoice) TitleStyle() TextStyle
    func (i *Invoice) Total() (*InvoiceCell, *InvoiceCell)
    func (i *Invoice) TotalLines() [][2]*InvoiceCell
type InvoiceAddress
type InvoiceCell
type InvoiceCellProps
type Line
    func (l *Line) Color() Color
    func (l *Line) DashPattern() (dashArray []int64, dashPhase int64)
    func (l *Line) FitMode() FitMode
    func (l *Line) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (l *Line) GetCoords() (float64, float64, float64, float64)
    func (l *Line) GetMargins() (float64, float64, float64, float64)
    func (l *Line) Height() float64
    func (l *Line) Length() float64
    func (l *Line) LineWidth() float64
    func (l *Line) Opacity() float64
    func (l *Line) Positioning() Positioning
    func (l *Line) SetColor(color Color)
    func (l *Line) SetDashPattern(dashArray []int64, dashPhase int64)
    func (l *Line) SetFitMode(fitMode FitMode)
    func (l *Line) SetLineWidth(width float64)
    func (l *Line) SetMargins(left, right, top, bottom float64)
    func (l *Line) SetOpacity(opacity float64)
    func (l *Line) SetPositioning(positioning Positioning)
    func (l *Line) SetStyle(style draw.LineStyle)
    func (l *Line) Style() draw.LineStyle
    func (l *Line) Width() float64
type LinearShading
    func (sh *LinearShading) AddColorStop(color Color, point float64)
    func (sh *LinearShading) AddPatternResource(block *Block) (patternName core.PdfObjectName, err error)
    func (sh *LinearShading) AddShadingResource(block *Block) (shadingName core.PdfObjectName, err error)
    func (sh *LinearShading) SetAngle(angle float64)
    func (sh *LinearShading) SetAntiAlias(enable bool)
    func (sh *LinearShading) SetBackgroundColor(backgroundColor Color)
    func (sh *LinearShading) SetBoundingBox(x, y, width, height float64)
    func (sh *LinearShading) SetExtends(start bool, end bool)
    func (sh *LinearShading) ToPdfShadingPattern() *model.PdfShadingPatternType2
    func (sh *LinearShading) ToRGB() (float64, float64, float64)
type List
    func (l *List) Add(item VectorDrawable) (*TextChunk, error)
    func (l *List) AddTextItem(text string) (*StyledParagraph, *TextChunk, error)
    func (l *List) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (l *List) Height() float64
    func (l *List) Indent() float64
    func (l *List) Margins() (float64, float64, float64, float64)
    func (l *List) Marker() *TextChunk
    func (l *List) SetIndent(indent float64)
    func (l *List) SetMargins(left, right, top, bottom float64)
    func (l *List) Width() float64
type Margins
    func (m *Margins) Horizontal() float64
    func (m *Margins) Vertical() float64
type PageBreak
    func (p *PageBreak) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
type PageFinalizeFunctionArgs
type PageSize
type Paragraph
    func (p *Paragraph) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (p *Paragraph) GetMargins() (float64, float64, float64, float64)
    func (p *Paragraph) Height() float64
    func (p *Paragraph) SetAngle(angle float64)
    func (p *Paragraph) SetColor(col Color)
    func (p *Paragraph) SetEnableWrap(enableWrap bool)
    func (p *Paragraph) SetFont(font *model.PdfFont)
    func (p *Paragraph) SetFontSize(fontSize float64)
    func (p *Paragraph) SetLineHeight(lineheight float64)
    func (p *Paragraph) SetMargins(left, right, top, bottom float64)
    func (p *Paragraph) SetMaxLines(maxLines int)
    func (p *Paragraph) SetPos(x, y float64)
    func (p *Paragraph) SetText(text string)
    func (p *Paragraph) SetTextAlignment(align TextAlignment)
    func (p *Paragraph) SetWidth(width float64)
    func (p *Paragraph) Text() string
    func (p *Paragraph) Width() float64
type PolyBezierCurve
    func (p *PolyBezierCurve) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (p *PolyBezierCurve) SetBorderColor(color Color)
    func (p *PolyBezierCurve) SetBorderOpacity(opacity float64)
    func (p *PolyBezierCurve) SetBorderWidth(borderWidth float64)
    func (p *PolyBezierCurve) SetFillColor(color Color)
    func (p *PolyBezierCurve) SetFillOpacity(opacity float64)
type Polygon
    func (p *Polygon) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (p *Polygon) SetBorderColor(color Color)
    func (p *Polygon) SetBorderOpacity(opacity float64)
    func (p *Polygon) SetBorderWidth(borderWidth float64)
    func (p *Polygon) SetFillColor(color Color)
    func (p *Polygon) SetFillOpacity(opacity float64)
type Polyline
    func (p *Polyline) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (p *Polyline) SetLineColor(color Color)
    func (p *Polyline) SetLineOpacity(opacity float64)
    func (p *Polyline) SetLineWidth(lineWidth float64)
type Positioning
    func (p Positioning) IsAbsolute() bool
    func (p Positioning) IsRelative() bool
type RadialShading
    func (sh *RadialShading) AddColorStop(color Color, point float64)
    func (sh *RadialShading) AddPatternResource(block *Block) (patternName core.PdfObjectName, err error)
    func (sh *RadialShading) AddShadingResource(block *Block) (shadingName core.PdfObjectName, err error)
    func (sh *RadialShading) SetAnchor(anchor AnchorPoint)
    func (sh *RadialShading) SetAntiAlias(enable bool)
    func (sh *RadialShading) SetBackgroundColor(backgroundColor Color)
    func (sh *RadialShading) SetBoundingBox(x, y, width, height float64)
    func (sh *RadialShading) SetExtends(start bool, end bool)
    func (sh *RadialShading) ToPdfShadingPattern() *model.PdfShadingPatternType3
    func (sh *RadialShading) ToRGB() (float64, float64, float64)
type Rectangle
    func (rect *Rectangle) BorderColor() Color
    func (rect *Rectangle) BorderOpacity() float64
    func (rect *Rectangle) BorderWidth() float64
    func (rect *Rectangle) FillColor() Color
    func (rect *Rectangle) FillOpacity() float64
    func (rect *Rectangle) FitMode() FitMode
    func (rect *Rectangle) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (rect *Rectangle) GetCoords() (float64, float64)
    func (rect *Rectangle) GetMargins() (float64, float64, float64, float64)
    func (rect *Rectangle) Height() float64
    func (rect *Rectangle) Positioning() Positioning
    func (rect *Rectangle) Scale(xFactor, yFactor float64)
    func (rect *Rectangle) ScaleToHeight(h float64)
    func (rect *Rectangle) ScaleToWidth(w float64)
    func (rect *Rectangle) SetBorderColor(col Color)
    func (rect *Rectangle) SetBorderOpacity(opacity float64)
    func (rect *Rectangle) SetBorderRadius(topLeft, topRight, bottomLeft, bottomRight float64)
    func (rect *Rectangle) SetBorderWidth(bw float64)
    func (rect *Rectangle) SetCoords(x, y float64)
    func (rect *Rectangle) SetFillColor(col Color)
    func (rect *Rectangle) SetFillOpacity(opacity float64)
    func (rect *Rectangle) SetFitMode(fitMode FitMode)
    func (rect *Rectangle) SetHeight(height float64)
    func (rect *Rectangle) SetMargins(left, right, top, bottom float64)
    func (rect *Rectangle) SetPositioning(position Positioning)
    func (rect *Rectangle) SetWidth(width float64)
    func (rect *Rectangle) Width() float64
type StyledParagraph
    func (p *StyledParagraph) AddExternalLink(text, url string) *TextChunk
    func (p *StyledParagraph) AddInternalLink(text string, page int64, x, y, zoom float64) *TextChunk
    func (p *StyledParagraph) Append(text string) *TextChunk
    func (p *StyledParagraph) EnableWordWrap(val bool)
    func (p *StyledParagraph) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (p *StyledParagraph) GetMargins() (float64, float64, float64, float64)
    func (p *StyledParagraph) Height() float64
    func (p *StyledParagraph) Insert(index uint, text string) *TextChunk
    func (p *StyledParagraph) Reset()
    func (p *StyledParagraph) SetAngle(angle float64)
    func (p *StyledParagraph) SetEnableWrap(enableWrap bool)
    func (p *StyledParagraph) SetLineHeight(lineheight float64)
    func (p *StyledParagraph) SetMargins(left, right, top, bottom float64)
    func (p *StyledParagraph) SetPos(x, y float64)
    func (p *StyledParagraph) SetText(text string) *TextChunk
    func (p *StyledParagraph) SetTextAlignment(align TextAlignment)
    func (p *StyledParagraph) SetTextOverflow(textOverflow TextOverflow)
    func (p *StyledParagraph) SetTextVerticalAlignment(align TextVerticalAlignment)
    func (p *StyledParagraph) SetWidth(width float64)
    func (p *StyledParagraph) Width() float64
type TOC
    func (t *TOC) Add(number, title, page string, level uint) *TOCLine
    func (t *TOC) AddLine(line *TOCLine) *TOCLine
    func (t *TOC) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (t *TOC) Heading() *StyledParagraph
    func (t *TOC) Lines() []*TOCLine
    func (t *TOC) SetHeading(text string, style TextStyle)
    func (t *TOC) SetLineLevelOffset(levelOffset float64)
    func (t *TOC) SetLineMargins(left, right, top, bottom float64)
    func (t *TOC) SetLineNumberStyle(style TextStyle)
    func (t *TOC) SetLinePageStyle(style TextStyle)
    func (t *TOC) SetLineSeparator(separator string)
    func (t *TOC) SetLineSeparatorStyle(style TextStyle)
    func (t *TOC) SetLineStyle(style TextStyle)
    func (t *TOC) SetLineTitleStyle(style TextStyle)
    func (t *TOC) SetShowLinks(showLinks bool)
type TOCLine
    func (tl *TOCLine) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (tl *TOCLine) GetMargins() (float64, float64, float64, float64)
    func (tl *TOCLine) Level() uint
    func (tl *TOCLine) LevelOffset() float64
    func (tl *TOCLine) Link() (page int64, x, y float64)
    func (tl *TOCLine) SetLevel(level uint)
    func (tl *TOCLine) SetLevelOffset(levelOffset float64)
    func (tl *TOCLine) SetLink(page int64, x, y float64)
    func (tl *TOCLine) SetMargins(left, right, top, bottom float64)
    func (tl *TOCLine) SetStyle(style TextStyle)
type Table
    func (table *Table) AddSubtable(row, col int, subtable *Table)
    func (table *Table) Cols() int
    func (table *Table) CurCol() int
    func (table *Table) CurRow() int
    func (table *Table) EnablePageWrap(enable bool)
    func (table *Table) EnableRowWrap(enable bool)
    func (table *Table) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
    func (table *Table) GetMargins() (float64, float64, float64, float64)
    func (table *Table) GetRowHeight(row int) (float64, error)
    func (table *Table) Height() float64
    func (table *Table) MultiCell(rowspan, colspan int) *TableCell
    func (table *Table) MultiColCell(colspan int) *TableCell
    func (table *Table) MultiRowCell(rowspan int) *TableCell
    func (table *Table) NewCell() *TableCell
    func (table *Table) Rows() int
    func (table *Table) SetColumnWidths(widths ...float64) error
    func (table *Table) SetCompactMode(enable bool)
    func (table *Table) SetHeaderRows(startRow, endRow int) error
    func (table *Table) SetMargins(left, right, top, bottom float64)
    func (table *Table) SetPos(x, y float64)
    func (table *Table) SetRowHeight(row int, h float64) error
    func (table *Table) SkipCells(num int)
    func (table *Table) SkipOver(rows, cols int)
    func (table *Table) SkipRows(num int)
    func (table *Table) Width() float64
type TableCell
    func (cell *TableCell) GetIndent() float64
    func (cell *TableCell) SetBackgroundColor(col Color)
    func (cell *TableCell) SetBorder(side CellBorderSide, style CellBorderStyle, width float64)
    func (cell *TableCell) SetBorderColor(col Color)
    func (cell *TableCell) SetBorderLineStyle(style draw.LineStyle)
    func (cell *TableCell) SetColPosition(col int)
    func (cell *TableCell) SetContent(vd VectorDrawable) error
    func (cell *TableCell) SetHorizontalAlignment(halign CellHorizontalAlignment)
    func (cell *TableCell) SetIndent(indent float64)
    func (cell *TableCell) SetRowPosition(row int)
    func (cell *TableCell) SetSideBorderColor(side CellBorderSide, col Color)
    func (cell *TableCell) SetSideBorderStyle(side CellBorderSide, style CellBorderStyle)
    func (cell *TableCell) SetSideBorderWidth(side CellBorderSide, width float64)
    func (cell *TableCell) SetVerticalAlignment(valign CellVerticalAlignment)
    func (cell *TableCell) Width(ctx DrawContext) float64
type TemplateOptions
type TextAlignment
type TextChunk
    func NewTextChunk(text string, style TextStyle) *TextChunk
    func (tc *TextChunk) Fit(width, height float64) (*TextChunk, error)
    func (tc *TextChunk) SetAnnotation(annotation *model.PdfAnnotation)
    func (tc *TextChunk) Width() float64
    func (tc *TextChunk) Wrap(width float64) ([]string, error)
type TextDecorationLineStyle
type TextOverflow
type TextRenderingMode
type TextStyle
type TextVerticalAlignment
type UnsupportedRuneError
    func (e UnsupportedRuneError) Error() string
type VectorDrawable

Package files

background.go block.go border.go chapters.go chart.go color.go const.go creator.go curve.go curve_polygon.go division.go doc.go drawable.go ellipse.go filled_curve.go graphic_svg.go image.go invoice.go line.go list.go pagebreak.go paragraph.go polybezier_curve.go polygon.go polyline.go rectangle.go shading.go styled_paragraph.go table.go template_node_util_compat.go template_processor.go text_chunk.go text_style.go toc.go toc_line.go utils.go

Constants

const (
    // DefaultHorizontalScaling represents the default horizontal scaling
    // percentage of paragraph text chunks.
    DefaultHorizontalScaling = 100
)

Variables

Commonly used colors.

var (
    ColorBlack  = ColorRGBFromArithmetic(0, 0, 0)
    ColorWhite  = ColorRGBFromArithmetic(1, 1, 1)
    ColorRed    = ColorRGBFromArithmetic(1, 0, 0)
    ColorGreen  = ColorRGBFromArithmetic(0, 1, 0)
    ColorBlue   = ColorRGBFromArithmetic(0, 0, 1)
    ColorYellow = ColorRGBFromArithmetic(1, 1, 0)
)

Commonly used page sizes

var (
    PageSizeA3     = PageSize{297 * PPMM, 420 * PPMM}
    PageSizeA4     = PageSize{210 * PPMM, 297 * PPMM}
    PageSizeA5     = PageSize{148 * PPMM, 210 * PPMM}
    PageSizeLetter = PageSize{8.5 * PPI, 11 * PPI}
    PageSizeLegal  = PageSize{8.5 * PPI, 14 * PPI}
)

Errors which may happen while creating PDF

var (
    ErrContentNotFit = errors.New("Cannot fit content into an existing space")
)

PPI specifies the default PDF resolution in points/inch.

var PPI float64 = 72 // Points per inch. (Default resolution).

PPMM specifies the default PDF resolution in points/mm. Points per mm. (Default resolution).

var PPMM = float64(72 * 1.0 / 25.4)

type AnchorPoint

AnchorPoint defines anchor point where the center position of the radial gradient would be calculated.

type AnchorPoint int

Anchor point options.

const (
    AnchorBottomLeft AnchorPoint = iota
    AnchorBottomRight
    AnchorTopLeft
    AnchorTopRight
    AnchorCenter
    AnchorLeft
    AnchorRight
    AnchorTop
    AnchorBottom
)

type Background

Background contains properties related to the background of a component.

type Background struct {
    FillColor               Color
    BorderColor             Color
    BorderSize              float64
    BorderRadiusTopLeft     float64
    BorderRadiusTopRight    float64
    BorderRadiusBottomLeft  float64
    BorderRadiusBottomRight float64
}

func (*Background) SetBorderRadius

func (b *Background) SetBorderRadius(topLeft, topRight, bottomLeft, bottomRight float64)

SetBorderRadius sets the radius of the background corners.

type Block

Block contains a portion of PDF Page contents. It has a width and a position and can be placed anywhere on a Page. It can even contain a whole Page, and is used in the creator where each Drawable object can output one or more blocks, each representing content for separate pages (typically needed when Page breaks occur).

type Block struct {
    // contains filtered or unexported fields
}

func NewBlock

func NewBlock(width float64, height float64) *Block

NewBlock creates a new Block with specified width and height.

func NewBlockFromPage

func NewBlockFromPage(page *model.PdfPage) (*Block, error)

NewBlockFromPage creates a Block from a PDF Page. Useful for loading template pages as blocks from a PDF document and additional content with the creator.

func (*Block) AddAnnotation

func (blk *Block) AddAnnotation(annotation *model.PdfAnnotation)

AddAnnotation adds an annotation to the current block. The annotation will be added to the page the block will be rendered on.

func (*Block) Angle

func (blk *Block) Angle() float64

Angle returns the block rotation angle in degrees.

func (*Block) Draw

func (blk *Block) Draw(d Drawable) error

Draw draws the drawable d on the block. Note that the drawable must not wrap, i.e. only return one block. Otherwise an error is returned.

func (*Block) DrawTemplate

func (blk *Block) DrawTemplate(c *Creator, r io.Reader, data interface{}, options *TemplateOptions) error

DrawTemplate renders the template provided through the specified reader, using the specified `data` and `options`. Creator templates are first executed as text/template *Template instances, so the specified `data` is inserted within the template. The second phase of processing is actually parsing the template, translating it into creator components and rendering them using the provided options. Both the `data` and `options` parameters can be nil.

func (*Block) DrawWithContext

func (blk *Block) DrawWithContext(d Drawable, ctx DrawContext) error

DrawWithContext draws the Block using the specified drawing context.

func (*Block) GeneratePageBlocks

func (blk *Block) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks draws the block contents on a template Page block. Implements the Drawable interface.

func (*Block) GetMargins

func (blk *Block) GetMargins() (float64, float64, float64, float64)

GetMargins returns the Block's margins: left, right, top, bottom.

func (*Block) Height

func (blk *Block) Height() float64

Height returns the Block's height.

func (*Block) RotatedSize

func (blk *Block) RotatedSize() (float64, float64)

RotatedSize returns the width and height of the rotated block.

func (*Block) Scale

func (blk *Block) Scale(sx, sy float64)

Scale block by specified factors in the x and y directions.

func (*Block) ScaleToHeight

func (blk *Block) ScaleToHeight(h float64)

ScaleToHeight scales the Block to a specified height, maintaining the same aspect ratio.

func (*Block) ScaleToWidth

func (blk *Block) ScaleToWidth(w float64)

ScaleToWidth scales the Block to a specified width, maintaining the same aspect ratio.

func (*Block) SetAngle

func (blk *Block) SetAngle(angleDeg float64)

SetAngle sets the rotation angle in degrees.

func (*Block) SetMargins

func (blk *Block) SetMargins(left, right, top, bottom float64)

SetMargins sets the Block's left, right, top, bottom, margins.

func (*Block) SetPos

func (blk *Block) SetPos(x, y float64)

SetPos sets the Block's positioning to absolute mode with the specified coordinates.

func (*Block) Width

func (blk *Block) Width() float64

Width returns the Block's width.

type CellBorderSide

CellBorderSide defines the table cell's border side.

type CellBorderSide int
const (
    // CellBorderSideLeft adds border on the left side of the table.
    CellBorderSideLeft CellBorderSide = iota

    // CellBorderSideRight adds a border on the right side of the table.
    CellBorderSideRight

    // CellBorderSideTop adds a border on the top side of the table.
    CellBorderSideTop

    // CellBorderSideBottom adds a border on the bottom side of the table.
    CellBorderSideBottom

    // CellBorderSideAll adds borders on all sides of the table.
    CellBorderSideAll
)

type CellBorderStyle

CellBorderStyle defines the table cell's border style.

type CellBorderStyle int

Currently supported table styles are: None (no border) and boxed (line along each side).

const (
    CellBorderStyleNone CellBorderStyle = iota // no border

    CellBorderStyleSingle
    CellBorderStyleDouble
)

type CellHorizontalAlignment

CellHorizontalAlignment defines the table cell's horizontal alignment.

type CellHorizontalAlignment int

Table cells have three horizontal alignment modes: left, center and right.

const (
    // CellHorizontalAlignmentLeft aligns cell content on the left (with specified indent); unused space on the right.
    CellHorizontalAlignmentLeft CellHorizontalAlignment = iota

    // CellHorizontalAlignmentCenter aligns cell content in the middle (unused space divided equally on the left/right).
    CellHorizontalAlignmentCenter

    // CellHorizontalAlignmentRight aligns the cell content on the right; unsued space on the left.
    CellHorizontalAlignmentRight
)

type CellVerticalAlignment

CellVerticalAlignment defines the table cell's vertical alignment.

type CellVerticalAlignment int

Table cells have three vertical alignment modes: top, middle and bottom.

const (
    // CellVerticalAlignmentTop aligns cell content vertically to the top; unused space below.
    CellVerticalAlignmentTop CellVerticalAlignment = iota

    // CellVerticalAlignmentMiddle aligns cell content in the middle; unused space divided equally above and below.
    CellVerticalAlignmentMiddle

    // CellVerticalAlignmentBottom aligns cell content on the bottom; unused space above.
    CellVerticalAlignmentBottom
)

type Chapter

Chapter is used to arrange multiple drawables (paragraphs, images, etc) into a single section. The concept is the same as a book or a report chapter.

type Chapter struct {
    // contains filtered or unexported fields
}

func (*Chapter) Add

func (chap *Chapter) Add(d Drawable) error

Add adds a new Drawable to the chapter. Currently supported Drawables: - *Paragraph - *StyledParagraph - *Image - *Chart - *Table - *Division - *List - *Rectangle - *Ellipse - *Line - *Block, - *PageBreak - *Chapter

func (*Chapter) GeneratePageBlocks

func (chap *Chapter) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks generate the Page blocks. Multiple blocks are generated if the contents wrap over multiple pages.

func (*Chapter) GetHeading

func (chap *Chapter) GetHeading() *Paragraph

GetHeading returns the chapter heading paragraph. Used to give access to address style: font, sizing etc.

func (*Chapter) GetMargins

func (chap *Chapter) GetMargins() (float64, float64, float64, float64)

GetMargins returns the Chapter's margin: left, right, top, bottom.

func (*Chapter) NewSubchapter

func (chap *Chapter) NewSubchapter(title string) *Chapter

NewSubchapter creates a new child chapter with the specified title.

func (*Chapter) SetIncludeInTOC

func (chap *Chapter) SetIncludeInTOC(includeInTOC bool)

SetIncludeInTOC sets a flag to indicate whether or not to include in tOC.

func (*Chapter) SetMargins

func (chap *Chapter) SetMargins(left, right, top, bottom float64)

SetMargins sets the Chapter margins: left, right, top, bottom. Typically not needed as the creator's page margins are used.

func (*Chapter) SetShowNumbering

func (chap *Chapter) SetShowNumbering(show bool)

SetShowNumbering sets a flag to indicate whether or not to show chapter numbers as part of title.

type Chart

Chart represents a chart drawable. It is used to render unichart chart components using a creator instance.

type Chart struct {
    // contains filtered or unexported fields
}

func NewChart

func NewChart(chart render.ChartRenderable) *Chart

NewChart creates a new creator drawable based on the provided unichart chart component.

func (*Chart) GeneratePageBlocks

func (c *Chart) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks draws the chart onto a block.

func (*Chart) GetMargins

func (c *Chart) GetMargins() (float64, float64, float64, float64)

GetMargins returns the margins of the chart (left, right, top, bottom).

func (*Chart) Height

func (c *Chart) Height() float64

Height returns the height of the chart.

func (*Chart) SetMargins

func (c *Chart) SetMargins(left, right, top, bottom float64)

SetMargins sets the margins of the chart component.

func (*Chart) SetPos

func (c *Chart) SetPos(x, y float64)

SetPos sets the position of the chart to the specified coordinates. This method sets the chart to use absolute positioning.

func (*Chart) Width

func (c *Chart) Width() float64

Width returns the width of the chart. In relative positioning mode, all the available context width is used at render time.

type Color

Color interface represents colors in the PDF creator.

type Color interface {
    ToRGB() (float64, float64, float64)
}

func ColorCMYKFrom8bit

func ColorCMYKFrom8bit(c, m, y, k byte) Color

ColorCMYKFrom8bit creates a Color from c,m,y,k values (0-100). Example:

red := ColorCMYKFrom8Bit(0, 100, 100, 0)

func ColorCMYKFromArithmetic

func ColorCMYKFromArithmetic(c, m, y, k float64) Color

ColorCMYKFromArithmetic creates a Color from arithmetic color values (0-1). Example:

green := ColorCMYKFromArithmetic(1.0, 0.0, 1.0, 0.0)

func ColorRGBFrom8bit

func ColorRGBFrom8bit(r, g, b byte) Color

ColorRGBFrom8bit creates a Color from 8-bit (0-255) r,g,b values. Example:

red := ColorRGBFrom8Bit(255, 0, 0)

func ColorRGBFromArithmetic

func ColorRGBFromArithmetic(r, g, b float64) Color

ColorRGBFromArithmetic creates a Color from arithmetic color values (0-1). Example:

green := ColorRGBFromArithmetic(0.0, 1.0, 0.0)

func ColorRGBFromHex

func ColorRGBFromHex(hexStr string) Color

ColorRGBFromHex converts color hex code to rgb color for using with creator. NOTE: If there is a problem interpreting the string, then will use black color and log a debug message. Example hex code: #ffffff -> (1,1,1) white.

type ColorPoint

ColorPoint is a pair of Color and a relative point where the color would be rendered.

type ColorPoint struct {
    // contains filtered or unexported fields
}

func NewColorPoint

func NewColorPoint(color Color, point float64) *ColorPoint

NewColorPoint creates a new color and point object for use in the gradient rendering process.

type Creator

Creator is a wrapper around functionality for creating PDF reports and/or adding new content onto imported PDF pages, etc.

type Creator struct {
    // Errors keeps error messages that should not interrupt pdf processing and to be checked later.
    Errors []error

    // UnsupportedCharacterReplacement is character that will be used to replace unsupported glyph.
    // The value will be passed to drawing context.
    UnsupportedCharacterReplacement rune

    // Controls whether a table of contents will be generated.
    AddTOC bool

    // CustomTOC specifies if the TOC is rendered by the user.
    // When the `CustomTOC` field is set to `true`, the default TOC component is not rendered.
    // Instead the TOC is drawn by the user, in the callback provided to
    // the `Creator.CreateTableOfContents` method.
    // If `CustomTOC` is set to `false`, the callback provided to
    // `Creator.CreateTableOfContents` customizes the style of the automatically generated TOC component.
    CustomTOC bool

    // Controls whether outlines will be generated.
    AddOutlines bool
    // contains filtered or unexported fields
}

func New

func New() *Creator

New creates a new instance of the PDF Creator.

func (*Creator) AddPage

func (c *Creator) AddPage(page *model.PdfPage) error

AddPage adds the specified page to the creator. NOTE: If the page has a Rotate flag, the creator will take care of transforming the contents to maintain the correct orientation.

func (*Creator) Context

func (c *Creator) Context() DrawContext

Context returns the current drawing context.

func (*Creator) CreateFrontPage

func (c *Creator) CreateFrontPage(genFrontPageFunc func(args FrontpageFunctionArgs))

CreateFrontPage sets a function to generate a front Page.

func (*Creator) CreateTableOfContents

func (c *Creator) CreateTableOfContents(genTOCFunc func(toc *TOC) error)

CreateTableOfContents sets a function to generate table of contents.

func (*Creator) Draw

func (c *Creator) Draw(d Drawable) error

Draw processes the specified Drawable widget and generates blocks that can be rendered to the output document. The generated blocks can span over one or more pages. Additional pages are added if the contents go over the current page. Each generated block is assigned to the creator page it will be rendered to. In order to render the generated blocks to the creator pages, call Finalize, Write or WriteToFile.

func (*Creator) DrawFooter

func (c *Creator) DrawFooter(drawFooterFunc func(footer *Block, args FooterFunctionArgs))

DrawFooter sets a function to draw a footer on created output pages.

func (*Creator) DrawHeader

func (c *Creator) DrawHeader(drawHeaderFunc func(header *Block, args HeaderFunctionArgs))

DrawHeader sets a function to draw a header on created output pages.

func (*Creator) DrawTemplate

func (c *Creator) DrawTemplate(r io.Reader, data interface{}, options *TemplateOptions) error

DrawTemplate renders the template provided through the specified reader, using the specified `data` and `options`. Creator templates are first executed as text/template *Template instances, so the specified `data` is inserted within the template. The second phase of processing is actually parsing the template, translating it into creator components and rendering them using the provided options. Both the `data` and `options` parameters can be nil.

func (*Creator) EnableFontSubsetting

func (c *Creator) EnableFontSubsetting(font *model.PdfFont)

EnableFontSubsetting enables font subsetting for `font` when the creator output is written to file. Embeds only the subset of the runes/glyphs that are actually used to display the file. Subsetting can reduce the size of fonts significantly.

func (*Creator) Finalize

func (c *Creator) Finalize() error

Finalize renders all blocks to the creator pages. In addition, it takes care of adding headers and footers, as well as generating the front page, table of contents and outlines. Finalize is automatically called before writing the document out. Calling the method manually can be useful when adding external pages to the creator, using the AddPage method, as it renders all creator blocks to the added pages, without having to write the document out. NOTE: TOC and outlines are generated only if the AddTOC and AddOutlines fields of the creator are set to true (enabled by default). Furthermore, TOCs and outlines without content are skipped. TOC and outline content is added automatically when using the chapter component. TOCs and outlines can also be set externally, using the SetTOC and SetOutlineTree methods. Finalize should only be called once, after all draw calls have taken place, as it will return immediately if the creator instance has been finalized.

func (*Creator) Flip

func (c *Creator) Flip(flipH, flipV bool) error

Flip flips the active page on the specified axes. If `flipH` is true, the page is flipped horizontally. Similarly, if `flipV` is true, the page is flipped vertically. If both are true, the page is flipped both horizontally and vertically. NOTE: the flip transformations are applied when the creator is finalized, which is at write time in most cases.

func (*Creator) GetOptimizer

func (c *Creator) GetOptimizer() model.Optimizer

GetOptimizer returns current PDF optimizer.

func (*Creator) Height

func (c *Creator) Height() float64

Height returns the current page height.

func (*Creator) MoveDown

func (c *Creator) MoveDown(dy float64)

MoveDown moves the drawing context down by relative displacement dy (negative goes up).

func (*Creator) MoveRight

func (c *Creator) MoveRight(dx float64)

MoveRight moves the drawing context right by relative displacement dx (negative goes left).

func (*Creator) MoveTo

func (c *Creator) MoveTo(x, y float64)

MoveTo moves the drawing context to absolute coordinates (x, y).

func (*Creator) MoveX

func (c *Creator) MoveX(x float64)

MoveX moves the drawing context to absolute position x.

func (*Creator) MoveY

func (c *Creator) MoveY(y float64)

MoveY moves the drawing context to absolute position y.

func (*Creator) NewChapter

func (c *Creator) NewChapter(title string) *Chapter

NewChapter creates a new chapter with the specified title as the heading.

func (*Creator) NewCurve

func (c *Creator) NewCurve(x1, y1, cx, cy, x2, y2 float64) *Curve

NewCurve returns new instance of Curve between points (x1,y1) and (x2, y2) with control point (cx,cy).

func (*Creator) NewCurvePolygon

func (c *Creator) NewCurvePolygon(rings [][]draw.CubicBezierCurve) *CurvePolygon

NewCurvePolygon creates a new curve polygon.

func (*Creator) NewDivision

func (c *Creator) NewDivision() *Division

NewDivision returns a new Division container component.

func (*Creator) NewEllipse

func (c *Creator) NewEllipse(xc, yc, width, height float64) *Ellipse

NewEllipse creates a new ellipse with the center at (`xc`, `yc`), having the specified width and height. NOTE: In relative positioning mode, `xc` and `yc` are calculated using the current context. Furthermore, when the fit mode is set to fill the available space, the ellipse is scaled so that it occupies the entire context width while maintaining the original aspect ratio.

func (*Creator) NewFilledCurve

func (c *Creator) NewFilledCurve() *FilledCurve

NewFilledCurve returns a instance of filled curve.

func (*Creator) NewImage

func (c *Creator) NewImage(img *model.Image) (*Image, error)

NewImage create a new image from a unidoc image (model.Image).

func (*Creator) NewImageFromData

func (c *Creator) NewImageFromData(data []byte) (*Image, error)

NewImageFromData creates an Image from image data.

func (*Creator) NewImageFromFile

func (c *Creator) NewImageFromFile(path string) (*Image, error)

NewImageFromFile creates an Image from a file.

func (*Creator) NewImageFromGoImage

func (c *Creator) NewImageFromGoImage(goimg goimage.Image) (*Image, error)

NewImageFromGoImage creates an Image from a go image.Image data structure.

func (*Creator) NewInvoice

func (c *Creator) NewInvoice() *Invoice

NewInvoice returns an instance of an empty invoice.

func (*Creator) NewLine

func (c *Creator) NewLine(x1, y1, x2, y2 float64) *Line

NewLine creates a new line between (x1, y1) to (x2, y2), using default attributes. NOTE: In relative positioning mode, `x1` and `y1` are calculated using the current context and `x2`, `y2` are used only to calculate the position of the second point in relation to the first one (used just as a measurement of size). Furthermore, when the fit mode is set to fill the context width, `x2` is set to the right edge coordinate of the context.

func (*Creator) NewLinearGradientColor

func (c *Creator) NewLinearGradientColor(colorPoints []*ColorPoint) *LinearShading

NewLinearGradientColor creates a linear gradient color that could act as a color in other components.

func (*Creator) NewList

func (c *Creator) NewList() *List

NewList creates a new list.

func (*Creator) NewPage

func (c *Creator) NewPage() *model.PdfPage

NewPage adds a new Page to the Creator and sets as the active Page.

func (*Creator) NewPageBreak

func (c *Creator) NewPageBreak() *PageBreak

NewPageBreak create a new page break.

func (*Creator) NewParagraph

func (c *Creator) NewParagraph(text string) *Paragraph

NewParagraph creates a new text paragraph. Default attributes: Font: Helvetica, Font size: 10 Encoding: WinAnsiEncoding Wrap: enabled Text color: black

func (*Creator) NewPolyBezierCurve

func (c *Creator) NewPolyBezierCurve(curves []draw.CubicBezierCurve) *PolyBezierCurve

NewPolyBezierCurve creates a new composite Bezier (polybezier) curve.

func (*Creator) NewPolygon

func (c *Creator) NewPolygon(points [][]draw.Point) *Polygon

NewPolygon creates a new polygon.

func (*Creator) NewPolyline

func (c *Creator) NewPolyline(points []draw.Point) *Polyline

NewPolyline creates a new polyline.

func (*Creator) NewRadialGradientColor

func (c *Creator) NewRadialGradientColor(x float64, y float64, innerRadius float64,
    outerRadius float64, colorPoints []*ColorPoint) *RadialShading

NewRadialGradientColor creates a radial gradient color that could act as a color in other componenents. Note: The innerRadius must be smaller than outerRadius for the circle to render properly.

func (*Creator) NewRectangle

func (c *Creator) NewRectangle(x, y, width, height float64) *Rectangle

NewRectangle creates a new rectangle with the left corner at (`x`, `y`), having the specified width and height. NOTE: In relative positioning mode, `x` and `y` are calculated using the current context. Furthermore, when the fit mode is set to fill the available space, the rectangle is scaled so that it occupies the entire context width while maintaining the original aspect ratio.

func (*Creator) NewStyledParagraph

func (c *Creator) NewStyledParagraph() *StyledParagraph

NewStyledParagraph creates a new styled paragraph. Default attributes: Font: Helvetica, Font size: 10 Encoding: WinAnsiEncoding Wrap: enabled Text color: black

func (*Creator) NewStyledTOCLine

func (c *Creator) NewStyledTOCLine(number, title, page TextChunk, level uint, style TextStyle) *TOCLine

NewStyledTOCLine creates a new table of contents line with the provided style.

func (*Creator) NewTOC

func (c *Creator) NewTOC(title string) *TOC

NewTOC creates a new table of contents.

func (*Creator) NewTOCLine

func (c *Creator) NewTOCLine(number, title, page string, level uint) *TOCLine

NewTOCLine creates a new table of contents line with the default style.

func (*Creator) NewTable

func (c *Creator) NewTable(cols int) *Table

NewTable create a new Table with a specified number of columns.

func (*Creator) NewTextStyle

func (c *Creator) NewTextStyle() TextStyle

NewTextStyle creates a new text style object which can be used to style chunks of text. Default attributes: Font: Helvetica Font size: 10 Encoding: WinAnsiEncoding Text color: black

func (*Creator) PageFinalize

func (c *Creator) PageFinalize(pageFinalizeFunc func(args PageFinalizeFunctionArgs) error)

PageFinalize sets a function to be called for each page before finalization (i.e. the last stage of page processing before they get written out). The callback function allows final touch-ups for each page, and it provides information that might not be known at other stages of designing the document (e.g. the total number of pages). Unlike the header/footer functions, which are limited to the top/bottom margins of the page, the finalize function can be used draw components anywhere on the current page.

func (*Creator) RotateDeg

func (c *Creator) RotateDeg(angleDeg int64) error

RotateDeg rotates the current active page by angle degrees. An error is returned on failure, which can be if there is no currently active page, or the angleDeg is not a multiple of 90 degrees.

func (*Creator) SetForms

func (c *Creator) SetForms(form *model.PdfAcroForm) error

SetForms adds an Acroform to a PDF file. Sets the specified form for writing.

func (*Creator) SetOptimizer

func (c *Creator) SetOptimizer(optimizer model.Optimizer)

SetOptimizer sets the optimizer to optimize PDF before writing.

func (*Creator) SetOutlineTree

func (c *Creator) SetOutlineTree(outlineTree *model.PdfOutlineTreeNode)

SetOutlineTree adds the specified outline tree to the PDF file generated by the creator. Adding an external outline tree disables the automatic generation of outlines done by the creator for the relevant components.

func (*Creator) SetPageLabels

func (c *Creator) SetPageLabels(pageLabels core.PdfObject)

SetPageLabels adds the specified page labels to the PDF file generated by the creator. See section 12.4.2 "Page Labels" (p. 382 PDF32000_2008). NOTE: for existing PDF files, the page label ranges object can be obtained using the model.PDFReader's GetPageLabels method.

func (*Creator) SetPageMargins

func (c *Creator) SetPageMargins(left, right, top, bottom float64)

SetPageMargins sets the page margins: left, right, top, bottom. The default page margins are 10% of document width.

func (*Creator) SetPageSize

func (c *Creator) SetPageSize(size PageSize)

SetPageSize sets the Creator's page size. Pages that are added after this will be created with this Page size. Does not affect pages already created.

Common page sizes are defined as constants. Examples: 1. c.SetPageSize(creator.PageSizeA4) 2. c.SetPageSize(creator.PageSizeA3) 3. c.SetPageSize(creator.PageSizeLegal) 4. c.SetPageSize(creator.PageSizeLetter)

For custom sizes: Use the PPMM (points per mm) and PPI (points per inch) when defining those based on physical page sizes:

Examples: 1. 10x15 sq. mm: SetPageSize(PageSize{10*creator.PPMM, 15*creator.PPMM}) where PPMM is points per mm. 2. 3x2 sq. inches: SetPageSize(PageSize{3*creator.PPI, 2*creator.PPI}) where PPI is points per inch.

func (*Creator) SetPdfWriterAccessFunc

func (c *Creator) SetPdfWriterAccessFunc(pdfWriterAccessFunc func(writer *model.PdfWriter) error)

SetPdfWriterAccessFunc sets a PdfWriter access function/hook. Exposes the PdfWriter just prior to writing the PDF. Can be used to encrypt the output PDF, etc.

Example of encrypting with a user/owner password "password" Prior to calling c.WriteFile():

c.SetPdfWriterAccessFunc(func(w *model.PdfWriter) error {
	userPass := []byte("password")
	ownerPass := []byte("password")
	err := w.Encrypt(userPass, ownerPass, nil)
	return err
})

func (*Creator) SetTOC

func (c *Creator) SetTOC(toc *TOC)

SetTOC sets the table of content component of the creator. This method should be used when building a custom table of contents.

func (*Creator) TOC

func (c *Creator) TOC() *TOC

TOC returns the table of contents component of the creator.

func (*Creator) Width

func (c *Creator) Width() float64

Width returns the current page width.

func (*Creator) Write

func (c *Creator) Write(ws io.Writer) error

Write output of creator to io.Writer interface.

func (*Creator) WriteToFile

func (c *Creator) WriteToFile(outputPath string) error

WriteToFile writes the Creator output to file specified by path.

type Curve

Curve represents a cubic Bezier curve with a control point.

type Curve struct {
    // contains filtered or unexported fields
}

func (*Curve) GeneratePageBlocks

func (c *Curve) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks draws the curve onto page blocks.

func (*Curve) SetColor

func (c *Curve) SetColor(col Color)

SetColor sets the line color.

func (*Curve) SetWidth

func (c *Curve) SetWidth(width float64)

SetWidth sets line width.

type CurvePolygon

CurvePolygon represents a curve polygon shape. Implements the Drawable interface and can be drawn on PDF using the Creator.

type CurvePolygon struct {
    // contains filtered or unexported fields
}

func (*CurvePolygon) GeneratePageBlocks

func (p *CurvePolygon) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks draws the composite curve polygon on a new block representing the page. Implements the Drawable interface.

func (*CurvePolygon) SetBorderColor

func (p *CurvePolygon) SetBorderColor(color Color)

SetBorderColor sets the border color.

func (*CurvePolygon) SetBorderOpacity

func (p *CurvePolygon) SetBorderOpacity(opacity float64)

SetBorderOpacity sets the border opacity.

func (*CurvePolygon) SetBorderWidth

func (p *CurvePolygon) SetBorderWidth(borderWidth float64)

SetBorderWidth sets the border width.

func (*CurvePolygon) SetFillColor

func (p *CurvePolygon) SetFillColor(color Color)

SetFillColor sets the fill color.

func (*CurvePolygon) SetFillOpacity

func (p *CurvePolygon) SetFillOpacity(opacity float64)

SetFillOpacity sets the fill opacity.

type Division

Division is a container component which can wrap across multiple pages. Currently supported drawable components: - *Paragraph - *StyledParagraph - *Image - *Chart

The component stacking behavior is vertical, where the drawables are drawn on top of each other.

type Division struct {
    // contains filtered or unexported fields
}

func (*Division) Add

func (div *Division) Add(d VectorDrawable) error

Add adds a VectorDrawable to the Division container. Currently supported VectorDrawables: - *Paragraph - *StyledParagraph - *Image - *Chart - *Rectangle - *Ellipse - *Line - *Table - *Division - *List

func (*Division) EnablePageWrap

func (div *Division) EnablePageWrap(enable bool)

EnablePageWrap controls whether the division is wrapped across pages. If disabled, the division is moved in its entirety on a new page, if it does not fit in the available height. By default, page wrapping is enabled. If the height of the division is larger than an entire page, wrapping is enabled automatically in order to avoid unwanted behavior. Currently, page wrapping can only be disabled for vertical divisions.

func (*Division) GeneratePageBlocks

func (div *Division) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks generates the page blocks for the Division component. Multiple blocks are generated if the contents wrap over multiple pages.

func (*Division) Height

func (div *Division) Height() float64

Height returns the height of the division, assuming all components are stacked on top of each other.

func (*Division) Inline

func (div *Division) Inline() bool

Inline returns whether the inline mode of the division is active.

func (*Division) Margins

func (div *Division) Margins() (left, right, top, bottom float64)

Margins returns the margins of the component.

func (*Division) Padding

func (div *Division) Padding() (left, right, top, bottom float64)

Padding returns the padding of the component.

func (*Division) SetBackground

func (div *Division) SetBackground(background *Background)

SetBackground sets the background properties of the component.

func (*Division) SetInline

func (div *Division) SetInline(inline bool)

SetInline sets the inline mode of the division.

func (*Division) SetMargins

func (div *Division) SetMargins(left, right, top, bottom float64)

SetMargins sets the margins of the component. The margins are applied around the division.

func (*Division) SetPadding

func (div *Division) SetPadding(left, right, top, bottom float64)

SetPadding sets the padding of the component. The padding represents inner margins which are applied around the contents of the division. The background of the component is not affected by its padding.

func (*Division) Width

func (div *Division) Width() float64

Width is not used as the division component is designed to fill all the available space, depending on the context. Returns 0.

type DrawContext

DrawContext defines the drawing context. The DrawContext is continuously used and updated when drawing the page contents in relative mode. Keeps track of current X, Y position, available height as well as other page parameters such as margins and dimensions.

type DrawContext struct {
    // Current page number.
    Page int

    // Current position.  In a relative positioning mode, a drawable will be placed at these coordinates.
    X, Y float64

    // Context dimensions.  Available width and height (on current page).
    Width, Height float64

    // Page Margins.
    Margins Margins

    // Absolute Page size, widths and height.
    PageWidth  float64
    PageHeight float64

    // Controls whether the components are stacked horizontally
    Inline bool
    // contains filtered or unexported fields
}

type Drawable

Drawable is a widget that can be used to draw with the Creator.

type Drawable interface {
    // GeneratePageBlocks draw onto blocks representing Page contents. As the content can wrap over many pages, multiple
    // templates are returned, one per Page.  The function also takes a draw context containing information
    // where to draw (if relative positioning) and the available height to draw on accounting for Margins etc.
    GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)
}

type Ellipse

Ellipse defines an ellipse with a center at (xc,yc) and a specified width and height. The ellipse can have a colored fill and/or border with a specified width. Implements the Drawable interface and can be drawn on PDF using the Creator.

type Ellipse struct {
    // contains filtered or unexported fields
}

func (*Ellipse) BorderColor

func (ell *Ellipse) BorderColor() Color

BorderColor returns the border color of the ellipse.

func (*Ellipse) BorderOpacity

func (ell *Ellipse) BorderOpacity() float64

BorderOpacity returns the border opacity of the ellipse (0-1).

func (*Ellipse) BorderWidth

func (ell *Ellipse) BorderWidth() float64

BorderWidth returns the border width of the ellipse.

func (*Ellipse) FillColor

func (ell *Ellipse) FillColor() Color

FillColor returns the fill color of the ellipse.

func (*Ellipse) FillOpacity

func (ell *Ellipse) FillOpacity() float64

FillOpacity returns the fill opacity of the ellipse (0-1).

func (*Ellipse) FitMode

func (ell *Ellipse) FitMode() FitMode

FitMode returns the fit mode of the ellipse.

func (*Ellipse) GeneratePageBlocks

func (ell *Ellipse) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks draws the ellipse on a new block representing the page.

func (*Ellipse) GetCoords

func (ell *Ellipse) GetCoords() (float64, float64)

GetCoords returns the center coordinates of ellipse (`xc`, `yc`).

func (*Ellipse) GetMargins

func (ell *Ellipse) GetMargins() (float64, float64, float64, float64)

GetMargins returns the margins of the ellipse: left, right, top, bottom.

func (*Ellipse) Height

func (ell *Ellipse) Height() float64

Height returns the height of the ellipse.

func (*Ellipse) Positioning

func (ell *Ellipse) Positioning() Positioning

Positioning returns the type of positioning the ellipse is set to use.

func (*Ellipse) Scale

func (ell *Ellipse) Scale(xFactor, yFactor float64)

Scale scales the ellipse dimensions by the specified factors.

func (*Ellipse) ScaleToHeight

func (ell *Ellipse) ScaleToHeight(h float64)

ScaleToHeight scales the ellipse to the specified height. The width of the ellipse is scaled so that the aspect ratio is maintained.

func (*Ellipse) ScaleToWidth

func (ell *Ellipse) ScaleToWidth(w float64)

ScaleToWidth scales the ellipse to the specified width. The height of the ellipse is scaled so that the aspect ratio is maintained.

func (*Ellipse) SetBorderColor

func (ell *Ellipse) SetBorderColor(col Color)

SetBorderColor sets the border color of the ellipse.

func (*Ellipse) SetBorderOpacity

func (ell *Ellipse) SetBorderOpacity(opacity float64)

SetBorderOpacity sets the border opacity of the ellipse.

func (*Ellipse) SetBorderWidth

func (ell *Ellipse) SetBorderWidth(bw float64)

SetBorderWidth sets the border width of the ellipse.

func (*Ellipse) SetCoords

func (ell *Ellipse) SetCoords(xc, yc float64)

SetCoords sets the center coordinates of the ellipse.

func (*Ellipse) SetFillColor

func (ell *Ellipse) SetFillColor(col Color)

SetFillColor sets the fill color of the ellipse.

func (*Ellipse) SetFillOpacity

func (ell *Ellipse) SetFillOpacity(opacity float64)

SetFillOpacity sets the fill opacity of the ellipse.

func (*Ellipse) SetFitMode

func (ell *Ellipse) SetFitMode(fitMode FitMode)

SetFitMode sets the fit mode of the ellipse. NOTE: The fit mode is only applied if relative positioning is used.

func (*Ellipse) SetHeight

func (ell *Ellipse) SetHeight(height float64)

SetHeight sets the height of the ellipse.

func (*Ellipse) SetMargins

func (ell *Ellipse) SetMargins(left, right, top, bottom float64)

SetMargins sets the margins of the ellipse. NOTE: ellipse margins are only applied if relative positioning is used.

func (*Ellipse) SetPositioning

func (ell *Ellipse) SetPositioning(position Positioning)

SetPositioning sets the positioning of the ellipse (absolute or relative).

func (*Ellipse) SetWidth

func (ell *Ellipse) SetWidth(width float64)

SetWidth sets the width of the ellipse.

func (*Ellipse) Width

func (ell *Ellipse) Width() float64

Width returns the width of the ellipse.

type FilledCurve

FilledCurve represents a closed path of Bezier curves with a border and fill.

type FilledCurve struct {
    FillEnabled bool // Show fill?

    BorderEnabled bool // Show border?
    BorderWidth   float64
    // contains filtered or unexported fields
}

func (*FilledCurve) AppendCurve

func (fc *FilledCurve) AppendCurve(curve draw.CubicBezierCurve) *FilledCurve

AppendCurve appends a Bezier curve to the filled curve.

func (*FilledCurve) GeneratePageBlocks

func (fc *FilledCurve) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks draws the filled curve on page blocks.

func (*FilledCurve) SetBorderColor

func (fc *FilledCurve) SetBorderColor(color Color)

SetBorderColor sets the border color for the path.

func (*FilledCurve) SetFillColor

func (fc *FilledCurve) SetFillColor(color Color)

SetFillColor sets the fill color for the path.

type FitMode

FitMode defines resizing options of an object inside a container.

type FitMode int
const (
    // FitModeNone sets the object to be rendered as is, no changes are made
    // to its dimensions.
    FitModeNone FitMode = iota

    // FitModeFillWidth sets the object to be scaled (up or down) in order
    // to occupy the entire width of its container (or the context).
    // The aspect ratio of the original object is preserved.
    FitModeFillWidth
)

type FooterFunctionArgs

FooterFunctionArgs holds the input arguments to a footer drawing function. It is designed as a struct, so additional parameters can be added in the future with backwards compatibility.

type FooterFunctionArgs struct {
    PageNum    int
    TotalPages int
}

type FrontpageFunctionArgs

FrontpageFunctionArgs holds the input arguments to a front page drawing function. It is designed as a struct, so additional parameters can be added in the future with backwards compatibility.

type FrontpageFunctionArgs struct {
    PageNum    int
    TotalPages int
}

type GraphicSVG

GraphicSVG represents a drawable graphic SVG. It is used to render the graphic SVG components using a creator instance.

type GraphicSVG struct {
    // contains filtered or unexported fields
}

func NewGraphicSVGFromFile

func NewGraphicSVGFromFile(path string) (*GraphicSVG, error)

NewGraphicSVGFromFile creates a graphic SVG from a file.

func NewGraphicSVGFromString

func NewGraphicSVGFromString(svgStr string) (*GraphicSVG, error)

NewGraphicSVGFromString creates a graphic SVG from a SVG string.

func (*GraphicSVG) GeneratePageBlocks

func (gs *GraphicSVG) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks draw graphic svg into block.

func (*GraphicSVG) GetMargins

func (gs *GraphicSVG) GetMargins() (float64, float64, float64, float64)

GetMargins returns the margins of the graphic svg (left, right, top, bottom).

func (*GraphicSVG) Height

func (gs *GraphicSVG) Height() float64

Height returns the height of the graphic svg.

func (*GraphicSVG) Scale

func (gs *GraphicSVG) Scale(xFactor, yFactor float64)

Scale sets the scale ratio with `X` factor and `Y` factor for the graphic svg.

func (*GraphicSVG) ScaleToHeight

func (gs *GraphicSVG) ScaleToHeight(h float64)

ScaleToHeight sets the graphic svg scaling factor with the given height.

func (*GraphicSVG) ScaleToWidth

func (gs *GraphicSVG) ScaleToWidth(w float64)

ScaleToWidth sets the graphic svg scaling factor with the given width.

func (*GraphicSVG) SetMargins

func (gs *GraphicSVG) SetMargins(left, right, top, bottom float64)

SetMargins sets the margins of the graphic svg component.

func (*GraphicSVG) SetPos

func (gs *GraphicSVG) SetPos(x, y float64)

SetPos sets the position of the graphic svg to the specified coordinates. This method sets the graphic svg to use absolute positioning.

func (*GraphicSVG) Width

func (gs *GraphicSVG) Width() float64

Width returns the width of the graphic svg.

type HeaderFunctionArgs

HeaderFunctionArgs holds the input arguments to a header drawing function. It is designed as a struct, so additional parameters can be added in the future with backwards compatibility.

type HeaderFunctionArgs struct {
    PageNum    int
    TotalPages int
}

type HorizontalAlignment

HorizontalAlignment represents the horizontal alignment of components within a page.

type HorizontalAlignment int

Horizontal alignment options.

const (
    HorizontalAlignmentLeft HorizontalAlignment = iota
    HorizontalAlignmentCenter
    HorizontalAlignmentRight
)

type Image

The Image type is used to draw an image onto PDF.

type Image struct {
    // contains filtered or unexported fields
}

func (*Image) ConvertToBinary

func (img *Image) ConvertToBinary() error

ConvertToBinary converts current image data into binary (Bi-level image) format. If provided image is RGB or GrayScale the function converts it into binary image using histogram auto threshold method.

func (*Image) Crop

func (img *Image) Crop(x0, y0, x1, y1 int)

Crop crops the Image to the specified bounds.

func (*Image) FitMode

func (img *Image) FitMode() FitMode

FitMode returns the fit mode of the image.

func (*Image) GeneratePageBlocks

func (img *Image) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks generate the Page blocks. Draws the Image on a block, implementing the Drawable interface.

func (*Image) GetHorizontalAlignment

func (img *Image) GetHorizontalAlignment() HorizontalAlignment

GetHorizontalAlignment returns the horizontal alignment of the image.

func (*Image) GetMargins

func (img *Image) GetMargins() (float64, float64, float64, float64)

GetMargins returns the Image's margins: left, right, top, bottom.

func (*Image) Height

func (img *Image) Height() float64

Height returns Image's document height.

func (*Image) Lazy

func (img *Image) Lazy() bool

Lazy gets the lazy mode for the image.

func (*Image) Scale

func (img *Image) Scale(xFactor, yFactor float64)

Scale scales Image by a constant factor, both width and height.

func (*Image) ScaleToHeight

func (img *Image) ScaleToHeight(h float64)

ScaleToHeight scale Image to a specified height h, maintaining the aspect ratio.

func (*Image) ScaleToWidth

func (img *Image) ScaleToWidth(w float64)

ScaleToWidth scale Image to a specified width w, maintaining the aspect ratio.

func (*Image) SetAngle

func (img *Image) SetAngle(angle float64)

SetAngle sets Image rotation angle in degrees.

func (*Image) SetEncoder

func (img *Image) SetEncoder(encoder core.StreamEncoder)

SetEncoder sets the encoding/compression mechanism for the image.

func (*Image) SetFitMode

func (img *Image) SetFitMode(fitMode FitMode)

SetFitMode sets the fit mode of the image. NOTE: The fit mode is only applied if relative positioning is used.

func (*Image) SetHeight

func (img *Image) SetHeight(h float64)

SetHeight sets the Image's document height to specified h.

func (*Image) SetHorizontalAlignment

func (img *Image) SetHorizontalAlignment(alignment HorizontalAlignment)

SetHorizontalAlignment sets the horizontal alignment of the image.

func (*Image) SetLazy

func (img *Image) SetLazy(lazy bool)

SetLazy sets the lazy mode for the image.

func (*Image) SetMargins

func (img *Image) SetMargins(left, right, top, bottom float64)

SetMargins sets the margins for the Image (in relative mode): left, right, top, bottom.

func (*Image) SetOpacity

func (img *Image) SetOpacity(opacity float64)

SetOpacity sets opacity for Image.

func (*Image) SetPos

func (img *Image) SetPos(x, y float64)

SetPos sets the absolute position. Changes object positioning to absolute.

func (*Image) SetWidth

func (img *Image) SetWidth(w float64)

SetWidth set the Image's document width to specified w. This does not change the raw image data, i.e. no actual scaling of data is performed. That is handled by the PDF viewer.

func (*Image) Width

func (img *Image) Width() float64

Width returns Image's document width.

type Invoice

Invoice represents a configurable invoice template.

type Invoice struct {
    // contains filtered or unexported fields
}

func (*Invoice) AddInfo

func (i *Invoice) AddInfo(description, value string) (*InvoiceCell, *InvoiceCell)

AddInfo is used to append a piece of invoice information in the template information table.

func (*Invoice) AddLine

func (i *Invoice) AddLine(values ...string) []*InvoiceCell

AddLine appends a new line to the invoice line items table.

func (*Invoice) AddSection

func (i *Invoice) AddSection(title, content string)

AddSection adds a new content section at the end of the invoice.

func (*Invoice) AddTotalLine

func (i *Invoice) AddTotalLine(desc, value string) (*InvoiceCell, *InvoiceCell)

AddTotalLine adds a new line in the invoice totals table.

func (*Invoice) AddressHeadingStyle

func (i *Invoice) AddressHeadingStyle() TextStyle

AddressHeadingStyle returns the style properties used to render the heading of the invoice address sections.

func (*Invoice) AddressStyle

func (i *Invoice) AddressStyle() TextStyle

AddressStyle returns the style properties used to render the content of the invoice address sections.

func (*Invoice) AppendColumn

func (i *Invoice) AppendColumn(description string) *InvoiceCell

AppendColumn appends a column to the line items table.

func (*Invoice) BuyerAddress

func (i *Invoice) BuyerAddress() *InvoiceAddress

BuyerAddress returns the buyer address used in the invoice template.

func (*Invoice) Columns

func (i *Invoice) Columns() []*InvoiceCell

Columns returns all the columns in the invoice line items table.

func (*Invoice) Date

func (i *Invoice) Date() (*InvoiceCell, *InvoiceCell)

Date returns the invoice date description and value cells. The returned values can be used to customize the styles of the cells.

func (*Invoice) DueDate

func (i *Invoice) DueDate() (*InvoiceCell, *InvoiceCell)

DueDate returns the invoice due date description and value cells. The returned values can be used to customize the styles of the cells.

func (*Invoice) GeneratePageBlocks

func (i *Invoice) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks generate the Page blocks. Multiple blocks are generated if the contents wrap over multiple pages.

func (*Invoice) InfoLines

func (i *Invoice) InfoLines() [][2]*InvoiceCell

InfoLines returns all the rows in the invoice information table as description-value cell pairs.

func (*Invoice) InsertColumn

func (i *Invoice) InsertColumn(index uint, description string) *InvoiceCell

InsertColumn inserts a column in the line items table at the specified index.

func (*Invoice) Lines

func (i *Invoice) Lines() [][]*InvoiceCell

Lines returns all the rows of the invoice line items table.

func (i *Invoice) Logo() *Image

Logo returns the logo of the invoice.

func (*Invoice) NewCell

func (i *Invoice) NewCell(value string) *InvoiceCell

NewCell returns a new invoice table cell.

func (*Invoice) NewCellProps

func (i *Invoice) NewCellProps() InvoiceCellProps

NewCellProps returns the default properties of an invoice cell.

func (*Invoice) NewColumn

func (i *Invoice) NewColumn(description string) *InvoiceCell

NewColumn returns a new column for the line items invoice table.

func (*Invoice) NoteHeadingStyle

func (i *Invoice) NoteHeadingStyle() TextStyle

NoteHeadingStyle returns the style properties used to render the heading of the invoice note sections.

func (*Invoice) NoteStyle

func (i *Invoice) NoteStyle() TextStyle

NoteStyle returns the style properties used to render the content of the invoice note sections.

func (*Invoice) Notes

func (i *Invoice) Notes() (string, string)

Notes returns the notes section of the invoice as a title-content pair.

func (*Invoice) Number

func (i *Invoice) Number() (*InvoiceCell, *InvoiceCell)

Number returns the invoice number description and value cells. The returned values can be used to customize the styles of the cells.

func (*Invoice) Sections

func (i *Invoice) Sections() [][2]string

Sections returns the custom content sections of the invoice as title-content pairs.

func (*Invoice) SellerAddress

func (i *Invoice) SellerAddress() *InvoiceAddress

SellerAddress returns the seller address used in the invoice template.

func (*Invoice) SetAddressHeadingStyle

func (i *Invoice) SetAddressHeadingStyle(style TextStyle)

SetAddressHeadingStyle sets the style properties used to render the heading of the invoice address sections.

func (*Invoice) SetAddressStyle

func (i *Invoice) SetAddressStyle(style TextStyle)

SetAddressStyle sets the style properties used to render the content of the invoice address sections.

func (*Invoice) SetBuyerAddress

func (i *Invoice) SetBuyerAddress(address *InvoiceAddress)

SetBuyerAddress sets the buyer address of the invoice.

func (*Invoice) SetColumns

func (i *Invoice) SetColumns(cols []*InvoiceCell)

SetColumns overwrites any columns in the line items table. This should be called before AddLine.

func (*Invoice) SetDate

func (i *Invoice) SetDate(date string) (*InvoiceCell, *InvoiceCell)

SetDate sets the date of the invoice.

func (*Invoice) SetDueDate

func (i *Invoice) SetDueDate(dueDate string) (*InvoiceCell, *InvoiceCell)

SetDueDate sets the due date of the invoice.

func (i *Invoice) SetLogo(logo *Image)

SetLogo sets the logo of the invoice.

func (*Invoice) SetNoteHeadingStyle

func (i *Invoice) SetNoteHeadingStyle(style TextStyle)

SetNoteHeadingStyle sets the style properties used to render the heading of the invoice note sections.

func (*Invoice) SetNoteStyle

func (i *Invoice) SetNoteStyle(style TextStyle)

SetNoteStyle sets the style properties used to render the content of the invoice note sections.

func (*Invoice) SetNotes

func (i *Invoice) SetNotes(title, content string)

SetNotes sets the notes section of the invoice.

func (*Invoice) SetNumber

func (i *Invoice) SetNumber(number string) (*InvoiceCell, *InvoiceCell)

SetNumber sets the number of the invoice.

func (*Invoice) SetSellerAddress

func (i *Invoice) SetSellerAddress(address *InvoiceAddress)

SetSellerAddress sets the seller address of the invoice.

func (*Invoice) SetSubtotal

func (i *Invoice) SetSubtotal(value string)

SetSubtotal sets the subtotal of the invoice.

func (*Invoice) SetTerms

func (i *Invoice) SetTerms(title, content string)

SetTerms sets the terms and conditions section of the invoice.

func (*Invoice) SetTitle

func (i *Invoice) SetTitle(title string)

SetTitle sets the title of the invoice.

func (*Invoice) SetTitleStyle

func (i *Invoice) SetTitleStyle(style TextStyle)

SetTitleStyle sets the style properties of the invoice title.

func (*Invoice) SetTotal

func (i *Invoice) SetTotal(value string)

SetTotal sets the total of the invoice.

func (*Invoice) Subtotal

func (i *Invoice) Subtotal() (*InvoiceCell, *InvoiceCell)

Subtotal returns the invoice subtotal description and value cells. The returned values can be used to customize the styles of the cells.

func (*Invoice) Terms

func (i *Invoice) Terms() (string, string)

Terms returns the terms and conditions section of the invoice as a title-content pair.

func (*Invoice) Title

func (i *Invoice) Title() string

Title returns the title of the invoice.

func (*Invoice) TitleStyle

func (i *Invoice) TitleStyle() TextStyle

TitleStyle returns the style properties used to render the invoice title.

func (*Invoice) Total

func (i *Invoice) Total() (*InvoiceCell, *InvoiceCell)

Total returns the invoice total description and value cells. The returned values can be used to customize the styles of the cells.

func (*Invoice) TotalLines

func (i *Invoice) TotalLines() [][2]*InvoiceCell

TotalLines returns all the rows in the invoice totals table as description-value cell pairs.

type InvoiceAddress

InvoiceAddress contains contact information that can be displayed in an invoice. It is used for the seller and buyer information in the invoice template.

type InvoiceAddress struct {
    Heading string
    Name    string
    Street  string
    Street2 string
    Zip     string
    City    string
    State   string
    Country string
    Phone   string
    Email   string

    // Separator defines the separator between different address components,
    // such as the city, state and zip code. It defaults to ", " when the
    // field is an empty string.
    Separator string

    // If enabled, the Phone field label (`Phone: `) is not displayed.
    HidePhoneLabel bool

    // If enabled, the Email field label (`Email: `) is not displayed.
    HideEmailLabel bool
}

type InvoiceCell

InvoiceCell represents any cell belonging to a table from the invoice template. The main tables are the invoice information table, the line items table and totals table. Contains the text value of the cell and the style properties of the cell.

type InvoiceCell struct {
    InvoiceCellProps

    Value string
}

type InvoiceCellProps

InvoiceCellProps holds all style properties for an invoice cell.

type InvoiceCellProps struct {
    TextStyle       TextStyle
    Alignment       CellHorizontalAlignment
    BackgroundColor Color

    BorderColor Color
    BorderWidth float64
    BorderSides []CellBorderSide
}

type Line

Line defines a line between point 1 (X1, Y1) and point 2 (X2, Y2). The line width, color, style (solid or dashed) and opacity can be configured. Implements the Drawable interface.

type Line struct {
    // contains filtered or unexported fields
}

func (*Line) Color

func (l *Line) Color() Color

Color returns the color of the line.

func (*Line) DashPattern

func (l *Line) DashPattern() (dashArray []int64, dashPhase int64)

DashPattern returns the dash pattern of the line.

func (*Line) FitMode

func (l *Line) FitMode() FitMode

FitMode returns the fit mode of the line.

func (*Line) GeneratePageBlocks

func (l *Line) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks draws the line on a new block representing the page. Implements the Drawable interface.

func (*Line) GetCoords

func (l *Line) GetCoords() (float64, float64, float64, float64)

GetCoords returns the (x1, y1), (x2, y2) points defining the Line.

func (*Line) GetMargins

func (l *Line) GetMargins() (float64, float64, float64, float64)

GetMargins returns the margins of the line: left, right, top, bottom.

func (*Line) Height

func (l *Line) Height() float64

Height returns the height of the line.

func (*Line) Length

func (l *Line) Length() float64

Length calculates and returns the length of the line.

func (*Line) LineWidth

func (l *Line) LineWidth() float64

LineWidth returns the width of the line.

func (*Line) Opacity

func (l *Line) Opacity() float64

Opacity returns the opacity of the line.

func (*Line) Positioning

func (l *Line) Positioning() Positioning

Positioning returns the type of positioning the line is set to use.

func (*Line) SetColor

func (l *Line) SetColor(color Color)

SetColor sets the line color. Use ColorRGBFromHex, ColorRGBFrom8bit or ColorRGBFromArithmetic to create the color object.

func (*Line) SetDashPattern

func (l *Line) SetDashPattern(dashArray []int64, dashPhase int64)

SetDashPattern sets the dash pattern of the line. NOTE: the dash pattern is taken into account only if the style of the line is set to dashed.

func (*Line) SetFitMode

func (l *Line) SetFitMode(fitMode FitMode)

SetFitMode sets the fit mode of the line. NOTE: The fit mode is only applied if relative positioning is used.

func (*Line) SetLineWidth

func (l *Line) SetLineWidth(width float64)

SetLineWidth sets the line width.

func (*Line) SetMargins

func (l *Line) SetMargins(left, right, top, bottom float64)

SetMargins sets the margins of the line. NOTE: line margins are only applied if relative positioning is used.

func (*Line) SetOpacity

func (l *Line) SetOpacity(opacity float64)

SetOpacity sets the opacity of the line (0-1).

func (*Line) SetPositioning

func (l *Line) SetPositioning(positioning Positioning)

SetPositioning sets the positioning of the line (absolute or relative).

func (*Line) SetStyle

func (l *Line) SetStyle(style draw.LineStyle)

SetStyle sets the style of the line (solid or dashed).

func (*Line) Style

func (l *Line) Style() draw.LineStyle

Style returns the style of the line.

func (*Line) Width

func (l *Line) Width() float64

Width returns the width of the line. NOTE: Depending on the fit mode the line is set to use, its width may be calculated at runtime (e.g. when using FitModeFillWidth).

type LinearShading

LinearShading holds data for rendering a linear shading gradient.

type LinearShading struct {
    // contains filtered or unexported fields
}

func (*LinearShading) AddColorStop

func (sh *LinearShading) AddColorStop(color Color, point float64)

AddColorStop add color stop info for rendering gradient color.

func (*LinearShading) AddPatternResource

func (sh *LinearShading) AddPatternResource(block *Block) (patternName core.PdfObjectName, err error)

AddPatternResource adds pattern dictionary inside the resources dictionary.

func (*LinearShading) AddShadingResource

func (sh *LinearShading) AddShadingResource(block *Block) (shadingName core.PdfObjectName, err error)

AddShadingResource adds shading dictionary inside the resources dictionary.

func (*LinearShading) SetAngle

func (sh *LinearShading) SetAngle(angle float64)

SetAngle would set the angle at which the gradient is rendered.

The default angle would be 0 where the gradient would be rendered from left to right side.

func (*LinearShading) SetAntiAlias

func (sh *LinearShading) SetAntiAlias(enable bool)

SetAntiAlias enables anti alias config.

Anti alias is disabled by default.

func (*LinearShading) SetBackgroundColor

func (sh *LinearShading) SetBackgroundColor(backgroundColor Color)

SetBackgroundColor set background color of the shading area.

By default the background color is set to white.

func (*LinearShading) SetBoundingBox

func (sh *LinearShading) SetBoundingBox(x, y, width, height float64)

SetBoundingBox set gradient color bounding box where the gradient would be rendered.

func (*LinearShading) SetExtends

func (sh *LinearShading) SetExtends(start bool, end bool)

SetExtends specifies whether ot extend the shading beyond the starting and ending points.

Text extends is set to `[]bool{false, false}` by default.

func (*LinearShading) ToPdfShadingPattern

func (sh *LinearShading) ToPdfShadingPattern() *model.PdfShadingPatternType2

ToPdfShadingPattern generates a new model.PdfShadingPatternType2 object.

func (*LinearShading) ToRGB

func (sh *LinearShading) ToRGB() (float64, float64, float64)

ToRGB implements interface Color. Note: It's not directly used since shading color works differently than regular color.

type List

List represents a list of items. The representation of a list item is as follows:

[marker] [content]

e.g.: • This is the content of the item. The supported components to add content to list items are: - Paragraph - StyledParagraph - List

type List struct {
    // contains filtered or unexported fields
}

func (*List) Add

func (l *List) Add(item VectorDrawable) (*TextChunk, error)

Add appends a new item to the list. The supported components are: *Paragraph, *StyledParagraph, *Division, *Image, *Table, and *List. Returns the marker used for the newly added item. The returned marker object can be used to change the text and style of the marker for the current item.

func (*List) AddTextItem

func (l *List) AddTextItem(text string) (*StyledParagraph, *TextChunk, error)

AddTextItem appends a new item with the specified text to the list. The method creates a styled paragraph with the specified text and returns it so that the item style can be customized. The method also returns the marker used for the newly added item. The marker object can be used to change the text and style of the marker for the current item.

func (*List) GeneratePageBlocks

func (l *List) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks generate the Page blocks. Multiple blocks are generated if the contents wrap over multiple pages.

func (*List) Height

func (l *List) Height() float64

Height returns the height of the list.

func (*List) Indent

func (l *List) Indent() float64

Indent returns the left offset of the list when nested into another list.

func (*List) Margins

func (l *List) Margins() (float64, float64, float64, float64)

Margins returns the margins of the list: left, right, top, bottom.

func (*List) Marker

func (l *List) Marker() *TextChunk

Marker returns the marker used for the list items. The marker instance can be used the change the text and the style of newly added list items.

func (*List) SetIndent

func (l *List) SetIndent(indent float64)

SetIndent sets the left offset of the list when nested into another list.

func (*List) SetMargins

func (l *List) SetMargins(left, right, top, bottom float64)

SetMargins sets the margins of the paragraph.

func (*List) Width

func (l *List) Width() float64

Width is not used. The list component is designed to fill into the available width depending on the context. Returns 0.

type Margins

Margins represents page margins or margins around an element.

type Margins struct {
    Left   float64
    Right  float64
    Top    float64
    Bottom float64
}

func (*Margins) Horizontal

func (m *Margins) Horizontal() float64

Horizontal returns total horizontal (left + right) margin.

func (*Margins) Vertical

func (m *Margins) Vertical() float64

Vertical returns total vertical (top + bottom) margin.

type PageBreak

PageBreak represents a page break for a chapter.

type PageBreak struct {
}

func (*PageBreak) GeneratePageBlocks

func (p *PageBreak) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks generates a page break block.

type PageFinalizeFunctionArgs

PageFinalizeFunctionArgs holds the input arguments provided to the page finalize callback function which can be set using Creator.PageFinalize.

type PageFinalizeFunctionArgs struct {
    PageNum    int     // the current page number.
    PageWidth  float64 // the width of the page.
    PageHeight float64 // the height of the page.
    TOCPages   int     // the number of TOC pages.
    TotalPages int     // the total number of pages.
}

type PageSize

PageSize represents the page size as a 2 element array representing the width and height in PDF document units (points).

type PageSize [2]float64

type Paragraph

Paragraph represents text drawn with a specified font and can wrap across lines and pages. By default it occupies the available width in the drawing context.

type Paragraph struct {
    // contains filtered or unexported fields
}

func (*Paragraph) GeneratePageBlocks

func (p *Paragraph) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks generates the page blocks. Multiple blocks are generated if the contents wrap over multiple pages. Implements the Drawable interface.

func (*Paragraph) GetMargins

func (p *Paragraph) GetMargins() (float64, float64, float64, float64)

GetMargins returns the Paragraph's margins: left, right, top, bottom.

func (*Paragraph) Height

func (p *Paragraph) Height() float64

Height returns the height of the Paragraph. The height is calculated based on the input text and how it is wrapped within the container. Does not include Margins.

func (*Paragraph) SetAngle

func (p *Paragraph) SetAngle(angle float64)

SetAngle sets the rotation angle of the text.

func (*Paragraph) SetColor

func (p *Paragraph) SetColor(col Color)

SetColor sets the color of the Paragraph text.

Example:

1. p := NewParagraph("Red paragraph")
   // Set to red color with a hex code:
   p.SetColor(creator.ColorRGBFromHex("#ff0000"))

2. Make Paragraph green with 8-bit rgb values (0-255 each component)
   p.SetColor(creator.ColorRGBFrom8bit(0, 255, 0)

3. Make Paragraph blue with arithmetic (0-1) rgb components.
   p.SetColor(creator.ColorRGBFromArithmetic(0, 0, 1.0)

func (*Paragraph) SetEnableWrap

func (p *Paragraph) SetEnableWrap(enableWrap bool)

SetEnableWrap sets the line wrapping enabled flag.

func (*Paragraph) SetFont

func (p *Paragraph) SetFont(font *model.PdfFont)

SetFont sets the Paragraph's font.

func (*Paragraph) SetFontSize

func (p *Paragraph) SetFontSize(fontSize float64)

SetFontSize sets the font size in document units (points).

func (*Paragraph) SetLineHeight

func (p *Paragraph) SetLineHeight(lineheight float64)

SetLineHeight sets the line height (1.0 default).

func (*Paragraph) SetMargins

func (p *Paragraph) SetMargins(left, right, top, bottom float64)

SetMargins sets the Paragraph's margins.

func (*Paragraph) SetMaxLines

func (p *Paragraph) SetMaxLines(maxLines int)

SetMaxLines sets the maximum number of lines before the paragraph text is truncated.

func (*Paragraph) SetPos

func (p *Paragraph) SetPos(x, y float64)

SetPos sets absolute positioning with specified coordinates.

func (*Paragraph) SetText

func (p *Paragraph) SetText(text string)

SetText sets the text content of the Paragraph.

func (*Paragraph) SetTextAlignment

func (p *Paragraph) SetTextAlignment(align TextAlignment)

SetTextAlignment sets the horizontal alignment of the text within the space provided.

func (*Paragraph) SetWidth

func (p *Paragraph) SetWidth(width float64)

SetWidth sets the the Paragraph width. This is essentially the wrapping width, i.e. the width the text can extend to prior to wrapping over to next line.

func (*Paragraph) Text

func (p *Paragraph) Text() string

Text sets the text content of the Paragraph.

func (*Paragraph) Width

func (p *Paragraph) Width() float64

Width returns the width of the Paragraph.

type PolyBezierCurve

PolyBezierCurve represents a composite curve that is the result of joining multiple cubic Bezier curves. Implements the Drawable interface and can be drawn on PDF using the Creator.

type PolyBezierCurve struct {
    // contains filtered or unexported fields
}

func (*PolyBezierCurve) GeneratePageBlocks

func (p *PolyBezierCurve) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks draws the composite Bezier curve on a new block representing the page. Implements the Drawable interface.

func (*PolyBezierCurve) SetBorderColor

func (p *PolyBezierCurve) SetBorderColor(color Color)

SetBorderColor sets the border color.

func (*PolyBezierCurve) SetBorderOpacity

func (p *PolyBezierCurve) SetBorderOpacity(opacity float64)

SetBorderOpacity sets the border opacity.

func (*PolyBezierCurve) SetBorderWidth

func (p *PolyBezierCurve) SetBorderWidth(borderWidth float64)

SetBorderWidth sets the border width.

func (*PolyBezierCurve) SetFillColor

func (p *PolyBezierCurve) SetFillColor(color Color)

SetFillColor sets the fill color.

func (*PolyBezierCurve) SetFillOpacity

func (p *PolyBezierCurve) SetFillOpacity(opacity float64)

SetFillOpacity sets the fill opacity.

type Polygon

Polygon represents a polygon shape. Implements the Drawable interface and can be drawn on PDF using the Creator.

type Polygon struct {
    // contains filtered or unexported fields
}

func (*Polygon) GeneratePageBlocks

func (p *Polygon) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks draws the polygon on a new block representing the page. Implements the Drawable interface.

func (*Polygon) SetBorderColor

func (p *Polygon) SetBorderColor(color Color)

SetBorderColor sets the border color.

func (*Polygon) SetBorderOpacity

func (p *Polygon) SetBorderOpacity(opacity float64)

SetBorderOpacity sets the border opacity.

func (*Polygon) SetBorderWidth

func (p *Polygon) SetBorderWidth(borderWidth float64)

SetBorderWidth sets the border width.

func (*Polygon) SetFillColor

func (p *Polygon) SetFillColor(color Color)

SetFillColor sets the fill color.

func (*Polygon) SetFillOpacity

func (p *Polygon) SetFillOpacity(opacity float64)

SetFillOpacity sets the fill opacity.

type Polyline

Polyline represents a slice of points that are connected as straight lines. Implements the Drawable interface and can be rendered using the Creator.

type Polyline struct {
    // contains filtered or unexported fields
}

func (*Polyline) GeneratePageBlocks

func (p *Polyline) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks draws the polyline on a new block representing the page. Implements the Drawable interface.

func (*Polyline) SetLineColor

func (p *Polyline) SetLineColor(color Color)

SetLineColor sets the line color.

func (*Polyline) SetLineOpacity

func (p *Polyline) SetLineOpacity(opacity float64)

SetLineOpacity sets the line opacity.

func (*Polyline) SetLineWidth

func (p *Polyline) SetLineWidth(lineWidth float64)

SetLineWidth sets the line width.

type Positioning

Positioning represents the positioning type for drawing creator components (relative/absolute).

type Positioning int
const (
    // PositionRelative represents relative positioning.
    PositionRelative Positioning = iota
    // PositionAbsolute represents absolute positioning.
    PositionAbsolute
)

func (Positioning) IsAbsolute

func (p Positioning) IsAbsolute() bool

IsAbsolute checks if the positioning is absolute.

func (Positioning) IsRelative

func (p Positioning) IsRelative() bool

IsRelative checks if the positioning is relative.

type RadialShading

RadialShading holds information that will be used to render a radial shading.

type RadialShading struct {
    // contains filtered or unexported fields
}

func (*RadialShading) AddColorStop

func (sh *RadialShading) AddColorStop(color Color, point float64)

AddColorStop add color stop info for rendering gradient color.

func (*RadialShading) AddPatternResource

func (sh *RadialShading) AddPatternResource(block *Block) (patternName core.PdfObjectName, err error)

AddPatternResource adds pattern dictionary inside the resources dictionary.

func (*RadialShading) AddShadingResource

func (sh *RadialShading) AddShadingResource(block *Block) (shadingName core.PdfObjectName, err error)

AddShadingResource adds shading dictionary inside the resources dictionary.

func (*RadialShading) SetAnchor

func (sh *RadialShading) SetAnchor(anchor AnchorPoint)

SetAnchor set gradient position anchor. Default to center.

func (*RadialShading) SetAntiAlias

func (sh *RadialShading) SetAntiAlias(enable bool)

SetAntiAlias enables anti alias config.

Anti alias is disabled by default.

func (*RadialShading) SetBackgroundColor

func (sh *RadialShading) SetBackgroundColor(backgroundColor Color)

SetBackgroundColor set background color of the shading area.

By default the background color is set to white.

func (*RadialShading) SetBoundingBox

func (sh *RadialShading) SetBoundingBox(x, y, width, height float64)

SetBoundingBox set gradient color bounding box where the gradient would be rendered.

func (*RadialShading) SetExtends

func (sh *RadialShading) SetExtends(start bool, end bool)

SetExtends specifies whether ot extend the shading beyond the starting and ending points.

Text extends is set to `[]bool{false, false}` by default.

func (*RadialShading) ToPdfShadingPattern

func (sh *RadialShading) ToPdfShadingPattern() *model.PdfShadingPatternType3

ToPdfShadingPattern generates a new model.PdfShadingPatternType3 object.

func (*RadialShading) ToRGB

func (sh *RadialShading) ToRGB() (float64, float64, float64)

ToRGB implements interface Color. Note: It's not directly used since shading color works differently than regular color.

type Rectangle

Rectangle defines a rectangle with upper left corner at (x,y) and a specified width and height. The rectangle can have a colored fill and/or border with a specified width. Implements the Drawable interface and can be drawn on PDF using the Creator.

type Rectangle struct {
    // contains filtered or unexported fields
}

func (*Rectangle) BorderColor

func (rect *Rectangle) BorderColor() Color

BorderColor returns the border color of the rectangle.

func (*Rectangle) BorderOpacity

func (rect *Rectangle) BorderOpacity() float64

BorderOpacity returns the border opacity of the rectangle (0-1).

func (*Rectangle) BorderWidth

func (rect *Rectangle) BorderWidth() float64

BorderWidth returns the border width of the rectangle.

func (*Rectangle) FillColor

func (rect *Rectangle) FillColor() Color

FillColor returns the fill color of the rectangle.

func (*Rectangle) FillOpacity

func (rect *Rectangle) FillOpacity() float64

FillOpacity returns the fill opacity of the rectangle (0-1).

func (*Rectangle) FitMode

func (rect *Rectangle) FitMode() FitMode

FitMode returns the fit mode of the rectangle.

func (*Rectangle) GeneratePageBlocks

func (rect *Rectangle) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks draws the rectangle on a new block representing the page. Implements the Drawable interface.

func (*Rectangle) GetCoords

func (rect *Rectangle) GetCoords() (float64, float64)

GetCoords returns the upper left corner coordinates of the rectangle (`x`, `y`).

func (*Rectangle) GetMargins

func (rect *Rectangle) GetMargins() (float64, float64, float64, float64)

GetMargins returns the margins of the rectangle: left, right, top, bottom.

func (*Rectangle) Height

func (rect *Rectangle) Height() float64

Height returns the height of the rectangle. NOTE: the returned value does not include the border width of the rectangle.

func (*Rectangle) Positioning

func (rect *Rectangle) Positioning() Positioning

Positioning returns the type of positioning the rectangle is set to use.

func (*Rectangle) Scale

func (rect *Rectangle) Scale(xFactor, yFactor float64)

Scale scales the rectangle dimensions by the specified factors.

func (*Rectangle) ScaleToHeight

func (rect *Rectangle) ScaleToHeight(h float64)

ScaleToHeight scales the rectangle to the specified height. The width of the rectangle is scaled so that the aspect ratio is maintained.

func (*Rectangle) ScaleToWidth

func (rect *Rectangle) ScaleToWidth(w float64)

ScaleToWidth scales the rectangle to the specified width. The height of the rectangle is scaled so that the aspect ratio is maintained.

func (*Rectangle) SetBorderColor

func (rect *Rectangle) SetBorderColor(col Color)

SetBorderColor sets border color of the rectangle.

func (*Rectangle) SetBorderOpacity

func (rect *Rectangle) SetBorderOpacity(opacity float64)

SetBorderOpacity sets the border opacity of the rectangle.

func (*Rectangle) SetBorderRadius

func (rect *Rectangle) SetBorderRadius(topLeft, topRight, bottomLeft, bottomRight float64)

SetBorderRadius sets the radius of the rectangle corners.

func (*Rectangle) SetBorderWidth

func (rect *Rectangle) SetBorderWidth(bw float64)

SetBorderWidth sets the border width of the rectangle.

func (*Rectangle) SetCoords

func (rect *Rectangle) SetCoords(x, y float64)

SetCoords sets the upper left corner coordinates of the rectangle.

func (*Rectangle) SetFillColor

func (rect *Rectangle) SetFillColor(col Color)

SetFillColor sets the fill color of the rectangle.

func (*Rectangle) SetFillOpacity

func (rect *Rectangle) SetFillOpacity(opacity float64)

SetFillOpacity sets the fill opacity of the rectangle.

func (*Rectangle) SetFitMode

func (rect *Rectangle) SetFitMode(fitMode FitMode)

SetFitMode sets the fit mode of the rectangle. NOTE: The fit mode is only applied if relative positioning is used.

func (*Rectangle) SetHeight

func (rect *Rectangle) SetHeight(height float64)

SetHeight sets the height of the rectangle.

func (*Rectangle) SetMargins

func (rect *Rectangle) SetMargins(left, right, top, bottom float64)

SetMargins sets the margins of the rectangle. NOTE: rectangle margins are only applied if relative positioning is used.

func (*Rectangle) SetPositioning

func (rect *Rectangle) SetPositioning(position Positioning)

SetPositioning sets the positioning of the rectangle (absolute or relative).

func (*Rectangle) SetWidth

func (rect *Rectangle) SetWidth(width float64)

SetWidth sets the width of the rectangle.

func (*Rectangle) Width

func (rect *Rectangle) Width() float64

Width returns the width of the rectangle. NOTE: the returned value does not include the border width of the rectangle.

type StyledParagraph

StyledParagraph represents text drawn with a specified font and can wrap across lines and pages. By default occupies the available width in the drawing context.

type StyledParagraph struct {
    // contains filtered or unexported fields
}
func (p *StyledParagraph) AddExternalLink(text, url string) *TextChunk

AddExternalLink adds a new external link to the paragraph. The text parameter represents the text that is displayed and the url parameter sets the destionation of the link.

func (p *StyledParagraph) AddInternalLink(text string, page int64, x, y, zoom float64) *TextChunk

AddInternalLink adds a new internal link to the paragraph. The text parameter represents the text that is displayed. The user is taken to the specified page, at the specified x and y coordinates. Position 0, 0 is at the top left of the page. The zoom of the destination page is controlled with the zoom parameter. Pass in 0 to keep the current zoom value.

func (*StyledParagraph) Append

func (p *StyledParagraph) Append(text string) *TextChunk

Append adds a new text chunk to the paragraph.

func (*StyledParagraph) EnableWordWrap

func (p *StyledParagraph) EnableWordWrap(val bool)

EnableWordWrap sets the paragraph word wrap flag.

func (*StyledParagraph) GeneratePageBlocks

func (p *StyledParagraph) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks generates the page blocks. Multiple blocks are generated if the contents wrap over multiple pages. Implements the Drawable interface.

func (*StyledParagraph) GetMargins

func (p *StyledParagraph) GetMargins() (float64, float64, float64, float64)

GetMargins returns the Paragraph's margins: left, right, top, bottom.

func (*StyledParagraph) Height

func (p *StyledParagraph) Height() float64

Height returns the height of the Paragraph. The height is calculated based on the input text and how it is wrapped within the container. Does not include Margins.

func (*StyledParagraph) Insert

func (p *StyledParagraph) Insert(index uint, text string) *TextChunk

Insert adds a new text chunk at the specified position in the paragraph.

func (*StyledParagraph) Reset

func (p *StyledParagraph) Reset()

Reset removes all the text chunks the paragraph contains.

func (*StyledParagraph) SetAngle

func (p *StyledParagraph) SetAngle(angle float64)

SetAngle sets the rotation angle of the text.

func (*StyledParagraph) SetEnableWrap

func (p *StyledParagraph) SetEnableWrap(enableWrap bool)

SetEnableWrap sets the line wrapping enabled flag.

func (*StyledParagraph) SetLineHeight

func (p *StyledParagraph) SetLineHeight(lineheight float64)

SetLineHeight sets the line height (1.0 default).

func (*StyledParagraph) SetMargins

func (p *StyledParagraph) SetMargins(left, right, top, bottom float64)

SetMargins sets the Paragraph's margins.

func (*StyledParagraph) SetPos

func (p *StyledParagraph) SetPos(x, y float64)

SetPos sets absolute positioning with specified coordinates.

func (*StyledParagraph) SetText

func (p *StyledParagraph) SetText(text string) *TextChunk

SetText replaces all the text of the paragraph with the specified one.

func (*StyledParagraph) SetTextAlignment

func (p *StyledParagraph) SetTextAlignment(align TextAlignment)

SetTextAlignment sets the horizontal alignment of the text within the space provided.

func (*StyledParagraph) SetTextOverflow

func (p *StyledParagraph) SetTextOverflow(textOverflow TextOverflow)

SetTextOverflow controls the behavior of paragraph text which does not fit in the available space.

func (*StyledParagraph) SetTextVerticalAlignment

func (p *StyledParagraph) SetTextVerticalAlignment(align TextVerticalAlignment)

SetTextVerticalAlignment sets the vertical alignment of the text within the bounds of the styled paragraph.

Note: Currently Styled Paragraph doesn't support TextVerticalAlignmentBottom as that option only used for aligning text chunks.

In order to change the vertical alignment of individual text chunks, use TextChunk.VerticalAlignment.

func (*StyledParagraph) SetWidth

func (p *StyledParagraph) SetWidth(width float64)

SetWidth sets the the Paragraph width. This is essentially the wrapping width, i.e. the width the text can extend to prior to wrapping over to next line.

func (*StyledParagraph) Width

func (p *StyledParagraph) Width() float64

Width returns the width of the Paragraph.

type TOC

TOC represents a table of contents component. It consists of a paragraph heading and a collection of table of contents lines. The representation of a table of contents line is as follows:

[number] [title]      [separator] [page]

e.g.: Chapter1 Introduction ........... 1

type TOC struct {
    // contains filtered or unexported fields
}

func (*TOC) Add

func (t *TOC) Add(number, title, page string, level uint) *TOCLine

Add adds a new line with the default style to the table of contents.

func (*TOC) AddLine

func (t *TOC) AddLine(line *TOCLine) *TOCLine

AddLine adds a new line with the provided style to the table of contents.

func (*TOC) GeneratePageBlocks

func (t *TOC) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks generate the Page blocks. Multiple blocks are generated if the contents wrap over multiple pages.

func (*TOC) Heading

func (t *TOC) Heading() *StyledParagraph

Heading returns the heading component of the table of contents.

func (*TOC) Lines

func (t *TOC) Lines() []*TOCLine

Lines returns all the lines the table of contents has.

func (*TOC) SetHeading

func (t *TOC) SetHeading(text string, style TextStyle)

SetHeading sets the text and the style of the heading of the TOC component.

func (*TOC) SetLineLevelOffset

func (t *TOC) SetLineLevelOffset(levelOffset float64)

SetLineLevelOffset sets the amount of space an indentation level occupies for all new lines of the table of contents.

func (*TOC) SetLineMargins

func (t *TOC) SetLineMargins(left, right, top, bottom float64)

SetLineMargins sets the margins for all new lines of the table of contents.

func (*TOC) SetLineNumberStyle

func (t *TOC) SetLineNumberStyle(style TextStyle)

SetLineNumberStyle sets the style for the numbers part of all new lines of the table of contents.

func (*TOC) SetLinePageStyle

func (t *TOC) SetLinePageStyle(style TextStyle)

SetLinePageStyle sets the style for the page part of all new lines of the table of contents.

func (*TOC) SetLineSeparator

func (t *TOC) SetLineSeparator(separator string)

SetLineSeparator sets the separator for all new lines of the table of contents.

func (*TOC) SetLineSeparatorStyle

func (t *TOC) SetLineSeparatorStyle(style TextStyle)

SetLineSeparatorStyle sets the style for the separator part of all new lines of the table of contents.

func (*TOC) SetLineStyle

func (t *TOC) SetLineStyle(style TextStyle)

SetLineStyle sets the style for all the line components: number, title, separator, page. The style is applied only for new lines added to the TOC component.

func (*TOC) SetLineTitleStyle

func (t *TOC) SetLineTitleStyle(style TextStyle)

SetLineTitleStyle sets the style for the title part of all new lines of the table of contents.

func (t *TOC) SetShowLinks(showLinks bool)

SetShowLinks sets visibility of links for the TOC lines.

type TOCLine

TOCLine represents a line in a table of contents. The component can be used both in the context of a table of contents component and as a standalone component. The representation of a table of contents line is as follows:

      [number] [title]      [separator] [page]
e.g.: Chapter1 Introduction ........... 1
type TOCLine struct {

    // Holds the text and style of the number part of the TOC line.
    Number TextChunk

    // Holds the text and style of the title part of the TOC line.
    Title TextChunk

    // Holds the text and style of the separator part of the TOC line.
    Separator TextChunk

    // Holds the text and style of the page part of the TOC line.
    Page TextChunk
    // contains filtered or unexported fields
}

func (*TOCLine) GeneratePageBlocks

func (tl *TOCLine) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks generate the Page blocks. Multiple blocks are generated if the contents wrap over multiple pages.

func (*TOCLine) GetMargins

func (tl *TOCLine) GetMargins() (float64, float64, float64, float64)

GetMargins returns the margins of the TOC line: left, right, top, bottom.

func (*TOCLine) Level

func (tl *TOCLine) Level() uint

Level returns the indentation level of the TOC line.

func (*TOCLine) LevelOffset

func (tl *TOCLine) LevelOffset() float64

LevelOffset returns the amount of space an indentation level occupies.

func (tl *TOCLine) Link() (page int64, x, y float64)

Link returns link information for this line.

func (*TOCLine) SetLevel

func (tl *TOCLine) SetLevel(level uint)

SetLevel sets the indentation level of the TOC line.

func (*TOCLine) SetLevelOffset

func (tl *TOCLine) SetLevelOffset(levelOffset float64)

SetLevelOffset sets the amount of space an indentation level occupies.

func (tl *TOCLine) SetLink(page int64, x, y float64)

SetLink makes the line an internal link. The text parameter represents the text that is displayed. The user is taken to the specified page, at the specified x and y coordinates. Position 0, 0 is at the top left of the page.

func (*TOCLine) SetMargins

func (tl *TOCLine) SetMargins(left, right, top, bottom float64)

SetMargins sets the margins TOC line.

func (*TOCLine) SetStyle

func (tl *TOCLine) SetStyle(style TextStyle)

SetStyle sets the style for all the line components: number, title, separator, page.

type Table

Table allows organizing content in an rows X columns matrix, which can spawn across multiple pages.

type Table struct {
    // contains filtered or unexported fields
}

func (*Table) AddSubtable

func (table *Table) AddSubtable(row, col int, subtable *Table)

AddSubtable copies the cells of the subtable in the table, starting with the specified position. The table row and column indices are 1-based, which makes the position of the first cell of the first row of the table 1,1. The table is automatically extended if the subtable exceeds its columns. This can happen when the subtable has more columns than the table or when one or more columns of the subtable starting from the specified position exceed the last column of the table.

func (*Table) Cols

func (table *Table) Cols() int

Cols returns the total number of columns the table has.

func (*Table) CurCol

func (table *Table) CurCol() int

CurCol returns the currently active cell's column number.

func (*Table) CurRow

func (table *Table) CurRow() int

CurRow returns the currently active cell's row number.

func (*Table) EnablePageWrap

func (table *Table) EnablePageWrap(enable bool)

EnablePageWrap controls whether the table is wrapped across pages. If disabled, the table is moved in its entirety on a new page, if it does not fit in the available height. By default, page wrapping is enabled. If the height of the table is larger than an entire page, wrapping is enabled automatically in order to avoid unwanted behavior.

func (*Table) EnableRowWrap

func (table *Table) EnableRowWrap(enable bool)

EnableRowWrap controls whether rows are wrapped across pages. NOTE: Currently, row wrapping is supported for rows using StyledParagraphs.

func (*Table) GeneratePageBlocks

func (table *Table) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error)

GeneratePageBlocks generates the table page blocks. Multiple blocks are generated if the contents wrap over multiple pages. Implements the Drawable interface.

func (*Table) GetMargins

func (table *Table) GetMargins() (float64, float64, float64, float64)

GetMargins returns the left, right, top, bottom Margins.

func (*Table) GetRowHeight

func (table *Table) GetRowHeight(row int) (float64, error)

GetRowHeight returns the height of the specified row.

func (*Table) Height

func (table *Table) Height() float64

Height returns the total height of all rows.

func (*Table) MultiCell

func (table *Table) MultiCell(rowspan, colspan int) *TableCell

MultiCell makes a new cell with the specified row span and col span and inserts it into the table at the current position.

func (*Table) MultiColCell

func (table *Table) MultiColCell(colspan int) *TableCell

MultiColCell makes a new cell with the specified column span and inserts it into the table at the current position.

func (*Table) MultiRowCell

func (table *Table) MultiRowCell(rowspan int) *TableCell

MultiRowCell makes a new cell with the specified row span and inserts it into the table at the current position.

func (*Table) NewCell

func (table *Table) NewCell() *TableCell

NewCell makes a new cell and inserts it into the table at the current position.

func (*Table) Rows

func (table *Table) Rows() int

Rows returns the total number of rows the table has.

func (*Table) SetColumnWidths

func (table *Table) SetColumnWidths(widths ...float64) error

SetColumnWidths sets the fractional column widths. Each width should be in the range 0-1 and is a fraction of the table width. The number of width inputs must match number of columns, otherwise an error is returned.

func (*Table) SetCompactMode

func (table *Table) SetCompactMode(enable bool)

SetCompactMode sets the compact mode flag for this table.

By enabling compact mode, table cell that contains Paragraph/StyleParagraph would not add extra height when calculating it's height.

The default value is false.

func (*Table) SetHeaderRows

func (table *Table) SetHeaderRows(startRow, endRow int) error

SetHeaderRows turns the selected table rows into headers that are repeated for every page the table spans. startRow and endRow are inclusive.

func (*Table) SetMargins

func (table *Table) SetMargins(left, right, top, bottom float64)

SetMargins sets the Table's left, right, top, bottom margins.

func (*Table) SetPos

func (table *Table) SetPos(x, y float64)

SetPos sets the Table's positioning to absolute mode and specifies the upper-left corner coordinates as (x,y). Note that this is only sensible to use when the table does not wrap over multiple pages. TODO: Should be able to set width too (not just based on context/relative positioning mode).

func (*Table) SetRowHeight

func (table *Table) SetRowHeight(row int, h float64) error

SetRowHeight sets the height for a specified row.

func (*Table) SkipCells

func (table *Table) SkipCells(num int)

SkipCells skips over a specified number of cells in the table.

func (*Table) SkipOver

func (table *Table) SkipOver(rows, cols int)

SkipOver skips over a specified number of rows and cols.

func (*Table) SkipRows

func (table *Table) SkipRows(num int)

SkipRows skips over a specified number of rows in the table.

func (*Table) Width

func (table *Table) Width() float64

Width is not used. Not used as a Table element is designed to fill into available width depending on the context. Returns 0.

type TableCell

TableCell defines a table cell which can contain a Drawable as content.

type TableCell struct {
    // contains filtered or unexported fields
}

func (*TableCell) GetIndent

func (cell *TableCell) GetIndent() float64

GetIndent get the cell's left indent.

func (*TableCell) SetBackgroundColor

func (cell *TableCell) SetBackgroundColor(col Color)

SetBackgroundColor sets the cell's background color.

func (*TableCell) SetBorder

func (cell *TableCell) SetBorder(side CellBorderSide, style CellBorderStyle, width float64)

SetBorder sets the cell's border style.

func (*TableCell) SetBorderColor

func (cell *TableCell) SetBorderColor(col Color)

SetBorderColor sets the cell's border color.

func (*TableCell) SetBorderLineStyle

func (cell *TableCell) SetBorderLineStyle(style draw.LineStyle)

SetBorderLineStyle sets border style (currently dashed or plain).

func (*TableCell) SetColPosition

func (cell *TableCell) SetColPosition(col int)

SetColPosition sets cell column position.

func (*TableCell) SetContent

func (cell *TableCell) SetContent(vd VectorDrawable) error

SetContent sets the cell's content. The content is a VectorDrawable, i.e. a Drawable with a known height and width. Currently supported VectorDrawables: - *Paragraph - *StyledParagraph - *Image - *Chart - *Table - *Division - *List - *Rectangle - *Ellipse - *Line

func (*TableCell) SetHorizontalAlignment

func (cell *TableCell) SetHorizontalAlignment(halign CellHorizontalAlignment)

SetHorizontalAlignment sets the cell's horizontal alignment of content. Can be one of: - CellHorizontalAlignmentLeft - CellHorizontalAlignmentCenter - CellHorizontalAlignmentRight

func (*TableCell) SetIndent

func (cell *TableCell) SetIndent(indent float64)

SetIndent sets the cell's left indent.

func (*TableCell) SetRowPosition

func (cell *TableCell) SetRowPosition(row int)

SetRowPosition sets cell row position.

func (*TableCell) SetSideBorderColor

func (cell *TableCell) SetSideBorderColor(side CellBorderSide, col Color)

SetSideBorderColor sets the cell's side border color.

func (*TableCell) SetSideBorderStyle

func (cell *TableCell) SetSideBorderStyle(side CellBorderSide, style CellBorderStyle)

SetSideBorderStyle sets the cell's side border style.

func (*TableCell) SetSideBorderWidth

func (cell *TableCell) SetSideBorderWidth(side CellBorderSide, width float64)

SetSideBorderWidth sets the cell's side border width.

func (*TableCell) SetVerticalAlignment

func (cell *TableCell) SetVerticalAlignment(valign CellVerticalAlignment)

SetVerticalAlignment set the cell's vertical alignment of content. Can be one of: - CellHorizontalAlignmentTop - CellHorizontalAlignmentMiddle - CellHorizontalAlignmentBottom

func (*TableCell) Width

func (cell *TableCell) Width(ctx DrawContext) float64

Width returns the cell's width based on the input draw context.

type TemplateOptions

TemplateOptions contains options and resources to use when rendering a template with a Creator instance. All the resources in the map fields can be referenced by their name/key in the template which is rendered using the options instance.

type TemplateOptions struct {
    // HelperFuncMap is used to define functions which can be accessed
    // inside the rendered templates by their assigned names.
    HelperFuncMap template.FuncMap

    // SubtemplateMap contains templates which can be rendered alongside
    // the main template. They can be accessed using their assigned names
    // in the main template or in the other subtemplates.
    // Subtemplates defined inside the subtemplates specified in the map
    // can be accessed directly.
    // All resources available to the main template are also available
    // to the subtemplates.
    SubtemplateMap map[string]io.Reader

    // FontMap contains pre-loaded fonts which can be accessed
    // inside the rendered templates by their assigned names.
    FontMap map[string]*model.PdfFont

    // ImageMap contains pre-loaded images which can be accessed
    // inside the rendered templates by their assigned names.
    ImageMap map[string]*model.Image

    // ColorMap contains colors which can be accessed
    // inside the rendered templates by their assigned names.
    ColorMap map[string]Color

    // ChartMap contains charts which can be accessed
    // inside the rendered templates by their assigned names.
    ChartMap map[string]render.ChartRenderable
}

type TextAlignment

TextAlignment options for paragraph.

type TextAlignment int

The options supported for text alignment are: left - TextAlignmentLeft right - TextAlignmentRight center - TextAlignmentCenter justify - TextAlignmentJustify

const (
    TextAlignmentLeft TextAlignment = iota
    TextAlignmentRight
    TextAlignmentCenter
    TextAlignmentJustify
)

type TextChunk

TextChunk represents a chunk of text along with a particular style.

type TextChunk struct {
    // The text that is being rendered in the PDF.
    Text string

    // The style of the text being rendered.
    Style TextStyle

    // The vertical alignment of the text chunk.
    VerticalAlignment TextVerticalAlignment
    // contains filtered or unexported fields
}

func NewTextChunk

func NewTextChunk(text string, style TextStyle) *TextChunk

NewTextChunk returns a new text chunk instance.

func (*TextChunk) Fit

func (tc *TextChunk) Fit(width, height float64) (*TextChunk, error)

Fit fits the chunk into the specified bounding box, cropping off the remainder in a new chunk, if it exceeds the specified dimensions. NOTE: The method assumes a line height of 1.0. In order to account for other line height values, the passed in height must be divided by the line height: height = height / lineHeight

func (*TextChunk) SetAnnotation

func (tc *TextChunk) SetAnnotation(annotation *model.PdfAnnotation)

SetAnnotation sets a annotation on a TextChunk.

func (*TextChunk) Width

func (tc *TextChunk) Width() float64

Width returns the width of the specified text chunk.

func (*TextChunk) Wrap

func (tc *TextChunk) Wrap(width float64) ([]string, error)

Wrap wraps the text of the chunk into lines based on its style and the specified width.

type TextDecorationLineStyle

TextDecorationLineStyle represents the style of lines used to decorate a text chunk (e.g. underline).

type TextDecorationLineStyle struct {
    // Color represents the color of the line (default: the color of the text).
    Color Color

    // Offset represents the vertical offset of the line (default: 1).
    Offset float64

    // Thickness represents the thickness of the line (default: 1).
    Thickness float64
}

type TextOverflow

TextOverflow determines the behavior of paragraph text which does not fit in the available space.

type TextOverflow int

Text overflow options.

const (
    TextOverflowVisible TextOverflow = iota
    TextOverflowHidden
)

type TextRenderingMode

TextRenderingMode determines whether showing text shall cause glyph outlines to be stroked, filled, used as a clipping boundary, or some combination of the three. See section 9.3 "Text State Parameters and Operators" and Table 106 (pp. 254-255 PDF32000_2008).

type TextRenderingMode int
const (
    // TextRenderingModeFill (default) - Fill text.
    TextRenderingModeFill TextRenderingMode = iota

    // TextRenderingModeStroke - Stroke text.
    TextRenderingModeStroke

    // TextRenderingModeFillStroke - Fill, then stroke text.
    TextRenderingModeFillStroke

    // TextRenderingModeInvisible - Neither fill nor stroke text (invisible).
    TextRenderingModeInvisible

    // TextRenderingModeFillClip - Fill text and add to path for clipping.
    TextRenderingModeFillClip

    // TextRenderingModeStrokeClip - Stroke text and add to path for clipping.
    TextRenderingModeStrokeClip

    // TextRenderingModeFillStrokeClip - Fill, then stroke text and add to path for clipping.
    TextRenderingModeFillStrokeClip

    // TextRenderingModeClip - Add text to path for clipping.
    TextRenderingModeClip
)

type TextStyle

TextStyle is a collection of properties that can be assigned to a text chunk.

type TextStyle struct {
    // Color represents the color of the text.
    Color Color

    // OutlineColor represents the color of the text outline.
    OutlineColor Color

    // MultiFont represents an encoder that accepts multiple fonts and selects the correct font for encoding.
    MultiFont *model.MultipleFontEncoder

    // Font represents the font the text will use.
    Font *model.PdfFont

    // FontSize represents the size of the font.
    FontSize float64

    // OutlineSize represents the thickness of the text outline.
    OutlineSize float64

    // CharSpacing represents the character spacing.
    CharSpacing float64

    // HorizontalScaling represents the percentage to horizontally scale
    // characters by (default: 100). Values less than 100 will result in
    // narrower text while values greater than 100 will result in wider text.
    HorizontalScaling float64

    // RenderingMode represents the rendering mode.
    RenderingMode TextRenderingMode

    // Underline specifies if the text chunk is underlined.
    Underline bool

    // UnderlineStyle represents the style of the line used to underline text.
    UnderlineStyle TextDecorationLineStyle

    // TextRise specifies a vertical adjustment for text. It is useful for
    // drawing subscripts/superscripts. A positive text rise value will
    // produce superscript text, while a negative one will result in
    // subscript text.
    TextRise float64
}

type TextVerticalAlignment

TextVerticalAlignment controls the vertical position of the text in a styled paragraph.

type TextVerticalAlignment int

Text vertical alignment options.

const (
    TextVerticalAlignmentBaseline TextVerticalAlignment = iota
    TextVerticalAlignmentCenter
    TextVerticalAlignmentBottom
    TextVerticalAlignmentTop
)

type UnsupportedRuneError

UnsupportedRuneError is an error that occurs when there is unsupported glyph being used.

type UnsupportedRuneError struct {
    Message string
    Rune    rune
}

func (UnsupportedRuneError) Error

func (e UnsupportedRuneError) Error() string

String implements error interface.

type VectorDrawable

VectorDrawable is a Drawable with a specified width and height.

type VectorDrawable interface {
    Drawable

    // Width returns the width of the Drawable.
    Width() float64

    // Height returns the height of the Drawable.
    Height() float64
}