Bank Account Statement

In this guide creating a sample bank statement document will be shown.

Before you begin

You should get your API key from your UniCloud account if you don’t have any yet.

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

Navigate to the templates/bank-account-statement folder in the unipdf-examples directory.

cd unipdf-examples/templates/bank-account-statement

How it works

UniPDF packages and other libraries are imported in the import section in lines 10-24. The init function in lines 26-35 loads the license key from environment to authenticate library request.

The main function in lines 37-125 creates the file using templates and writes the document to file. In lines 42-51 the template file and json file are read using mainTpl, err := readTemplate("templates/main.tpl") and statement, err := readAccountStatement("account_statement.json") respectively. The template options object is created in lines 54-87 using creator.TemplateOptions. In line 89 the main template is drawn using c.DrawTemplate.

In lines 94-112 a function defined for drawing header and footer elements.

In line 114-119 the footer and header are drawn by using the predefined function. Finally the pdf document is written to file in lines 122-124 using the following code.

if err := c.WriteToFile("unipdf-bank-account-statement.pdf"); err != nil {

The readTemplate function reads the template function and returns io.Reader buffer. In lines 145-190 AccountStatement object is defined to represent the data used for the document. The readAccountStatement function defined in lines 194-207 decodes the data in json to an AccountStatement object.

Run the code

Use the following command to run the code.

go run pdf_bank_account_statement.go

Sample Output

Preview of the output document can be shown in the image below. Bank Account Statement

Got any Questions?

We're here to help you.