Receipt

In this guide creating a receipt document using creator template will be shown.

Before you begin

Before you begin, you should first get your API key from your UniCloud account.

If this is your first time using UniPDF SDK, follow this guide to setup a local development environment.

Clone the project repository

In your terminal, clone the examples repository. It contains the Go code we will be using for this guide.

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

Navigate to the templates/receipt folder in the unipdf-examples directory.

cd unipdf-examples/templates/receipt

How it works

The following code shows how a receipt document is created using the template.

The import section in lines 8-18 imports UniPDF packages and other necessary libraries. The init function defined in lines 20-28 authenticates your request.

The Field object which represents a field item of the ``Receiptobject is defined in lines31-34. The Receiptobject is defined in lines37-40`.

In lines 42-68 the main function is defined where the template is drawn and written to a file using the helping functions. The readTemplate function which defined in lines 71-84 is used to read the template file. The readReceipt function which read the data from a json and decodes it to Receipt object is defined in lines 87-103.

Run the code

run the code by using the following command from inside the unipdf-examples/templates/receipt directory.

go run pdf_receipt.go

Sample Output

Receipt Document

Got any Questions?

We're here to help you.