repo
stringlengths
5
67
sha
stringlengths
40
40
path
stringlengths
4
234
url
stringlengths
85
339
language
stringclasses
6 values
split
stringclasses
3 values
doc
stringlengths
3
51.2k
sign
stringlengths
5
8.01k
problem
stringlengths
13
51.2k
output
stringlengths
0
3.87M
buger/jsonparser
bf1c66bbce23153d89b23f8960071a680dbef54b
parser.go
https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/parser.go#L1183-L1190
go
train
// ParseString parses a String ValueType into a Go string (the main parsing work is unescaping the JSON string)
func ParseString(b []byte) (string, error)
// ParseString parses a String ValueType into a Go string (the main parsing work is unescaping the JSON string) func ParseString(b []byte) (string, error)
{ var stackbuf [unescapeStackBufSize]byte // stack-allocated array for allocation-free unescaping of small strings if bU, err := Unescape(b, stackbuf[:]); err != nil { return "", MalformedValueError } else { return string(bU), nil } }
buger/jsonparser
bf1c66bbce23153d89b23f8960071a680dbef54b
parser.go
https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/parser.go#L1193-L1199
go
train
// ParseNumber parses a Number ValueType into a Go float64
func ParseFloat(b []byte) (float64, error)
// ParseNumber parses a Number ValueType into a Go float64 func ParseFloat(b []byte) (float64, error)
{ if v, err := parseFloat(&b); err != nil { return 0, MalformedValueError } else { return v, nil } }
buger/jsonparser
bf1c66bbce23153d89b23f8960071a680dbef54b
parser.go
https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/parser.go#L1202-L1211
go
train
// ParseInt parses a Number ValueType into a Go int64
func ParseInt(b []byte) (int64, error)
// ParseInt parses a Number ValueType into a Go int64 func ParseInt(b []byte) (int64, error)
{ if v, ok, overflow := parseInt(b); !ok { if overflow { return 0, OverflowIntegerError } return 0, MalformedValueError } else { return v, nil } }
buger/jsonparser
bf1c66bbce23153d89b23f8960071a680dbef54b
bytes_unsafe.go
https://github.com/buger/jsonparser/blob/bf1c66bbce23153d89b23f8960071a680dbef54b/bytes_unsafe.go#L20-L22
go
train
// // The reason for using *[]byte rather than []byte in parameters is an optimization. As of Go 1.6, // the compiler cannot perfectly inline the function when using a non-pointer slice. That is, // the non-pointer []byte parameter version is slower than if its function body is manually // inlined, whereas the pointer ...
func equalStr(b *[]byte, s string) bool
// // The reason for using *[]byte rather than []byte in parameters is an optimization. As of Go 1.6, // the compiler cannot perfectly inline the function when using a non-pointer slice. That is, // the non-pointer []byte parameter version is slower than if its function body is manually // inlined, whereas the pointer ...
{ return *(*string)(unsafe.Pointer(b)) == s }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L207-L209
go
train
// NewCustom returns a pointer to a new Fpdf instance. Its methods are // subsequently called to produce a single PDF document. NewCustom() is an // alternative to New() that provides additional customization. The PageSize() // example demonstrates this method.
func NewCustom(init *InitType) (f *Fpdf)
// NewCustom returns a pointer to a new Fpdf instance. Its methods are // subsequently called to produce a single PDF document. NewCustom() is an // alternative to New() that provides additional customization. The PageSize() // example demonstrates this method. func NewCustom(init *InitType) (f *Fpdf)
{ return fpdfNew(init.OrientationStr, init.UnitStr, init.SizeStr, init.FontDirStr, init.Size) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L231-L233
go
train
// New returns a pointer to a new Fpdf instance. Its methods are subsequently // called to produce a single PDF document. // // orientationStr specifies the default page orientation. For portrait mode, // specify "P" or "Portrait". For landscape mode, specify "L" or "Landscape". // An empty string will be replaced with...
func New(orientationStr, unitStr, sizeStr, fontDirStr string) (f *Fpdf)
// New returns a pointer to a new Fpdf instance. Its methods are subsequently // called to produce a single PDF document. // // orientationStr specifies the default page orientation. For portrait mode, // specify "P" or "Portrait". For landscape mode, specify "L" or "Landscape". // An empty string will be replaced with...
{ return fpdfNew(orientationStr, unitStr, sizeStr, fontDirStr, SizeType{0, 0}) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L259-L263
go
train
// SetErrorf sets the internal Fpdf error with formatted text to halt PDF // generation; this may facilitate error handling by application. If an error // condition is already set, this call is ignored. // // See the documentation for printing in the standard fmt package for details // about fmtStr and args.
func (f *Fpdf) SetErrorf(fmtStr string, args ...interface{})
// SetErrorf sets the internal Fpdf error with formatted text to halt PDF // generation; this may facilitate error handling by application. If an error // condition is already set, this call is ignored. // // See the documentation for printing in the standard fmt package for details // about fmtStr and args. func (f *F...
{ if f.err == nil { f.err = fmt.Errorf(fmtStr, args...) } }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L273-L277
go
train
// SetError sets an error to halt PDF generation. This may facilitate error // handling by application. See also Ok(), Err() and Error().
func (f *Fpdf) SetError(err error)
// SetError sets an error to halt PDF generation. This may facilitate error // handling by application. See also Ok(), Err() and Error(). func (f *Fpdf) SetError(err error)
{ if f.err == nil && err != nil { f.err = err } }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L287-L291
go
train
// GetPageSize returns the current page's width and height. This is the paper's // size. To compute the size of the area being used, subtract the margins (see // GetMargins()).
func (f *Fpdf) GetPageSize() (width, height float64)
// GetPageSize returns the current page's width and height. This is the paper's // size. To compute the size of the area being used, subtract the margins (see // GetMargins()). func (f *Fpdf) GetPageSize() (width, height float64)
{ width = f.w height = f.h return }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L296-L302
go
train
// GetMargins returns the left, top, right, and bottom margins. The first three // are set with the SetMargins() method. The bottom margin is set with the // SetAutoPageBreak() method.
func (f *Fpdf) GetMargins() (left, top, right, bottom float64)
// GetMargins returns the left, top, right, and bottom margins. The first three // are set with the SetMargins() method. The bottom margin is set with the // SetAutoPageBreak() method. func (f *Fpdf) GetMargins() (left, top, right, bottom float64)
{ left = f.lMargin top = f.tMargin right = f.rMargin bottom = f.bMargin return }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L307-L314
go
train
// SetMargins defines the left, top and right margins. By default, they equal 1 // cm. Call this method to change them. If the value of the right margin is // less than zero, it is set to the same as the left margin.
func (f *Fpdf) SetMargins(left, top, right float64)
// SetMargins defines the left, top and right margins. By default, they equal 1 // cm. Call this method to change them. If the value of the right margin is // less than zero, it is set to the same as the left margin. func (f *Fpdf) SetMargins(left, top, right float64)
{ f.lMargin = left f.tMargin = top if right < 0 { right = left } f.rMargin = right }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L319-L324
go
train
// SetLeftMargin defines the left margin. The method can be called before // creating the first page. If the current abscissa gets out of page, it is // brought back to the margin.
func (f *Fpdf) SetLeftMargin(margin float64)
// SetLeftMargin defines the left margin. The method can be called before // creating the first page. If the current abscissa gets out of page, it is // brought back to the margin. func (f *Fpdf) SetLeftMargin(margin float64)
{ f.lMargin = margin if f.page > 0 && f.x < margin { f.x = margin } }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L344-L378
go
train
// SetPageBoxRec sets the page box for the current page, and any following // pages. Allowable types are trim, trimbox, crop, cropbox, bleed, bleedbox, // art and artbox box types are case insensitive. See SetPageBox() for a method // that specifies the coordinates and extent of the page box individually.
func (f *Fpdf) SetPageBoxRec(t string, pb PageBox)
// SetPageBoxRec sets the page box for the current page, and any following // pages. Allowable types are trim, trimbox, crop, cropbox, bleed, bleedbox, // art and artbox box types are case insensitive. See SetPageBox() for a method // that specifies the coordinates and extent of the page box individually. func (f *Fpdf...
{ switch strings.ToLower(t) { case "trim": fallthrough case "trimbox": t = "TrimBox" case "crop": fallthrough case "cropbox": t = "CropBox" case "bleed": fallthrough case "bleedbox": t = "BleedBox" case "art": fallthrough case "artbox": t = "ArtBox" default: f.err = fmt.Errorf("%s is not a ...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L383-L385
go
train
// SetPageBox sets the page box for the current page, and any following pages. // Allowable types are trim, trimbox, crop, cropbox, bleed, bleedbox, art and // artbox box types are case insensitive.
func (f *Fpdf) SetPageBox(t string, x, y, wd, ht float64)
// SetPageBox sets the page box for the current page, and any following pages. // Allowable types are trim, trimbox, crop, cropbox, bleed, bleedbox, art and // artbox box types are case insensitive. func (f *Fpdf) SetPageBox(t string, x, y, wd, ht float64)
{ f.SetPageBoxRec(t, PageBox{SizeType{Wd: wd, Ht: ht}, PointType{X: x, Y: y}}) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L389-L393
go
train
// SetPage sets the current page to that of a valid page in the PDF document. // pageNum is one-based. The SetPage() example demonstrates this method.
func (f *Fpdf) SetPage(pageNum int)
// SetPage sets the current page to that of a valid page in the PDF document. // pageNum is one-based. The SetPage() example demonstrates this method. func (f *Fpdf) SetPage(pageNum int)
{ if (pageNum > 0) && (pageNum < len(f.pages)) { f.page = pageNum } }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L421-L424
go
train
// SetHeaderFuncMode sets the function that lets the application render the // page header. See SetHeaderFunc() for more details. The value for homeMode // should be set to true to have the current position set to the left and top // margin after the header function is called.
func (f *Fpdf) SetHeaderFuncMode(fnc func(), homeMode bool)
// SetHeaderFuncMode sets the function that lets the application render the // page header. See SetHeaderFunc() for more details. The value for homeMode // should be set to true to have the current position set to the left and top // margin after the header function is called. func (f *Fpdf) SetHeaderFuncMode(fnc func(...
{ f.headerFnc = fnc f.headerHomeMode = homeMode }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L452-L455
go
train
// SetFooterFunc sets the function that lets the application render the page // footer. The specified function is automatically called by AddPage() and // Close() and should not be called directly by the application. The // implementation in Fpdf is empty, so you have to provide an appropriate // function if you want p...
func (f *Fpdf) SetFooterFunc(fnc func())
// SetFooterFunc sets the function that lets the application render the page // footer. The specified function is automatically called by AddPage() and // Close() and should not be called directly by the application. The // implementation in Fpdf is empty, so you have to provide an appropriate // function if you want p...
{ f.footerFnc = fnc f.footerFncLpi = nil }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L464-L467
go
train
// SetFooterFuncLpi sets the function that lets the application render the page // footer. The specified function is automatically called by AddPage() and // Close() and should not be called directly by the application. It is passed a // boolean that is true if the last page of the document is being rendered. The // im...
func (f *Fpdf) SetFooterFuncLpi(fnc func(lastPage bool))
// SetFooterFuncLpi sets the function that lets the application render the page // footer. The specified function is automatically called by AddPage() and // Close() and should not be called directly by the application. It is passed a // boolean that is true if the last page of the document is being rendered. The // im...
{ f.footerFncLpi = fnc f.footerFnc = nil }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L484-L488
go
train
// GetAutoPageBreak returns true if automatic pages breaks are enabled, false // otherwise. This is followed by the triggering limit from the bottom of the // page. This value applies only if automatic page breaks are enabled.
func (f *Fpdf) GetAutoPageBreak() (auto bool, margin float64)
// GetAutoPageBreak returns true if automatic pages breaks are enabled, false // otherwise. This is followed by the triggering limit from the bottom of the // page. This value applies only if automatic page breaks are enabled. func (f *Fpdf) GetAutoPageBreak() (auto bool, margin float64)
{ auto = f.autoPageBreak margin = f.bMargin return }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L494-L498
go
train
// SetAutoPageBreak enables or disables the automatic page breaking mode. When // enabling, the second parameter is the distance from the bottom of the page // that defines the triggering limit. By default, the mode is on and the margin // is 2 cm.
func (f *Fpdf) SetAutoPageBreak(auto bool, margin float64)
// SetAutoPageBreak enables or disables the automatic page breaking mode. When // enabling, the second parameter is the distance from the bottom of the page // that defines the triggering limit. By default, the mode is on and the margin // is 2 cm. func (f *Fpdf) SetAutoPageBreak(auto bool, margin float64)
{ f.autoPageBreak = auto f.bMargin = margin f.pageBreakTrigger = f.h - margin }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L519-L541
go
train
// SetDisplayMode sets advisory display directives for the document viewer. // Pages can be displayed entirely on screen, occupy the full width of the // window, use real size, be scaled by a specific zooming factor or use viewer // default (configured in the Preferences menu of Adobe Reader). The page // layout can be...
func (f *Fpdf) SetDisplayMode(zoomStr, layoutStr string)
// SetDisplayMode sets advisory display directives for the document viewer. // Pages can be displayed entirely on screen, occupy the full width of the // window, use real size, be scaled by a specific zooming factor or use viewer // default (configured in the Preferences menu of Adobe Reader). The page // layout can be...
{ if f.err != nil { return } if layoutStr == "" { layoutStr = "default" } switch zoomStr { case "fullpage", "fullwidth", "real", "default": f.zoomMode = zoomStr default: f.err = fmt.Errorf("incorrect zoom display mode: %s", zoomStr) return } switch layoutStr { case "single", "continuous", "two", "d...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L560-L565
go
train
// SetTitle defines the title of the document. isUTF8 indicates if the string // is encoded in ISO-8859-1 (false) or UTF-8 (true).
func (f *Fpdf) SetTitle(titleStr string, isUTF8 bool)
// SetTitle defines the title of the document. isUTF8 indicates if the string // is encoded in ISO-8859-1 (false) or UTF-8 (true). func (f *Fpdf) SetTitle(titleStr string, isUTF8 bool)
{ if isUTF8 { titleStr = utf8toutf16(titleStr) } f.title = titleStr }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L569-L574
go
train
// SetSubject defines the subject of the document. isUTF8 indicates if the // string is encoded in ISO-8859-1 (false) or UTF-8 (true).
func (f *Fpdf) SetSubject(subjectStr string, isUTF8 bool)
// SetSubject defines the subject of the document. isUTF8 indicates if the // string is encoded in ISO-8859-1 (false) or UTF-8 (true). func (f *Fpdf) SetSubject(subjectStr string, isUTF8 bool)
{ if isUTF8 { subjectStr = utf8toutf16(subjectStr) } f.subject = subjectStr }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L578-L583
go
train
// SetAuthor defines the author of the document. isUTF8 indicates if the string // is encoded in ISO-8859-1 (false) or UTF-8 (true).
func (f *Fpdf) SetAuthor(authorStr string, isUTF8 bool)
// SetAuthor defines the author of the document. isUTF8 indicates if the string // is encoded in ISO-8859-1 (false) or UTF-8 (true). func (f *Fpdf) SetAuthor(authorStr string, isUTF8 bool)
{ if isUTF8 { authorStr = utf8toutf16(authorStr) } f.author = authorStr }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L588-L593
go
train
// SetKeywords defines the keywords of the document. keywordStr is a // space-delimited string, for example "invoice August". isUTF8 indicates if // the string is encoded
func (f *Fpdf) SetKeywords(keywordsStr string, isUTF8 bool)
// SetKeywords defines the keywords of the document. keywordStr is a // space-delimited string, for example "invoice August". isUTF8 indicates if // the string is encoded func (f *Fpdf) SetKeywords(keywordsStr string, isUTF8 bool)
{ if isUTF8 { keywordsStr = utf8toutf16(keywordsStr) } f.keywords = keywordsStr }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L597-L602
go
train
// SetCreator defines the creator of the document. isUTF8 indicates if the // string is encoded in ISO-8859-1 (false) or UTF-8 (true).
func (f *Fpdf) SetCreator(creatorStr string, isUTF8 bool)
// SetCreator defines the creator of the document. isUTF8 indicates if the // string is encoded in ISO-8859-1 (false) or UTF-8 (true). func (f *Fpdf) SetCreator(creatorStr string, isUTF8 bool)
{ if isUTF8 { creatorStr = utf8toutf16(creatorStr) } f.creator = creatorStr }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L614-L619
go
train
// AliasNbPages defines an alias for the total number of pages. It will be // substituted as the document is closed. An empty string is replaced with the // string "{nb}". // // See the example for AddPage() for a demonstration of this method.
func (f *Fpdf) AliasNbPages(aliasStr string)
// AliasNbPages defines an alias for the total number of pages. It will be // substituted as the document is closed. An empty string is replaced with the // string "{nb}". // // See the example for AddPage() for a demonstration of this method. func (f *Fpdf) AliasNbPages(aliasStr string)
{ if aliasStr == "" { aliasStr = "{nb}" } f.aliasNbPagesStr = aliasStr }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L630-L664
go
train
// Close terminates the PDF document. It is not necessary to call this method // explicitly because Output(), OutputAndClose() and OutputFileAndClose() do it // automatically. If the document contains no page, AddPage() is called to // prevent the generation of an invalid document.
func (f *Fpdf) Close()
// Close terminates the PDF document. It is not necessary to call this method // explicitly because Output(), OutputAndClose() and OutputFileAndClose() do it // automatically. If the document contains no page, AddPage() is called to // prevent the generation of an invalid document. func (f *Fpdf) Close()
{ if f.err == nil { if f.clipNest > 0 { f.err = fmt.Errorf("clip procedure must be explicitly ended") } else if f.transformNest > 0 { f.err = fmt.Errorf("transformation procedure must be explicitly ended") } } if f.err != nil { return } if f.state == 3 { return } if f.page == 0 { f.AddPage() ...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L671-L679
go
train
// PageSize returns the width and height of the specified page in the units // established in New(). These return values are followed by the unit of // measure itself. If pageNum is zero or otherwise out of bounds, it returns // the default page size, that is, the size of the page that would be added by // AddPage().
func (f *Fpdf) PageSize(pageNum int) (wd, ht float64, unitStr string)
// PageSize returns the width and height of the specified page in the units // established in New(). These return values are followed by the unit of // measure itself. If pageNum is zero or otherwise out of bounds, it returns // the default page size, that is, the size of the page that would be added by // AddPage(). f...
{ sz, ok := f.pageSizes[pageNum] if ok { sz.Wd, sz.Ht = sz.Wd/f.k, sz.Ht/f.k } else { sz = f.defPageSize // user units } return sz.Wd, sz.Ht, f.unitStr }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L689-L789
go
train
// AddPageFormat adds a new page with non-default orientation or size. See // AddPage() for more details. // // See New() for a description of orientationStr. // // size specifies the size of the new page in the units established in New(). // // The PageSize() example demonstrates this method.
func (f *Fpdf) AddPageFormat(orientationStr string, size SizeType)
// AddPageFormat adds a new page with non-default orientation or size. See // AddPage() for more details. // // See New() for a description of orientationStr. // // size specifies the size of the new page in the units established in New(). // // The PageSize() example demonstrates this method. func (f *Fpdf) AddPageFor...
{ if f.err != nil { return } if f.page != len(f.pages)-1 { f.page = len(f.pages) - 1 } if f.state == 0 { f.open() } familyStr := f.fontFamily style := f.fontStyle if f.underline { style += "U" } fontsize := f.fontSizePt lw := f.lineWidth dc := f.color.draw fc := f.color.fill tc := f.color.text ...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L805-L812
go
train
// AddPage adds a new page to the document. If a page is already present, the // Footer() method is called first to output the footer. Then the page is // added, the current position set to the top-left corner according to the left // and top margins, and Header() is called to display the header. // // The font which w...
func (f *Fpdf) AddPage()
// AddPage adds a new page to the document. If a page is already present, the // Footer() method is called first to output the footer. Then the page is // added, the current position set to the top-left corner according to the left // and top margins, and Header() is called to display the header. // // The font which w...
{ if f.err != nil { return } // dbg("AddPage") f.AddPageFormat(f.defOrientation, f.defPageSize) return }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L852-L854
go
train
// SetDrawColor defines the color used for all drawing operations (lines, // rectangles and cell borders). It is expressed in RGB components (0 - 255). // The method can be called before the first page is created. The value is // retained from page to page.
func (f *Fpdf) SetDrawColor(r, g, b int)
// SetDrawColor defines the color used for all drawing operations (lines, // rectangles and cell borders). It is expressed in RGB components (0 - 255). // The method can be called before the first page is created. The value is // retained from page to page. func (f *Fpdf) SetDrawColor(r, g, b int)
{ f.setDrawColor(r, g, b) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L866-L868
go
train
// GetDrawColor returns the most recently set draw color as RGB components (0 - // 255). This will not be the current value if a draw color of some other type // (for example, spot) has been more recently set.
func (f *Fpdf) GetDrawColor() (int, int, int)
// GetDrawColor returns the most recently set draw color as RGB components (0 - // 255). This will not be the current value if a draw color of some other type // (for example, spot) has been more recently set. func (f *Fpdf) GetDrawColor() (int, int, int)
{ return f.color.draw.ir, f.color.draw.ig, f.color.draw.ib }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L874-L876
go
train
// SetFillColor defines the color used for all filling operations (filled // rectangles and cell backgrounds). It is expressed in RGB components (0 // -255). The method can be called before the first page is created and the // value is retained from page to page.
func (f *Fpdf) SetFillColor(r, g, b int)
// SetFillColor defines the color used for all filling operations (filled // rectangles and cell backgrounds). It is expressed in RGB components (0 // -255). The method can be called before the first page is created and the // value is retained from page to page. func (f *Fpdf) SetFillColor(r, g, b int)
{ f.setFillColor(r, g, b) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L889-L891
go
train
// GetFillColor returns the most recently set fill color as RGB components (0 - // 255). This will not be the current value if a fill color of some other type // (for example, spot) has been more recently set.
func (f *Fpdf) GetFillColor() (int, int, int)
// GetFillColor returns the most recently set fill color as RGB components (0 - // 255). This will not be the current value if a fill color of some other type // (for example, spot) has been more recently set. func (f *Fpdf) GetFillColor() (int, int, int)
{ return f.color.fill.ir, f.color.fill.ig, f.color.fill.ib }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L896-L898
go
train
// SetTextColor defines the color used for text. It is expressed in RGB // components (0 - 255). The method can be called before the first page is // created. The value is retained from page to page.
func (f *Fpdf) SetTextColor(r, g, b int)
// SetTextColor defines the color used for text. It is expressed in RGB // components (0 - 255). The method can be called before the first page is // created. The value is retained from page to page. func (f *Fpdf) SetTextColor(r, g, b int)
{ f.setTextColor(r, g, b) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L908-L910
go
train
// GetTextColor returns the most recently set text color as RGB components (0 - // 255). This will not be the current value if a text color of some other type // (for example, spot) has been more recently set.
func (f *Fpdf) GetTextColor() (int, int, int)
// GetTextColor returns the most recently set text color as RGB components (0 - // 255). This will not be the current value if a text color of some other type // (for example, spot) has been more recently set. func (f *Fpdf) GetTextColor() (int, int, int)
{ return f.color.text.ir, f.color.text.ig, f.color.text.ib }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L914-L926
go
train
// GetStringWidth returns the length of a string in user units. A font must be // currently selected.
func (f *Fpdf) GetStringWidth(s string) float64
// GetStringWidth returns the length of a string in user units. A font must be // currently selected. func (f *Fpdf) GetStringWidth(s string) float64
{ if f.err != nil { return 0 } w := 0 for _, ch := range []byte(s) { if ch == 0 { break } w += f.currentFont.Cw[ch] } return float64(w) * f.fontSize / 1000 }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L951-L965
go
train
// SetLineCapStyle defines the line cap style. styleStr should be "butt", // "round" or "square". A square style projects from the end of the line. The // method can be called before the first page is created. The value is // retained from page to page.
func (f *Fpdf) SetLineCapStyle(styleStr string)
// SetLineCapStyle defines the line cap style. styleStr should be "butt", // "round" or "square". A square style projects from the end of the line. The // method can be called before the first page is created. The value is // retained from page to page. func (f *Fpdf) SetLineCapStyle(styleStr string)
{ var capStyle int switch styleStr { case "round": capStyle = 1 case "square": capStyle = 2 default: capStyle = 0 } f.capStyle = capStyle if f.page > 0 { f.outf("%d J", f.capStyle) } }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L970-L984
go
train
// SetLineJoinStyle defines the line cap style. styleStr should be "miter", // "round" or "bevel". The method can be called before the first page // is created. The value is retained from page to page.
func (f *Fpdf) SetLineJoinStyle(styleStr string)
// SetLineJoinStyle defines the line cap style. styleStr should be "miter", // "round" or "bevel". The method can be called before the first page // is created. The value is retained from page to page. func (f *Fpdf) SetLineJoinStyle(styleStr string)
{ var joinStyle int switch styleStr { case "round": joinStyle = 1 case "bevel": joinStyle = 2 default: joinStyle = 0 } f.joinStyle = joinStyle if f.page > 0 { f.outf("%d j", f.joinStyle) } }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L994-L1007
go
train
// SetDashPattern sets the dash pattern that is used to draw lines. The // dashArray elements are numbers that specify the lengths, in units // established in New(), of alternating dashes and gaps. The dash phase // specifies the distance into the dash pattern at which to start the dash. The // dash pattern is retained...
func (f *Fpdf) SetDashPattern(dashArray []float64, dashPhase float64)
// SetDashPattern sets the dash pattern that is used to draw lines. The // dashArray elements are numbers that specify the lengths, in units // established in New(), of alternating dashes and gaps. The dash phase // specifies the distance into the dash pattern at which to start the dash. The // dash pattern is retained...
{ scaled := make([]float64, len(dashArray)) for i, value := range dashArray { scaled[i] = value * f.k } dashPhase *= f.k f.dashArray = scaled f.dashPhase = dashPhase if f.page > 0 { f.outputDashPattern() } }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1026-L1028
go
train
// Line draws a line between points (x1, y1) and (x2, y2) using the current // draw color, line width and cap style.
func (f *Fpdf) Line(x1, y1, x2, y2 float64)
// Line draws a line between points (x1, y1) and (x2, y2) using the current // draw color, line width and cap style. func (f *Fpdf) Line(x1, y1, x2, y2 float64)
{ f.outf("%.2f %.2f m %.2f %.2f l S", x1*f.k, (f.h-y1)*f.k, x2*f.k, (f.h-y2)*f.k) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1031-L1052
go
train
// fillDrawOp corrects path painting operators
func fillDrawOp(styleStr string) (opStr string)
// fillDrawOp corrects path painting operators func fillDrawOp(styleStr string) (opStr string)
{ switch strings.ToUpper(styleStr) { case "", "D": // Stroke the path. opStr = "S" case "F": // fill the path, using the nonzero winding number rule opStr = "f" case "F*": // fill the path, using the even-odd rule opStr = "f*" case "FD", "DF": // fill and then stroke the path, using the nonzero wind...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1062-L1064
go
train
// Rect outputs a rectangle of width w and height h with the upper left corner // positioned at point (x, y). // // It can be drawn (border only), filled (with no border) or both. styleStr can // be "F" for filled, "D" for outlined only, or "DF" or "FD" for outlined and // filled. An empty string will be replaced with ...
func (f *Fpdf) Rect(x, y, w, h float64, styleStr string)
// Rect outputs a rectangle of width w and height h with the upper left corner // positioned at point (x, y). // // It can be drawn (border only), filled (with no border) or both. styleStr can // be "F" for filled, "D" for outlined only, or "DF" or "FD" for outlined and // filled. An empty string will be replaced with ...
{ f.outf("%.2f %.2f %.2f %.2f re %s", x*f.k, (f.h-y)*f.k, w*f.k, -h*f.k, fillDrawOp(styleStr)) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1072-L1074
go
train
// Circle draws a circle centered on point (x, y) with radius r. // // styleStr can be "F" for filled, "D" for outlined only, or "DF" or "FD" for // outlined and filled. An empty string will be replaced with "D". Drawing uses // the current draw color and line width centered on the circle's perimeter. // Filling uses t...
func (f *Fpdf) Circle(x, y, r float64, styleStr string)
// Circle draws a circle centered on point (x, y) with radius r. // // styleStr can be "F" for filled, "D" for outlined only, or "DF" or "FD" for // outlined and filled. An empty string will be replaced with "D". Drawing uses // the current draw color and line width centered on the circle's perimeter. // Filling uses t...
{ f.Ellipse(x, y, r, r, 0, styleStr) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1088-L1090
go
train
// Ellipse draws an ellipse centered at point (x, y). rx and ry specify its // horizontal and vertical radii. // // degRotate specifies the counter-clockwise angle in degrees that the ellipse // will be rotated. // // styleStr can be "F" for filled, "D" for outlined only, or "DF" or "FD" for // outlined and filled. An ...
func (f *Fpdf) Ellipse(x, y, rx, ry, degRotate float64, styleStr string)
// Ellipse draws an ellipse centered at point (x, y). rx and ry specify its // horizontal and vertical radii. // // degRotate specifies the counter-clockwise angle in degrees that the ellipse // will be rotated. // // styleStr can be "F" for filled, "D" for outlined only, or "DF" or "FD" for // outlined and filled. An ...
{ f.arc(x, y, rx, ry, degRotate, 0, 360, styleStr, false) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1101-L1113
go
train
// Polygon draws a closed figure defined by a series of vertices specified by // points. The x and y fields of the points use the units established in New(). // The last point in the slice will be implicitly joined to the first to close // the polygon. // // styleStr can be "F" for filled, "D" for outlined only, or "DF...
func (f *Fpdf) Polygon(points []PointType, styleStr string)
// Polygon draws a closed figure defined by a series of vertices specified by // points. The x and y fields of the points use the units established in New(). // The last point in the slice will be implicitly joined to the first to close // the polygon. // // styleStr can be "F" for filled, "D" for outlined only, or "DF...
{ if len(points) > 2 { for j, pt := range points { if j == 0 { f.point(pt.X, pt.Y) } else { f.outf("%.5f %.5f l ", pt.X*f.k, (f.h-pt.Y)*f.k) } } f.outf("%.5f %.5f l ", points[0].X*f.k, (f.h-points[0].Y)*f.k) f.DrawPath(styleStr) } }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1126-L1145
go
train
// Beziergon draws a closed figure defined by a series of cubic Bézier curve // segments. The first point in the slice defines the starting point of the // figure. Each three following points p1, p2, p3 represent a curve segment to // the point p3 using p1 and p2 as the Bézier control points. // // The x and y fields o...
func (f *Fpdf) Beziergon(points []PointType, styleStr string)
// Beziergon draws a closed figure defined by a series of cubic Bézier curve // segments. The first point in the slice defines the starting point of the // figure. Each three following points p1, p2, p3 represent a curve segment to // the point p3 using p1 and p2 as the Bézier control points. // // The x and y fields o...
{ // Thanks, Robert Lillack, for contributing this function. if len(points) < 4 { return } f.point(points[0].XY()) points = points[1:] for len(points) >= 3 { cx0, cy0 := points[0].XY() cx1, cy1 := points[1].XY() x1, y1 := points[2].XY() f.curve(cx0, cy0, cx1, cy1, x1, y1) points = points[3:] } ...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1148-L1150
go
train
// point outputs current point
func (f *Fpdf) point(x, y float64)
// point outputs current point func (f *Fpdf) point(x, y float64)
{ f.outf("%.2f %.2f m", x*f.k, (f.h-y)*f.k) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1153-L1157
go
train
// curve outputs a single cubic Bézier curve segment from current point
func (f *Fpdf) curve(cx0, cy0, cx1, cy1, x, y float64)
// curve outputs a single cubic Bézier curve segment from current point func (f *Fpdf) curve(cx0, cy0, cx1, cy1, x, y float64)
{ // Thanks, Robert Lillack, for straightening this out f.outf("%.5f %.5f %.5f %.5f %.5f %.5f c", cx0*f.k, (f.h-cy0)*f.k, cx1*f.k, (f.h-cy1)*f.k, x*f.k, (f.h-y)*f.k) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1172-L1176
go
train
// Curve draws a single-segment quadratic Bézier curve. The curve starts at // the point (x0, y0) and ends at the point (x1, y1). The control point (cx, // cy) specifies the curvature. At the start point, the curve is tangent to the // straight line between the start point and the control point. At the end // point, th...
func (f *Fpdf) Curve(x0, y0, cx, cy, x1, y1 float64, styleStr string)
// Curve draws a single-segment quadratic Bézier curve. The curve starts at // the point (x0, y0) and ends at the point (x1, y1). The control point (cx, // cy) specifies the curvature. At the start point, the curve is tangent to the // straight line between the start point and the control point. At the end // point, th...
{ f.point(x0, y0) f.outf("%.5f %.5f %.5f %.5f v %s", cx*f.k, (f.h-cy)*f.k, x1*f.k, (f.h-y1)*f.k, fillDrawOp(styleStr)) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1181-L1186
go
train
// CurveCubic draws a single-segment cubic Bézier curve. This routine performs // the same function as CurveBezierCubic() but has a nonstandard argument order. // It is retained to preserve backward compatibility.
func (f *Fpdf) CurveCubic(x0, y0, cx0, cy0, x1, y1, cx1, cy1 float64, styleStr string)
// CurveCubic draws a single-segment cubic Bézier curve. This routine performs // the same function as CurveBezierCubic() but has a nonstandard argument order. // It is retained to preserve backward compatibility. func (f *Fpdf) CurveCubic(x0, y0, cx0, cy0, x1, y1, cx1, cy1 float64, styleStr string)
{ // f.point(x0, y0) // f.outf("%.5f %.5f %.5f %.5f %.5f %.5f c %s", cx0*f.k, (f.h-cy0)*f.k, // cx1*f.k, (f.h-cy1)*f.k, x1*f.k, (f.h-y1)*f.k, fillDrawOp(styleStr)) f.CurveBezierCubic(x0, y0, cx0, cy0, cx1, cy1, x1, y1, styleStr) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1204-L1208
go
train
// CurveBezierCubic draws a single-segment cubic Bézier curve. The curve starts at // the point (x0, y0) and ends at the point (x1, y1). The control points (cx0, // cy0) and (cx1, cy1) specify the curvature. At the start point, the curve is // tangent to the straight line between the start point and the control point /...
func (f *Fpdf) CurveBezierCubic(x0, y0, cx0, cy0, cx1, cy1, x1, y1 float64, styleStr string)
// CurveBezierCubic draws a single-segment cubic Bézier curve. The curve starts at // the point (x0, y0) and ends at the point (x1, y1). The control points (cx0, // cy0) and (cx1, cy1) specify the curvature. At the start point, the curve is // tangent to the straight line between the start point and the control point /...
{ f.point(x0, y0) f.outf("%.5f %.5f %.5f %.5f %.5f %.5f c %s", cx0*f.k, (f.h-cy0)*f.k, cx1*f.k, (f.h-cy1)*f.k, x1*f.k, (f.h-y1)*f.k, fillDrawOp(styleStr)) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1224-L1226
go
train
// Arc draws an elliptical arc centered at point (x, y). rx and ry specify its // horizontal and vertical radii. // // degRotate specifies the angle that the arc will be rotated. degStart and // degEnd specify the starting and ending angle of the arc. All angles are // specified in degrees and measured counter-clockwis...
func (f *Fpdf) Arc(x, y, rx, ry, degRotate, degStart, degEnd float64, styleStr string)
// Arc draws an elliptical arc centered at point (x, y). rx and ry specify its // horizontal and vertical radii. // // degRotate specifies the angle that the arc will be rotated. degStart and // degEnd specify the starting and ending angle of the arc. All angles are // specified in degrees and measured counter-clockwis...
{ f.arc(x, y, rx, ry, degRotate, degStart, degEnd, styleStr, false) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1231-L1233
go
train
// GetAlpha returns the alpha blending channel, which consists of the // alpha transparency value and the blend mode. See SetAlpha for more // details.
func (f *Fpdf) GetAlpha() (alpha float64, blendModeStr string)
// GetAlpha returns the alpha blending channel, which consists of the // alpha transparency value and the blend mode. See SetAlpha for more // details. func (f *Fpdf) GetAlpha() (alpha float64, blendModeStr string)
{ return f.alpha, f.blendMode }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1248-L1279
go
train
// SetAlpha sets the alpha blending channel. The blending effect applies to // text, drawings and images. // // alpha must be a value between 0.0 (fully transparent) to 1.0 (fully opaque). // Values outside of this range result in an error. // // blendModeStr must be one of "Normal", "Multiply", "Screen", "Overlay", //...
func (f *Fpdf) SetAlpha(alpha float64, blendModeStr string)
// SetAlpha sets the alpha blending channel. The blending effect applies to // text, drawings and images. // // alpha must be a value between 0.0 (fully transparent) to 1.0 (fully opaque). // Values outside of this range result in an error. // // blendModeStr must be one of "Normal", "Multiply", "Screen", "Overlay", //...
{ if f.err != nil { return } var bl blendModeType switch blendModeStr { case "Normal", "Multiply", "Screen", "Overlay", "Darken", "Lighten", "ColorDodge", "ColorBurn", "HardLight", "SoftLight", "Difference", "Exclusion", "Hue", "Saturation", "Color", "Luminosity": bl.modeStr = blendModeStr case "": bl....
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1342-L1346
go
train
// RadialGradient draws a rectangular area with a blending of one color to // another. The rectangle is of width w and height h. Its upper left corner is // positioned at point (x, y). // // Each color is specified with three component values, one each for red, green // and blue. The values range from 0 to 255. The fir...
func (f *Fpdf) RadialGradient(x, y, w, h float64, r1, g1, b1, r2, g2, b2 int, x1, y1, x2, y2, r float64)
// RadialGradient draws a rectangular area with a blending of one color to // another. The rectangle is of width w and height h. Its upper left corner is // positioned at point (x, y). // // Each color is specified with three component values, one each for red, green // and blue. The values range from 0 to 255. The fir...
{ f.gradientClipStart(x, y, w, h) f.gradient(3, r1, g1, b1, r2, g2, b2, x1, y1, x2, y2, r) f.gradientClipEnd() }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1357-L1360
go
train
// ClipRect begins a rectangular clipping operation. The rectangle is of width // w and height h. Its upper left corner is positioned at point (x, y). outline // is true to draw a border with the current draw color and line width centered // on the rectangle's perimeter. Only the outer half of the border will be // sho...
func (f *Fpdf) ClipRect(x, y, w, h float64, outline bool)
// ClipRect begins a rectangular clipping operation. The rectangle is of width // w and height h. Its upper left corner is positioned at point (x, y). outline // is true to draw a border with the current draw color and line width centered // on the rectangle's perimeter. Only the outer half of the border will be // sho...
{ f.clipNest++ f.outf("q %.2f %.2f %.2f %.2f re W %s", x*f.k, (f.h-y)*f.k, w*f.k, -h*f.k, strIf(outline, "S", "n")) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1370-L1373
go
train
// ClipText begins a clipping operation in which rendering is confined to the // character string specified by txtStr. The origin (x, y) is on the left of // the first character at the baseline. The current font is used. outline is // true to draw a border with the current draw color and line width centered on // the p...
func (f *Fpdf) ClipText(x, y float64, txtStr string, outline bool)
// ClipText begins a clipping operation in which rendering is confined to the // character string specified by txtStr. The origin (x, y) is on the left of // the first character at the baseline. The current font is used. outline is // true to draw a border with the current draw color and line width centered on // the p...
{ f.clipNest++ f.outf("q BT %.5f %.5f Td %d Tr (%s) Tj ET", x*f.k, (f.h-y)*f.k, intIf(outline, 5, 7), f.escape(txtStr)) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1391-L1414
go
train
// ClipRoundedRect begins a rectangular clipping operation. The rectangle is of // width w and height h. Its upper left corner is positioned at point (x, y). // The rounded corners of the rectangle are specified by radius r. outline is // true to draw a border with the current draw color and line width centered on // t...
func (f *Fpdf) ClipRoundedRect(x, y, w, h, r float64, outline bool)
// ClipRoundedRect begins a rectangular clipping operation. The rectangle is of // width w and height h. Its upper left corner is positioned at point (x, y). // The rounded corners of the rectangle are specified by radius r. outline is // true to draw a border with the current draw color and line width centered on // t...
{ f.clipNest++ k := f.k hp := f.h myArc := (4.0 / 3.0) * (math.Sqrt2 - 1.0) f.outf("q %.5f %.5f m", (x+r)*k, (hp-y)*k) xc := x + w - r yc := y + r f.outf("%.5f %.5f l", xc*k, (hp-y)*k) f.clipArc(xc+r*myArc, yc-r, xc+r, yc-r*myArc, xc+r, yc) xc = x + w - r yc = y + h - r f.outf("%.5f %.5f l", (x+w)*k, (hp-y...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1425-L1449
go
train
// ClipEllipse begins an elliptical clipping operation. The ellipse is centered // at (x, y). Its horizontal and vertical radii are specified by rx and ry. // outline is true to draw a border with the current draw color and line width // centered on the ellipse's perimeter. Only the outer half of the border will // be ...
func (f *Fpdf) ClipEllipse(x, y, rx, ry float64, outline bool)
// ClipEllipse begins an elliptical clipping operation. The ellipse is centered // at (x, y). Its horizontal and vertical radii are specified by rx and ry. // outline is true to draw a border with the current draw color and line width // centered on the ellipse's perimeter. Only the outer half of the border will // be ...
{ f.clipNest++ lx := (4.0 / 3.0) * rx * (math.Sqrt2 - 1) ly := (4.0 / 3.0) * ry * (math.Sqrt2 - 1) k := f.k h := f.h f.outf("q %.5f %.5f m %.5f %.5f %.5f %.5f %.5f %.5f c", (x+rx)*k, (h-y)*k, (x+rx)*k, (h-(y-ly))*k, (x+lx)*k, (h-(y-ry))*k, x*k, (h-(y-ry))*k) f.outf("%.5f %.5f %.5f %.5f %.5f %.5f c", (...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1459-L1461
go
train
// ClipCircle begins a circular clipping operation. The circle is centered at // (x, y) and has radius r. outline is true to draw a border with the current // draw color and line width centered on the circle's perimeter. Only the outer // half of the border will be shown. After calling this method, all rendering // ope...
func (f *Fpdf) ClipCircle(x, y, r float64, outline bool)
// ClipCircle begins a circular clipping operation. The circle is centered at // (x, y) and has radius r. outline is true to draw a border with the current // draw color and line width centered on the circle's perimeter. Only the outer // half of the border will be shown. After calling this method, all rendering // ope...
{ f.ClipEllipse(x, y, r, r, outline) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1474-L1485
go
train
// ClipPolygon begins a clipping operation within a polygon. The figure is // defined by a series of vertices specified by points. The x and y fields of // the points use the units established in New(). The last point in the slice // will be implicitly joined to the first to close the polygon. outline is true // to dra...
func (f *Fpdf) ClipPolygon(points []PointType, outline bool)
// ClipPolygon begins a clipping operation within a polygon. The figure is // defined by a series of vertices specified by points. The x and y fields of // the points use the units established in New(). The last point in the slice // will be implicitly joined to the first to close the polygon. outline is true // to dra...
{ f.clipNest++ var s fmtBuffer h := f.h k := f.k s.printf("q ") for j, pt := range points { s.printf("%.5f %.5f %s ", pt.X*k, (h-pt.Y)*k, strIf(j == 0, "m", "l")) } s.printf("h W %s", strIf(outline, "S", "n")) f.out(s.String()) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1493-L1502
go
train
// ClipEnd ends a clipping operation that was started with a call to // ClipRect(), ClipRoundedRect(), ClipText(), ClipEllipse(), ClipCircle() or // ClipPolygon(). Clipping operations can be nested. The document cannot be // successfully output while a clipping operation is active. // // The ClipText() example demonstr...
func (f *Fpdf) ClipEnd()
// ClipEnd ends a clipping operation that was started with a call to // ClipRect(), ClipRoundedRect(), ClipText(), ClipEllipse(), ClipCircle() or // ClipPolygon(). Clipping operations can be nested. The document cannot be // successfully output while a clipping operation is active. // // The ClipText() example demonstr...
{ if f.err == nil { if f.clipNest > 0 { f.clipNest-- f.out("Q") } else { f.err = fmt.Errorf("error attempting to end clip operation out of sequence") } } }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1524-L1549
go
train
// AddFont imports a TrueType, OpenType or Type1 font and makes it available. // It is necessary to generate a font definition file first with the makefont // utility. It is not necessary to call this function for the core PDF fonts // (courier, helvetica, times, zapfdingbats). // // The JSON definition file (and the f...
func (f *Fpdf) AddFont(familyStr, styleStr, fileStr string)
// AddFont imports a TrueType, OpenType or Type1 font and makes it available. // It is necessary to generate a font definition file first with the makefont // utility. It is not necessary to call this function for the core PDF fonts // (courier, helvetica, times, zapfdingbats). // // The JSON definition file (and the f...
{ if fileStr == "" { fileStr = strings.Replace(familyStr, " ", "", -1) + strings.ToLower(styleStr) + ".json" } if f.fontLoader != nil { reader, err := f.fontLoader.Open(fileStr) if err == nil { f.AddFontFromReader(familyStr, styleStr, reader) if closer, ok := reader.(io.Closer); ok { closer.Close()...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1566-L1635
go
train
// AddFontFromBytes imports a TrueType, OpenType or Type1 font from static // bytes within the executable and makes it available for use in the generated // document. // // family specifies the font family. The name can be chosen arbitrarily. If it // is a standard family name, it will override the corresponding font. ...
func (f *Fpdf) AddFontFromBytes(familyStr, styleStr string, jsonFileBytes, zFileBytes []byte)
// AddFontFromBytes imports a TrueType, OpenType or Type1 font from static // bytes within the executable and makes it available for use in the generated // document. // // family specifies the font family. The name can be chosen arbitrarily. If it // is a standard family name, it will override the corresponding font. ...
{ if f.err != nil { return } // load font key var ok bool fontkey := getFontKey(familyStr, styleStr) _, ok = f.fonts[fontkey] if ok { return } // load font definitions var info fontDefType err := json.Unmarshal(jsonFileBytes, &info) if err != nil { f.err = err } if f.err != nil { return } ...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1638-L1645
go
train
// getFontKey is used by AddFontFromReader and GetFontDesc
func getFontKey(familyStr, styleStr string) string
// getFontKey is used by AddFontFromReader and GetFontDesc func getFontKey(familyStr, styleStr string) string
{ familyStr = strings.ToLower(familyStr) styleStr = strings.ToUpper(styleStr) if styleStr == "IB" { styleStr = "BI" } return familyStr + styleStr }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1650-L1692
go
train
// AddFontFromReader imports a TrueType, OpenType or Type1 font and makes it // available using a reader that satisifies the io.Reader interface. See // AddFont for details about familyStr and styleStr.
func (f *Fpdf) AddFontFromReader(familyStr, styleStr string, r io.Reader)
// AddFontFromReader imports a TrueType, OpenType or Type1 font and makes it // available using a reader that satisifies the io.Reader interface. See // AddFont for details about familyStr and styleStr. func (f *Fpdf) AddFontFromReader(familyStr, styleStr string, r io.Reader)
{ if f.err != nil { return } // dbg("Adding family [%s], style [%s]", familyStr, styleStr) var ok bool fontkey := getFontKey(familyStr, styleStr) _, ok = f.fonts[fontkey] if ok { return } var info fontDefType info = f.loadfont(r) if f.err != nil { return } if len(info.Diff) > 0 { // Search existin...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1699-L1704
go
train
// GetFontDesc returns the font descriptor, which can be used for // example to find the baseline of a font. If familyStr is empty // current font descriptor will be returned. // See FontDescType for documentation about the font descriptor. // See AddFont for details about familyStr and styleStr.
func (f *Fpdf) GetFontDesc(familyStr, styleStr string) FontDescType
// GetFontDesc returns the font descriptor, which can be used for // example to find the baseline of a font. If familyStr is empty // current font descriptor will be returned. // See FontDescType for documentation about the font descriptor. // See AddFont for details about familyStr and styleStr. func (f *Fpdf) GetFont...
{ if familyStr == "" { return f.currentFont.Desc } return f.fonts[getFontKey(familyStr, styleStr)].Desc }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1733-L1800
go
train
// SetFont sets the font used to print character strings. It is mandatory to // call this method at least once before printing text or the resulting // document will not be valid. // // The font can be either a standard one or a font added via the AddFont() // method or AddFontFromReader() method. Standard fonts use th...
func (f *Fpdf) SetFont(familyStr, styleStr string, size float64)
// SetFont sets the font used to print character strings. It is mandatory to // call this method at least once before printing text or the resulting // document will not be valid. // // The font can be either a standard one or a font added via the AddFont() // method or AddFontFromReader() method. Standard fonts use th...
{ // dbg("SetFont x %.2f, lMargin %.2f", f.x, f.lMargin) if f.err != nil { return } // dbg("SetFont") var ok bool if familyStr == "" { familyStr = f.fontFamily } else { familyStr = strings.ToLower(familyStr) } styleStr = strings.ToUpper(styleStr) f.underline = strings.Contains(styleStr, "U") if f.und...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1803-L1805
go
train
// SetFontStyle sets the style of the current font. See also SetFont()
func (f *Fpdf) SetFontStyle(styleStr string)
// SetFontStyle sets the style of the current font. See also SetFont() func (f *Fpdf) SetFontStyle(styleStr string)
{ f.SetFont(f.fontFamily, styleStr, f.fontSizePt) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1809-L1815
go
train
// SetFontSize defines the size of the current font. Size is specified in // points (1/ 72 inch). See also SetFontUnitSize().
func (f *Fpdf) SetFontSize(size float64)
// SetFontSize defines the size of the current font. Size is specified in // points (1/ 72 inch). See also SetFontUnitSize(). func (f *Fpdf) SetFontSize(size float64)
{ f.fontSizePt = size f.fontSize = size / f.k if f.page > 0 { f.outf("BT /F%s %.2f Tf ET", f.currentFont.i, f.fontSizePt) } }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1830-L1832
go
train
// GetFontSize returns the size of the current font in points followed by the // size in the unit of measure specified in New(). The second value can be used // as a line height value in drawing operations.
func (f *Fpdf) GetFontSize() (ptSize, unitSize float64)
// GetFontSize returns the size of the current font in points followed by the // size in the unit of measure specified in New(). The second value can be used // as a line height value in drawing operations. func (f *Fpdf) GetFontSize() (ptSize, unitSize float64)
{ return f.fontSizePt, f.fontSize }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1838-L1841
go
train
// AddLink creates a new internal link and returns its identifier. An internal // link is a clickable area which directs to another place within the document. // The identifier can then be passed to Cell(), Write(), Image() or Link(). The // destination is defined with SetLink().
func (f *Fpdf) AddLink() int
// AddLink creates a new internal link and returns its identifier. An internal // link is a clickable area which directs to another place within the document. // The identifier can then be passed to Cell(), Write(), Image() or Link(). The // destination is defined with SetLink(). func (f *Fpdf) AddLink() int
{ f.links = append(f.links, intLinkType{}) return len(f.links) - 1 }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1844-L1852
go
train
// SetLink defines the page and position a link points to. See AddLink().
func (f *Fpdf) SetLink(link int, y float64, page int)
// SetLink defines the page and position a link points to. See AddLink(). func (f *Fpdf) SetLink(link int, y float64, page int)
{ if y == -1 { y = f.y } if page == -1 { page = f.page } f.links[link] = intLinkType{page, y} }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1855-L1863
go
train
// newLink adds a new clickable link on current page
func (f *Fpdf) newLink(x, y, w, h float64, link int, linkStr string)
// newLink adds a new clickable link on current page func (f *Fpdf) newLink(x, y, w, h float64, link int, linkStr string)
{ // linkList, ok := f.pageLinks[f.page] // if !ok { // linkList = make([]linkType, 0, 8) // f.pageLinks[f.page] = linkList // } f.pageLinks[f.page] = append(f.pageLinks[f.page], linkType{x * f.k, f.hPt - y*f.k, w * f.k, h * f.k, link, linkStr}) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1869-L1871
go
train
// Link puts a link on a rectangular area of the page. Text or image links are // generally put via Cell(), Write() or Image(), but this method can be useful // for instance to define a clickable area inside an image. link is the value // returned by AddLink().
func (f *Fpdf) Link(x, y, w, h float64, link int)
// Link puts a link on a rectangular area of the page. Text or image links are // generally put via Cell(), Write() or Image(), but this method can be useful // for instance to define a clickable area inside an image. link is the value // returned by AddLink(). func (f *Fpdf) Link(x, y, w, h float64, link int)
{ f.newLink(x, y, w, h, link, "") }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1877-L1879
go
train
// LinkString puts a link on a rectangular area of the page. Text or image // links are generally put via Cell(), Write() or Image(), but this method can // be useful for instance to define a clickable area inside an image. linkStr // is the target URL.
func (f *Fpdf) LinkString(x, y, w, h float64, linkStr string)
// LinkString puts a link on a rectangular area of the page. Text or image // links are generally put via Cell(), Write() or Image(), but this method can // be useful for instance to define a clickable area inside an image. linkStr // is the target URL. func (f *Fpdf) LinkString(x, y, w, h float64, linkStr string)
{ f.newLink(x, y, w, h, 0, linkStr) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1886-L1891
go
train
// Bookmark sets a bookmark that will be displayed in a sidebar outline. txtStr // is the title of the bookmark. level specifies the level of the bookmark in // the outline; 0 is the top level, 1 is just below, and so on. y specifies the // vertical position of the bookmark destination in the current page; -1 // indica...
func (f *Fpdf) Bookmark(txtStr string, level int, y float64)
// Bookmark sets a bookmark that will be displayed in a sidebar outline. txtStr // is the title of the bookmark. level specifies the level of the bookmark in // the outline; 0 is the top level, 1 is just below, and so on. y specifies the // vertical position of the bookmark destination in the current page; -1 // indica...
{ if y == -1 { y = f.y } f.outlines = append(f.outlines, outlineType{text: txtStr, level: level, y: y, p: f.PageNo(), prev: -1, last: -1, next: -1, first: -1}) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1897-L1906
go
train
// Text prints a character string. The origin (x, y) is on the left of the // first character at the baseline. This method permits a string to be placed // precisely on the page, but it is usually easier to use Cell(), MultiCell() // or Write() which are the standard methods to print text.
func (f *Fpdf) Text(x, y float64, txtStr string)
// Text prints a character string. The origin (x, y) is on the left of the // first character at the baseline. This method permits a string to be placed // precisely on the page, but it is usually easier to use Cell(), MultiCell() // or Write() which are the standard methods to print text. func (f *Fpdf) Text(x, y floa...
{ s := sprintf("BT %.2f %.2f Td (%s) Tj ET", x*f.k, (f.h-y)*f.k, f.escape(txtStr)) if f.underline && txtStr != "" { s += " " + f.dounderline(x, y, txtStr) } if f.colorFlag { s = sprintf("q %s %s Q", f.color.text.str, s) } f.out(s) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1910-L1912
go
train
// SetWordSpacing sets spacing between words of following text. See the // WriteAligned() example for a demonstration of its use.
func (f *Fpdf) SetWordSpacing(space float64)
// SetWordSpacing sets spacing between words of following text. See the // WriteAligned() example for a demonstration of its use. func (f *Fpdf) SetWordSpacing(space float64)
{ f.out(sprintf("%.5f Tw", space*f.k)) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L1968-L2110
go
train
// CellFormat prints a rectangular cell with optional borders, background color // and character string. The upper-left corner of the cell corresponds to the // current position. The text can be aligned or centered. After the call, the // current position moves to the right or to the next line. It is possible to // put...
func (f *Fpdf) CellFormat(w, h float64, txtStr, borderStr string, ln int, alignStr string, fill bool, link int, linkStr string)
// CellFormat prints a rectangular cell with optional borders, background color // and character string. The upper-left corner of the cell corresponds to the // current position. The text can be aligned or centered. After the call, the // current position moves to the right or to the next line. It is possible to // put...
{ // dbg("CellFormat. h = %.2f, borderStr = %s", h, borderStr) if f.err != nil { return } if f.currentFont.Name == "" { f.err = fmt.Errorf("font has not been set; unable to render text") return } borderStr = strings.ToUpper(borderStr) k := f.k if f.y+h > f.pageBreakTrigger && !f.inHeader && !f.inFooter...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2114-L2116
go
train
// Cell is a simpler version of CellFormat with no fill, border, links or // special alignment.
func (f *Fpdf) Cell(w, h float64, txtStr string)
// Cell is a simpler version of CellFormat with no fill, border, links or // special alignment. func (f *Fpdf) Cell(w, h float64, txtStr string)
{ f.CellFormat(w, h, txtStr, "", 0, "L", false, 0, "") }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2121-L2123
go
train
// Cellf is a simpler printf-style version of CellFormat with no fill, border, // links or special alignment. See documentation for the fmt package for // details on fmtStr and args.
func (f *Fpdf) Cellf(w, h float64, fmtStr string, args ...interface{})
// Cellf is a simpler printf-style version of CellFormat with no fill, border, // links or special alignment. See documentation for the fmt package for // details on fmtStr and args. func (f *Fpdf) Cellf(w, h float64, fmtStr string, args ...interface{})
{ f.CellFormat(w, h, sprintf(fmtStr, args...), "", 0, "L", false, 0, "") }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2132-L2174
go
train
// SplitLines splits text into several lines using the current font. Each line // has its length limited to a maximum width given by w. This function can be // used to determine the total height of wrapped text for vertical placement // purposes. // // You can use MultiCell if you want to print a text on several lines ...
func (f *Fpdf) SplitLines(txt []byte, w float64) [][]byte
// SplitLines splits text into several lines using the current font. Each line // has its length limited to a maximum width given by w. This function can be // used to determine the total height of wrapped text for vertical placement // purposes. // // You can use MultiCell if you want to print a text on several lines ...
{ // Function contributed by Bruno Michel lines := [][]byte{} cw := &f.currentFont.Cw wmax := int(math.Ceil((w - 2*f.cMargin) * 1000 / f.fontSize)) s := bytes.Replace(txt, []byte("\r"), []byte{}, -1) nb := len(s) for nb > 0 && s[nb-1] == '\n' { nb-- } s = s[0:nb] sep := -1 i := 0 j := 0 l := 0 for i < ...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2190-L2309
go
train
// MultiCell supports printing text with line breaks. They can be automatic (as // soon as the text reaches the right border of the cell) or explicit (via the // \n character). As many cells as necessary are output, one below the other. // // Text can be aligned, centered or justified. The cell block can be framed and ...
func (f *Fpdf) MultiCell(w, h float64, txtStr, borderStr, alignStr string, fill bool)
// MultiCell supports printing text with line breaks. They can be automatic (as // soon as the text reaches the right border of the cell) or explicit (via the // \n character). As many cells as necessary are output, one below the other. // // Text can be aligned, centered or justified. The cell block can be framed and ...
{ // dbg("MultiCell") if alignStr == "" { alignStr = "J" } cw := &f.currentFont.Cw if w == 0 { w = f.w - f.rMargin - f.x } wmax := int(math.Ceil((w - 2*f.cMargin) * 1000 / f.fontSize)) s := strings.Replace(txtStr, "\r", "", -1) nb := len(s) // if nb > 0 && s[nb-1:nb] == "\n" { if nb > 0 && []byte(s)[nb-...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2312-L2384
go
train
// write outputs text in flowing mode
func (f *Fpdf) write(h float64, txtStr string, link int, linkStr string)
// write outputs text in flowing mode func (f *Fpdf) write(h float64, txtStr string, link int, linkStr string)
{ // dbg("Write") cw := &f.currentFont.Cw w := f.w - f.rMargin - f.x wmax := (w - 2*f.cMargin) * 1000 / f.fontSize s := strings.Replace(txtStr, "\r", "", -1) nb := len(s) sep := -1 i := 0 j := 0 l := 0.0 nl := 1 for i < nb { // Get next character c := []byte(s)[i] if c == '\n' { // Explicit line b...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2394-L2396
go
train
// Write prints text from the current position. When the right margin is // reached (or the \n character is met) a line break occurs and text continues // from the left margin. Upon method exit, the current position is left just at // the end of the text. // // It is possible to put a link on the text. // // h indicate...
func (f *Fpdf) Write(h float64, txtStr string)
// Write prints text from the current position. When the right margin is // reached (or the \n character is met) a line break occurs and text continues // from the left margin. Upon method exit, the current position is left just at // the end of the text. // // It is possible to put a link on the text. // // h indicate...
{ f.write(h, txtStr, 0, "") }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2400-L2402
go
train
// Writef is like Write but uses printf-style formatting. See the documentation // for package fmt for more details on fmtStr and args.
func (f *Fpdf) Writef(h float64, fmtStr string, args ...interface{})
// Writef is like Write but uses printf-style formatting. See the documentation // for package fmt for more details on fmtStr and args. func (f *Fpdf) Writef(h float64, fmtStr string, args ...interface{})
{ f.write(h, sprintf(fmtStr, args...), 0, "") }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2406-L2408
go
train
// WriteLinkString writes text that when clicked launches an external URL. See // Write() for argument details.
func (f *Fpdf) WriteLinkString(h float64, displayStr, targetStr string)
// WriteLinkString writes text that when clicked launches an external URL. See // Write() for argument details. func (f *Fpdf) WriteLinkString(h float64, displayStr, targetStr string)
{ f.write(h, displayStr, 0, targetStr) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2413-L2415
go
train
// WriteLinkID writes text that when clicked jumps to another location in the // PDF. linkID is an identifier returned by AddLink(). See Write() for argument // details.
func (f *Fpdf) WriteLinkID(h float64, displayStr string, linkID int)
// WriteLinkID writes text that when clicked jumps to another location in the // PDF. linkID is an identifier returned by AddLink(). See Write() for argument // details. func (f *Fpdf) WriteLinkID(h float64, displayStr string, linkID int)
{ f.write(h, displayStr, linkID, "") }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2429-L2456
go
train
// WriteAligned is an implementation of Write that makes it possible to align // text. // // width indicates the width of the box the text will be drawn in. This is in // the unit of measure specified in New(). If it is set to 0, the bounding box //of the page will be taken (pageWidth - leftMargin - rightMargin). // //...
func (f *Fpdf) WriteAligned(width, lineHeight float64, textStr, alignStr string)
// WriteAligned is an implementation of Write that makes it possible to align // text. // // width indicates the width of the box the text will be drawn in. This is in // the unit of measure specified in New(). If it is set to 0, the bounding box //of the page will be taken (pageWidth - leftMargin - rightMargin). // //...
{ lMargin, _, rMargin, _ := f.GetMargins() if width == 0 { pageWidth, _ := f.GetPageSize() width = pageWidth - (lMargin + rMargin) } lines := f.SplitLines([]byte(textStr), width) for _, lineBt := range lines { lineStr := string(lineBt) lineWidth := f.GetStringWidth(lineStr) switch alignStr { case ...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2463-L2470
go
train
// Ln performs a line break. The current abscissa goes back to the left margin // and the ordinate increases by the amount passed in parameter. A negative // value of h indicates the height of the last printed cell. // // This method is demonstrated in the example for MultiCell.
func (f *Fpdf) Ln(h float64)
// Ln performs a line break. The current abscissa goes back to the left margin // and the ordinate increases by the amount passed in parameter. A negative // value of h indicates the height of the last printed cell. // // This method is demonstrated in the example for MultiCell. func (f *Fpdf) Ln(h float64)
{ f.x = f.lMargin if h < 0 { f.y += f.lasth } else { f.y += h } }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2476-L2490
go
train
// ImageTypeFromMime returns the image type used in various image-related // functions (for example, Image()) that is associated with the specified MIME // type. For example, "jpg" is returned if mimeStr is "image/jpeg". An error is // set if the specified MIME type is not supported.
func (f *Fpdf) ImageTypeFromMime(mimeStr string) (tp string)
// ImageTypeFromMime returns the image type used in various image-related // functions (for example, Image()) that is associated with the specified MIME // type. For example, "jpg" is returned if mimeStr is "image/jpeg". An error is // set if the specified MIME type is not supported. func (f *Fpdf) ImageTypeFromMime(mi...
{ switch mimeStr { case "image/png": tp = "png" case "image/jpg": tp = "jpg" case "image/jpeg": tp = "jpg" case "image/gif": tp = "gif" default: f.SetErrorf("unsupported image type: %s", mimeStr) } return }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2552-L2558
go
train
// Image puts a JPEG, PNG or GIF image in the current page. // // Deprecated in favor of ImageOptions -- see that function for // details on the behavior of arguments
func (f *Fpdf) Image(imageNameStr string, x, y, w, h float64, flow bool, tp string, link int, linkStr string)
// Image puts a JPEG, PNG or GIF image in the current page. // // Deprecated in favor of ImageOptions -- see that function for // details on the behavior of arguments func (f *Fpdf) Image(imageNameStr string, x, y, w, h float64, flow bool, tp string, link int, linkStr string)
{ options := ImageOptions{ ReadDpi: false, ImageType: tp, } f.ImageOptions(imageNameStr, x, y, w, h, flow, options, link, linkStr) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2596-L2606
go
train
// ImageOptions puts a JPEG, PNG or GIF image in the current page. The size it // will take on the page can be specified in different ways. If both w and h // are 0, the image is rendered at 96 dpi. If either w or h is zero, it will be // calculated from the other dimension so that the aspect ratio is maintained. // If...
func (f *Fpdf) ImageOptions(imageNameStr string, x, y, w, h float64, flow bool, options ImageOptions, link int, linkStr string)
// ImageOptions puts a JPEG, PNG or GIF image in the current page. The size it // will take on the page can be specified in different ways. If both w and h // are 0, the image is rendered at 96 dpi. If either w or h is zero, it will be // calculated from the other dimension so that the aspect ratio is maintained. // If...
{ if f.err != nil { return } info := f.RegisterImageOptions(imageNameStr, options) if f.err != nil { return } f.imageOut(info, x, y, w, h, options.AllowNegativePosition, flow, link, linkStr) return }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2612-L2618
go
train
// RegisterImageReader registers an image, reading it from Reader r, adding it // to the PDF file but not adding it to the page. // // This function is now deprecated in favor of RegisterImageOptionsReader
func (f *Fpdf) RegisterImageReader(imgName, tp string, r io.Reader) (info *ImageInfoType)
// RegisterImageReader registers an image, reading it from Reader r, adding it // to the PDF file but not adding it to the page. // // This function is now deprecated in favor of RegisterImageOptionsReader func (f *Fpdf) RegisterImageReader(imgName, tp string, r io.Reader) (info *ImageInfoType)
{ options := ImageOptions{ ReadDpi: false, ImageType: tp, } return f.RegisterImageOptionsReader(imgName, options, r) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2647-L2686
go
train
// RegisterImageOptionsReader registers an image, reading it from Reader r, adding it // to the PDF file but not adding it to the page. Use Image() with the same // name to add the image to the page. Note that tp should be specified in this // case. // // See Image() for restrictions on the image and the options parame...
func (f *Fpdf) RegisterImageOptionsReader(imgName string, options ImageOptions, r io.Reader) (info *ImageInfoType)
// RegisterImageOptionsReader registers an image, reading it from Reader r, adding it // to the PDF file but not adding it to the page. Use Image() with the same // name to add the image to the page. Note that tp should be specified in this // case. // // See Image() for restrictions on the image and the options parame...
{ // Thanks, Ivan Daniluk, for generalizing this code to use the Reader interface. if f.err != nil { return } info, ok := f.images[imgName] if ok { return } // First use of this image, get info if options.ImageType == "" { f.err = fmt.Errorf("image type should be specified if reading from custom reader"...
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2695-L2701
go
train
// RegisterImage registers an image, adding it to the PDF file but not adding // it to the page. Use Image() with the same filename to add the image to the // page. Note that Image() calls this function, so this function is only // necessary if you need information about the image before placing it. // // This function...
func (f *Fpdf) RegisterImage(fileStr, tp string) (info *ImageInfoType)
// RegisterImage registers an image, adding it to the PDF file but not adding // it to the page. Use Image() with the same filename to add the image to the // page. Note that Image() calls this function, so this function is only // necessary if you need information about the image before placing it. // // This function...
{ options := ImageOptions{ ReadDpi: false, ImageType: tp, } return f.RegisterImageOptions(fileStr, options) }
jung-kurt/gofpdf
8b09ffb30d9a8716107d250631b3c580aa54ba04
fpdf.go
https://github.com/jung-kurt/gofpdf/blob/8b09ffb30d9a8716107d250631b3c580aa54ba04/fpdf.go#L2708-L2732
go
train
// RegisterImageOptions registers an image, adding it to the PDF file but not // adding it to the page. Use Image() with the same filename to add the image // to the page. Note that Image() calls this function, so this function is only // necessary if you need information about the image before placing it. See // Image...
func (f *Fpdf) RegisterImageOptions(fileStr string, options ImageOptions) (info *ImageInfoType)
// RegisterImageOptions registers an image, adding it to the PDF file but not // adding it to the page. Use Image() with the same filename to add the image // to the page. Note that Image() calls this function, so this function is only // necessary if you need information about the image before placing it. See // Image...
{ info, ok := f.images[fileStr] if ok { return } file, err := os.Open(fileStr) if err != nil { f.err = err return } defer file.Close() // First use of this image, get info if options.ImageType == "" { pos := strings.LastIndex(fileStr, ".") if pos < 0 { f.err = fmt.Errorf("image file has no exte...