Invoices

This guide will show you how to create well-formatted invoices on the go using UniPDF, a Golang PDF library.

UniPDF can also be used to generate personalized invoices with custom styling and formatting.

Before you begin

You should get your API key from your UniCloud account.

If you are using UniPDF SDK for the first time, follow this guide to set up a local development environment.

Clone the project repository

Clone the examples repository in your terminal. It contains the sample Golang code we’ll be using in this guide.

git clone https://github.com/unidoc/unipdf-examples.git

Navigate to the invoice folder in the unipdf-examples directory.

cd unipdf-examples/invoice

How it works

Lines 9-16 import the UniPDF packages and other required dependencies.

The init function in lines 18-25 authenticates your request using your UNIDOC_LICENSE_API_KEY.

In lines 27–98, the main function creates a new instance of the PDF creator and calls the NewInvoice() method on that instance.

This is where you set the information that will appear on the invoice, such as the logo, addresses, items, and their prices. You can also add more information and terms and conditions to the invoice. The created invoice is saved as a PDF document in your current directory.

Run the code

Run this command to generate a PDF invoice. This will also get all the required dependencies to run the program.

go run pdf_invoice_simple.go

Sample output

PDF Invoice

Got any Questions?

We're here to help you.