/
doc.go
64 lines (43 loc) · 1.65 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
Package pdfinvoice is a library for generating PDF invoices.
# Defining the required environment variables
The following environment variables are required:
`FONT_PATH` - the path to the font files to be used
`LOGO_FILE_PATH` - the path to the logo file to be used.
In the default options struct, we are expecting the following font files:
`FONT_PATH`/Roboto-Regular.ttf
`FONT_PATH`/Roboto-Bold.ttf
# Creating the document
doc, err := NewInvoice(nil)
By passing nil as the first argument, the default configuration will be used.
# Filling the document with the required information
- Issuer
- Customer
- Type
- Number
- Date
- Series
- Mark
- PaymentMethod
- Notes
- QrCodeString
# Adding invoice entries
Using the doc.InvoiceDetails.AddEntry method, you can add invoice entries. Those are the items sold or
services provided.
# Calculate Totals and Taxes
- call doc.CalculateTotals() to calculate the totals
and fill all Taxes entries
doc.Taxes.WithHoldingTaxes =
doc.Taxes.Deductions =
doc.Taxes.StampDuty =
doc.Taxes.Fees =
doc.Taxes.OtherTaxes =
# Generate the PDF
After providing all the required data we need to create the actual document. Each document has a header, a middle body and a footer.
Three corresponding functions are responsible to place on the pdf document the data provided before.
We need to provide any struct or data type, that implements the InvoiceCreator interface, which provides those three functions.
We have already one implementation of this interface, the simpleA4Invoice.
We create the document with the following code:
err := doc.CreateAndSave("test.pdf", SimpleA4Invoice{})
*/
package pdfinvoice