Documentation
¶
Overview ¶
Package generator allows you to easily generate invoices, delivery notes and quotations in GoLang.
Index ¶
- Constants
- Variables
- type Address
- type Contact
- type Document
- func (d *Document) AppendItem(item *Item) *Document
- func (d *Document) Build() (*gofpdf.Fpdf, error)
- func (d *Document) SetCompany(company *Contact) *Document
- func (d *Document) SetCustomer(customer *Contact) *Document
- func (d *Document) SetDate(date string) *Document
- func (d *Document) SetDescription(desc string) *Document
- func (d *Document) SetFooter(footer *HeaderFooter) *Document
- func (d *Document) SetHeader(header *HeaderFooter) *Document
- func (d *Document) SetNotes(notes string) *Document
- func (d *Document) SetPaymentTerm(term string) *Document
- func (d *Document) SetRef(ref string) *Document
- func (d *Document) SetType(docType string) *Document
- func (d *Document) SetVersion(version string) *Document
- func (d *Document) Validate() error
- type HeaderFooter
- type Item
- type Options
- type Tax
Examples ¶
Constants ¶
View Source
const BaseMargin float64 = 10
View Source
const BaseMarginTop float64 = 20
View Source
const DeliveryNote string = "DELIVERY_NOTE"
View Source
const HeaderMarginTop float64 = 5
View Source
const Invoice string = "INVOICE"
View Source
const MaxPageHeight float64 = 260
View Source
const Quotation string = "QUOTATION"
Variables ¶
View Source
var BaseTextColor = []int{35, 35, 35}
View Source
var DarkBgColor = []int{212, 212, 212}
View Source
var GreyBgColor = []int{232, 232, 232}
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Document ¶
type Document struct {
Options *Options
Header *HeaderFooter
Type string `validate:"required,oneof=INVOICE DELIVERY_NOTE QUOTATION"`
Ref string `validate:"required,min=1,max=32"`
Version string `validate:"max=32"`
ClientRef string `validate:"max=64"`
Description string `validate:"max=1024"`
Notes string
Company *Contact `validate:"required"`
Customer *Contact `validate:"required"`
Items []*Item
Date string
ValidityDate string
PaymentTerm string
}
func New ¶
Example ¶
doc, _ := New(DeliveryNote, &Options{
TextTypeInvoice: "FACTURE",
AutoPrint: true,
})
doc.SetHeader(&HeaderFooter{
Text: "<center>Cupcake ipsum dolor sit amet bonbon. I love croissant cotton candy. Carrot cake sweet I love sweet roll cake powder.</center>",
Pagination: true,
})
doc.SetFooter(&HeaderFooter{
Text: "<center>Cupcake ipsum dolor sit amet bonbon. I love croissant cotton candy. Carrot cake sweet I love sweet roll cake powder.</center>",
Pagination: true,
})
doc.SetRef("testref")
doc.SetVersion("someversion")
doc.SetDescription("A description")
logoBytes, _ := ioutil.ReadFile("./example_logo.png")
doc.SetCompany(&Contact{
Name: "Test Company",
Logo: &logoBytes,
Address: &Address{
Address: "89 Rue de Brest",
Address2: "Appartement 2",
PostalCode: "75000",
City: "Paris",
Country: "France",
},
})
doc.SetCustomer(&Contact{
Name: "Test Customer",
Address: &Address{
Address: "89 Rue de Paris",
PostalCode: "29200",
City: "Brest",
Country: "France",
},
})
for i := 0; i < 15; i++ {
doc.AppendItem(&Item{
Name: "Test",
UnitCost: "99876.89",
Quantity: "2",
Tax: &Tax{
Percent: "20",
},
})
}
pdf, err := doc.Build()
if err != nil {
fmt.Println(err.Error())
}
err = pdf.OutputFileAndClose("out.pdf")
if err != nil {
fmt.Println(err.Error())
}
func (*Document) AppendItem ¶
func (*Document) SetCompany ¶
func (*Document) SetCustomer ¶
func (*Document) SetDescription ¶
func (*Document) SetFooter ¶
func (d *Document) SetFooter(footer *HeaderFooter) *Document
func (*Document) SetHeader ¶
func (d *Document) SetHeader(header *HeaderFooter) *Document
func (*Document) SetPaymentTerm ¶
func (*Document) SetVersion ¶
type HeaderFooter ¶
type HeaderFooter struct {
}
func (*HeaderFooter) ApplyFunc ¶
func (hf *HeaderFooter) ApplyFunc(pdf *gofpdf.Fpdf, fn fnc)
ApplyFunc allow user to apply custom func
type Options ¶
type Options struct {
AutoPrint bool
CurrencySymbol string `default:"€ "`
CurrencyPrecision int `default:"2"`
CurrencyDecimal string `default:","`
CurrencyThousand string `default:"."`
TextTypeInvoice string `default:"INVOICE"`
TextTypeQuotation string `default:"QUOTATION"`
TextTypeDeliveryNote string `default:"DELIVERY NOTE"`
TextRefTitle string `default:"Ref."`
TextVersionTitle string `default:"Version"`
TextDateTitle string `default:"Date"`
TextPaymentTermTitle string `default:"Payment term"`
TextItemsDescriptionTitle string `default:"Description"`
TextItemsUnitCostTitle string `default:"Unit price"`
TextItemsQuantityTitle string `default:"Quantity"`
TextItemsTotalHTTitle string `default:"Total"`
TextItemsTaxTitle string `default:"Tax"`
TextItemsTotalTTCTitle string `default:"Total with tax"`
TextTotalTotal string `default:"TOTAL"`
TextTotalTax string `default:"TAX"`
TextTotalWithTax string `default:"TOTAL WITH TAX"`
}
Click to show internal directories.
Click to hide internal directories.
