Versions in this module Expand all Collapse all v1 v1.2.0 Aug 8, 2023 v1.1.0 Aug 8, 2023 Changes in this version + var ColorBlack = ColorRGBFromArithmetic(0, 0, 0) + var ColorBlue = ColorRGBFromArithmetic(0, 0, 1) + var ColorGreen = ColorRGBFromArithmetic(0, 1, 0) + var ColorRed = ColorRGBFromArithmetic(1, 0, 0) + var ColorWhite = ColorRGBFromArithmetic(1, 1, 1) + var ColorYellow = ColorRGBFromArithmetic(1, 1, 0) + var PPI float64 = 72 + var PPMM = float64(72 * 1.0 / 25.4) + var PageSizeA3 = PageSize + var PageSizeA4 = PageSize + var PageSizeA5 = PageSize + var PageSizeLegal = PageSize + var PageSizeLetter = PageSize + type Block struct + 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) 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 int + const CellBorderSideAll + const CellBorderSideBottom + const CellBorderSideLeft + const CellBorderSideRight + const CellBorderSideTop + type CellBorderStyle int + const CellBorderStyleDouble + const CellBorderStyleNone + const CellBorderStyleSingle + type CellHorizontalAlignment int + const CellHorizontalAlignmentCenter + const CellHorizontalAlignmentLeft + const CellHorizontalAlignmentRight + type CellVerticalAlignment int + const CellVerticalAlignmentBottom + const CellVerticalAlignmentMiddle + const CellVerticalAlignmentTop + type Chapter struct + 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 Color interface + ToRGB func() (float64, float64, float64) + func ColorRGBFrom8bit(r, g, b byte) Color + func ColorRGBFromArithmetic(r, g, b float64) Color + func ColorRGBFromHex(hexStr string) Color + type Creator struct + AddOutlines bool + AddTOC bool + 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) Finalize() 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) NewDivision() *Division + func (c *Creator) NewEllipse(xc, yc, width, height float64) *Ellipse + func (c *Creator) NewFilledCurve() *FilledCurve + func (c *Creator) NewHTMLContent() *HTMLContent + 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) NewList() *List + func (c *Creator) NewPage() *model.PdfPage + func (c *Creator) NewPageBreak() *PageBreak + func (c *Creator) NewParagraph(text string) *Paragraph + 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) 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) 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) SignAndWrite(userPass, ownerPass []byte, writer io.Writer, config SignConfig) error + 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 struct + func (c *Curve) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error) + func (c *Curve) SetColor(col Color) + func (c *Curve) SetWidth(width float64) + type Division struct + func (div *Division) Add(d VectorDrawable) error + func (div *Division) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error) + func (div *Division) Height() float64 + func (div *Division) Inline() bool + func (div *Division) SetInline(inline bool) + func (div *Division) Width() float64 + type DrawContext struct + Height float64 + Inline bool + Margins margins + Page int + PageHeight float64 + PageWidth float64 + Width float64 + X float64 + Y float64 + type Drawable interface + GeneratePageBlocks func(ctx DrawContext) ([]*Block, DrawContext, error) + type Ellipse struct + func (ell *Ellipse) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error) + func (ell *Ellipse) GetCoords() (float64, float64) + func (ell *Ellipse) SetBorderColor(col Color) + func (ell *Ellipse) SetBorderWidth(bw float64) + func (ell *Ellipse) SetFillColor(col Color) + type FilledCurve struct + BorderEnabled bool + BorderWidth float64 + FillEnabled bool + 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 FooterFunctionArgs struct + PageNum int + TotalPages int + type FrontpageFunctionArgs struct + PageNum int + TotalPages int + type HTMLContent struct + func (h *HTMLContent) AddCSS(cssText string) error + func (h *HTMLContent) Append(htmlCode string) error + func (h *HTMLContent) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error) + func (h *HTMLContent) Height() float64 + func (h *HTMLContent) SetBoldFont(font *model.PdfFont) + func (h *HTMLContent) SetBoldItalicFont(font *model.PdfFont) + func (h *HTMLContent) SetImage(path string, img *Image) + func (h *HTMLContent) SetImageLoadCallback(callback func(string) *Image) + func (h *HTMLContent) SetItalicFont(font *model.PdfFont) + func (h *HTMLContent) SetRegularFont(font *model.PdfFont) + func (h *HTMLContent) SetRegularStyle(style TextStyle) + func (h *HTMLContent) SetWidth(w float64) + func (h *HTMLContent) Width() float64 + type HeaderFunctionArgs struct + PageNum int + TotalPages int + type HorizontalAlignment int + const HorizontalAlignmentCenter + const HorizontalAlignmentLeft + const HorizontalAlignmentRight + type Image struct + func (img *Image) ConvertToBinary() error + 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) 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) SetHeight(h float64) + func (img *Image) SetHorizontalAlignment(alignment HorizontalAlignment) + 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 struct + 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 struct + City string + Country string + Email string + Name string + Phone string + Street string + Zip string + type InvoiceCell struct + Value string + type InvoiceCellProps struct + Alignment CellHorizontalAlignment + BackgroundColor Color + BorderColor Color + BorderSides []CellBorderSide + BorderWidth float64 + TextStyle TextStyle + type Line struct + func (l *Line) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error) + func (l *Line) GetCoords() (float64, float64, float64, float64) + func (l *Line) Length() float64 + func (l *Line) SetColor(col Color) + func (l *Line) SetLineWidth(lw float64) + type List struct + 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 PageBreak struct + func (p *PageBreak) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error) + type PageSize [2]float64 + type Paragraph struct + 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) 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 Rectangle struct + func (rect *Rectangle) GeneratePageBlocks(ctx DrawContext) ([]*Block, DrawContext, error) + func (rect *Rectangle) GetCoords() (float64, float64) + func (rect *Rectangle) SetBorderColor(col Color) + func (rect *Rectangle) SetBorderWidth(bw float64) + func (rect *Rectangle) SetFillColor(col Color) + type SignConfig struct + Annotations map[string]string + Certs *x509.Certificate + Coords []SignCoords + Location string + Name string + PrivKey *rsa.PrivateKey + Reason string + Style SignStyle + type SignCoords struct + Pages []int + X1 float64 + X2 float64 + Y1 float64 + Y2 float64 + type SignStyle struct + AutoSize bool + BgColorRGBA model.PdfColorDeviceRGB + BorderColorRGBA model.PdfColorDeviceRGB + BorderSize float64 + Font *model.PdfFont + FontColorRGBA model.PdfColorDeviceRGB + FontSize float64 + LineHeight float64 + type StyledParagraph struct + 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) 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) SetWidth(width float64) + func (p *StyledParagraph) Width() float64 + type TOC struct + 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 struct + Number TextChunk + Page TextChunk + Separator TextChunk + Title TextChunk + 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) 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 struct + 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) 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) MultiColCell(colspan int) *TableCell + func (table *Table) NewCell() *TableCell + func (table *Table) Rows() int + func (table *Table) SetColumnWidths(widths ...float64) error + 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 struct + 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) SetContent(vd VectorDrawable) error + func (cell *TableCell) SetHorizontalAlignment(halign CellHorizontalAlignment) + func (cell *TableCell) SetIndent(indent float64) + func (cell *TableCell) SetVerticalAlignment(valign CellVerticalAlignment) + func (cell *TableCell) Width(ctx DrawContext) float64 + type TextAlignment int + const TextAlignmentCenter + const TextAlignmentJustify + const TextAlignmentLeft + const TextAlignmentRight + type TextChunk struct + Style TextStyle + Text string + 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) Wrap(width float64) ([]string, error) + type TextRenderingMode int + const TextRenderingModeClip + const TextRenderingModeFill + const TextRenderingModeFillClip + const TextRenderingModeFillStroke + const TextRenderingModeFillStrokeClip + const TextRenderingModeInvisible + const TextRenderingModeStroke + const TextRenderingModeStrokeClip + type TextStyle struct + CharSpacing float64 + Color Color + Font *model.PdfFont + FontSize float64 + RenderingMode TextRenderingMode + type VectorDrawable interface + Height func() float64 + Width func() float64