Giter Site home page Giter Site logo

anecsoiu / go-invoice-generator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from angelodlfrtr/go-invoice-generator

0.0 1.0 0.0 378 KB

Super fast golang invoice / quotation / delivery-note PDF generator

License: Apache License 2.0

Go 100.00%

go-invoice-generator's Introduction

GoDoc

Golang invoice generator

A super fast golang package to generate invoices, delivery notes and quotations as pdf using https://github.com/jung-kurt/gofpdf.

Download from Github

go get -u github.com/anecsoiu/go-invoice-generator

Exemple output

DeliveryNoteExample

Quick start

package main

import (
  generator "github.com/anecsoiu/go-invoice-generator"
)

func main() {
	doc := generator.New(generator.INVOICE, &generator.Options{})

	doc.SetHeader(&generator.HeaderFooter{
		Text: "Some header text",
	})

	doc.SetFooter(&generator.HeaderFooter{
		Text:           "<center>Some footer text</center>",
		Pagination:     true,
	})

	doc.SetNumber("testnumber")
	doc.SetVersion("test version")

	doc.SetDescription("Some text describing document")

	doc.SetCompany(&generator.Contact{
		Name: "Test Company",
		Logo: []byte{}, // Image as byte array, supported format: png, jpeg, gif
		Address: &generator.Address{
			Address:    "89 Rue de Brest",
			Address2:   "Appartement 2",
			PostalCode: "75000",
			City:       "Paris",
			Country:    "France",
		},
	})

	doc.SetCustomer(&generator.Contact{
		Name: "Test Customer",
		Address: &generator.Address{
			Address:    "89 Rue de Paris",
			PostalCode: "29200",
			City:       "Brest",
			Country:    "France",
		},
	})

	doc.AppendItem(&generator.Item{
		Name:     "Item one",
		UnitCost: "89",
		Quantity: "2",
		Tax: &generator.Tax{
			Percent: "20",
		},
	})

	doc.AppendItem(&generator.Item{
		Name:     "Item two",
		UnitCost: "5.89",
		Quantity: "11",
		Tax: &generator.Tax{
			Amount: "10",
		},
	})

	pdf, err := doc.Build()

	if err != nil {
		fmt.Println(err.Error())
	}

	err = pdf.OutputFileAndClose("./out.pdf")

	if err != nil {
		fmt.Println(err.Error())
	}
}

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE and NOTICE for more information.

go-invoice-generator's People

Contributors

angelodlfrtr avatar anecsoiu avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.