Documentation ¶
Index ¶
- Variables
- type BarcodeElement
- type BarcodeType
- type Builder
- func (q *Builder) AddElement(item ...Element)
- func (q *Builder) Build() ([]byte, error)
- func (q *Builder) CurrPage() *Page
- func (q *Builder) NewCapturedPage(sourcePage types.Page, sourceFile *pdffile.File) (*Form, error)
- func (q *Builder) NewCompositeFont(ttf []byte) (*pdf.CompositeFont, error)
- func (q *Builder) NewCompositeFontFromOTF(otf []byte) (*pdf.CompositeFontOTF, error)
- func (q *Builder) NewFormFromPage(page *Page) (*Form, error)
- func (q *Builder) NewImage(bts []byte) (*pdf.Image, error)
- func (q *Builder) NewPage(size PageSize) *Page
- func (q *Builder) NewPageBefore(size PageSize, beforePageNo int) *Page
- func (q *Builder) NewStandardFont(name types.StandardFontName, encoding types.Encoding) (*pdf.StandardFont, error)
- func (q *Builder) NewTrueTypeFont(ttf []byte, encoding types.Encoding, embed bool) (*pdf.TrueTypeFont, error)
- func (q *Builder) PageCount() int
- func (q *Builder) SelectPage(pageNo int) error
- type CircleElement
- type Color
- type ColorCMYK
- type ColorGray
- type ColorRGB
- type DashPattern
- type Element
- type EllipseElement
- type Form
- type HorizontalAlign
- type ImageBoxElement
- type ImageElement
- type Length
- type LineElement
- type LinearMeasure
- type Page
- type PageSize
- type QRCodeElement
- type RectElement
- type StandardPageSize
- type TextBoxElement
- type TextChunk
- type TextChunkBoxElement
- type TextElement
- type VerticalAlign
Constants ¶
This section is empty.
Variables ¶
var ColorRGBBlack = ColorRGB{R: 0, G: 0, B: 0}
Functions ¶
This section is empty.
Types ¶
type BarcodeElement ¶ added in v1.0.20
type BarcodeElement struct {
Left, Top, Width, Height Length
Text string
Color Color
Rotate float64
Flipped bool
Type BarcodeType
Transparency float64
}
BarcodeElement is used to add a barcode to a page
type BarcodeType ¶ added in v1.0.31
type BarcodeType int
const ( BarcodeType39 BarcodeType = 1 BarcodeTypeEAN13 BarcodeType = 2 BarcodeType128 BarcodeType = 3 )
type Builder ¶
type Builder struct { Info types.InformationDictionary ID [2]string // Threshold length for compressing content streams CompressStreamsThreshold int // PDF Version number Version float64 // number of worker routines used to generate content streams of pages WorkerRoutines int // contains filtered or unexported fields }
Builder is the main object to build a PDF file
func (*Builder) AddElement ¶ added in v1.0.54
AddElement adds one or more elements to the current page
func (*Builder) NewCapturedPage ¶
NewCapturedPage adds a new captured page to the PDF file
func (*Builder) NewCompositeFont ¶
func (q *Builder) NewCompositeFont(ttf []byte) (*pdf.CompositeFont, error)
NewCompositeFont adds a font as composite font to the pdf, i.e. with Unicode support
func (*Builder) NewCompositeFontFromOTF ¶ added in v1.0.31
func (q *Builder) NewCompositeFontFromOTF(otf []byte) (*pdf.CompositeFontOTF, error)
NewCompositeFontFromOTF adds an otf font as composite font to the pdf, i.e. with Unicode support
func (*Builder) NewFormFromPage ¶ added in v1.0.26
NewFormFromPage creates a new form object from the give page
func (*Builder) NewPageBefore ¶ added in v1.0.20
NewPageBefore inserts a new page before the given pageNo to the pdf
func (*Builder) NewStandardFont ¶
func (q *Builder) NewStandardFont(name types.StandardFontName, encoding types.Encoding) (*pdf.StandardFont, error)
NewStandardFont adds a new standard font (expected to be available in all PDF consuming systems) to the pdf
func (*Builder) NewTrueTypeFont ¶
func (q *Builder) NewTrueTypeFont(ttf []byte, encoding types.Encoding, embed bool) (*pdf.TrueTypeFont, error)
NewTrueTypeFont adds a new TrueType font to the pdf
func (*Builder) SelectPage ¶ added in v1.0.54
SelectPage set the current page to the page with the given number (starting from 1)
type CircleElement ¶ added in v1.0.20
type CircleElement struct {
X, Y, Radius Length
LineWidth Length
LineColor Color
FillColor Color
DashPattern DashPattern
Transparency float64
}
CircleElement is used to add a circle to a page
type Color ¶
Color is the interface any type of color needs to fulfill
func ParseColor ¶ added in v1.0.31
ParseColor parses a string to a color. Can be r,g,b or c,m,y,k or #RRGGBB
type ColorCMYK ¶
ColorCMYK represents a CMYK color value
func NewColorCMYK ¶
NewColorCMYK creates a new ColorCMYK object
type ColorGray ¶
type ColorGray struct {
Gray int
}
ColorGray represents a gray color value
func NewColorGray ¶
NewColorGray creates a new ColorGray object
type DashPattern ¶ added in v1.0.22
DashPattern represents a dash pattern
func NewDashPattern ¶ added in v1.0.22
func NewDashPattern(phase Length, array ...Length) DashPattern
NewDashPattern creates a new DashPattern object
type Element ¶
Element is the interface any object needs to fulfill to be added to the content stream of a page
type EllipseElement ¶ added in v1.0.22
type EllipseElement struct {
Left, Top, Width, Height Length
LineWidth Length
LineColor Color
FillColor Color
DashPattern DashPattern
Transparency float64
}
EllipseElement is used to add an ellipse to a page
type Form ¶ added in v1.0.26
Form is used to add a captured page from another document to a page
type HorizontalAlign ¶ added in v1.0.35
type HorizontalAlign int
const ( HorizontalAlignLeft HorizontalAlign = 0 HorizontalAlignCenter HorizontalAlign = 1 HorizontalAlignRight HorizontalAlign = 2 )
type ImageBoxElement ¶
type ImageBoxElement struct {
Left, Top, Width, Height Length
Img *pdf.Image
VerticalAlign VerticalAlign
HorizontalAlign HorizontalAlign
Rotate float64
Transparency float64
}
ImageBoxElement is used to add an image box to a page
type ImageElement ¶
type ImageElement struct { Img *pdf.Image Left, Top, Width, Height Length Rotate float64 Transparency float64 }
ImageElement is used to add an image to a page
type Length ¶
type Length struct { Value float64 Unit LinearMeasure }
Length represents a length using a certain measure
type LineElement ¶
type LineElement struct {
X1, Y1, X2, Y2 Length
LineWidth Length
Color Color
DashPattern DashPattern
Transparency float64
}
LineElement is used to add a line to a page
type LinearMeasure ¶
type LinearMeasure int
LinearMeasure represents a linear measure like mm or inch.
const ( UnitPt LinearMeasure = iota UnitMM UnitInch )
type Page ¶
type Page struct { Width Length Height Length Rotate int // contains filtered or unexported fields }
Page represents on page in the PDF document to which elements can be added arbitrarily
func (*Page) AddElement ¶
AddElement adds one or more elements to the page
type PageSize ¶
type PageSize [2]Length
PageSize is width x height
func GetStandardPageSize ¶
func GetStandardPageSize(size StandardPageSize, landscape bool) PageSize
GetStandardPageSize returns a standard page size like DIN-A4 in either portrait or landscape
type QRCodeElement ¶ added in v1.0.23
type QRCodeElement struct {
Left, Top, Size Length
Text string
Color Color
RecoveryLevel qrcode.RecoveryLevel
Rotate float64
Transparency float64
}
QRCodeElement is used to add a QRCode to a page
type RectElement ¶
type RectElement struct {
Left, Top, Width, Height Length
LineWidth Length
LineColor Color
FillColor Color
DashPattern DashPattern
Rotate float64
Transparency float64
}
RectElement is used to add a rectangle to a page
type StandardPageSize ¶
type StandardPageSize int
StandardPageSize is used for GetStandardPageSize to get a standard page size like DIN-A4
const ( PageSizeA0 StandardPageSize = iota PageSizeA1 PageSizeA2 PageSizeA3 PageSizeA4 PageSizeA5 PageSizeA6 PageSizeA7 PageSizeLetter PageSizeLegal )
type TextBoxElement ¶
type TextBoxElement struct { TextElement Width, Height Length VerticalAlign VerticalAlign HeightBufferRel float64 }
TextBoxElement is similar to TextElement, but can have a maximum width and height
func (*TextBoxElement) Build ¶
func (q *TextBoxElement) Build(page *pdf.Page) (string, error)
Build adds the element to the content stream
func (*TextBoxElement) ShrinkToFit ¶ added in v1.0.65
func (q *TextBoxElement) ShrinkToFit()
ShrinkToFit reduces the font size so that the entire text fits into the box
func (*TextBoxElement) TextHeight ¶
func (q *TextBoxElement) TextHeight() Length
TextHeight returns the height of the text, accounting for line breaks and max width
type TextChunk ¶ added in v1.0.62
type TextChunk struct { Text string Font pdf.FontHandler FontSize float64 Color Color OutlineColor Color OutlineWidth Length DashPattern DashPattern Bold bool Italic bool Underline bool StrikeThrough bool CharSpacing Length TextScaling float64 }
func (*TextChunk) FontHeight ¶ added in v1.0.62
FontHeight returns the height of the font (bounding box y min to max)
type TextChunkBoxElement ¶ added in v1.0.62
type TextChunkBoxElement struct { Chunks []TextChunk Transparency float64 LineHeight float64 Left, Top Length Width, Height Length Rotate float64 TextAlign HorizontalAlign VerticalAlign VerticalAlign HeightBufferRel float64 }
TextChunkBoxElement is similar to TextBoxElement, but can have chunks with different format
func (*TextChunkBoxElement) Build ¶ added in v1.0.62
func (q *TextChunkBoxElement) Build(page *pdf.Page) (string, error)
Build adds the element to the content stream
func (*TextChunkBoxElement) ShrinkToFit ¶ added in v1.0.65
func (q *TextChunkBoxElement) ShrinkToFit()
ShrinkToFit reduces the font size so that the entire text fits into the box
func (*TextChunkBoxElement) TextHeight ¶ added in v1.0.62
func (q *TextChunkBoxElement) TextHeight() Length
TextHeight returns the height of the text, accounting for line breaks and max width
type TextElement ¶
type TextElement struct { TextChunk Left, Top Length TextAlign HorizontalAlign LineHeight float64 Rotate float64 Transparency float64 }
TextElement draws a text, may have line breaks
func (*TextElement) Build ¶
func (q *TextElement) Build(page *pdf.Page) (string, error)
Build adds the element to the content stream
func (*TextElement) FontHeight ¶ added in v1.0.31
func (q *TextElement) FontHeight() Length
FontHeight returns the height of the font (bounding box y min to max)
func (*TextElement) TextHeight ¶
func (q *TextElement) TextHeight() Length
TextHeight returns the height of the text, accounting for line breaks
type VerticalAlign ¶
type VerticalAlign int
const ( VerticalAlignTop VerticalAlign = 0 VerticalAlignMiddle VerticalAlign = 1 VerticalAlignBottom VerticalAlign = 2 )
Source Files ¶
- align.go
- builder.go
- color.go
- dashpattern.go
- element.go
- elements_barcode.go
- elements_circle.go
- elements_ellipse.go
- elements_form.go
- elements_image.go
- elements_imagebox.go
- elements_line.go
- elements_qrcode.go
- elements_rect.go
- elements_text.go
- elements_textbox.go
- elements_textchunkbox.go
- length.go
- page.go
- pagesize.go
- textchunk.go
Directories ¶
Path | Synopsis |
---|---|
standardfont/afm
Package afm implements a decoder for AFM (Adobe Font Metrics) files.
|
Package afm implements a decoder for AFM (Adobe Font Metrics) files. |
standardfont/fixed
Package fixed provides types to work with fixed-point numbers.
|
Package fixed provides types to work with fixed-point numbers. |