A simple and efficient Golang application designed to parse JSON data and generate PDF documents. This tool is ideal for converting structured data stored in JSON format into professionally formatted PDF reports. The project leverages the power of the UniDoc library to handle PDF creation and manipulation, ensuring high-quality output.
The following JSON structure outlines the schema for generating PDF statements:
{
"title": "string",
"generated_date": "string",
"bank_name": "string",
"customer_name": "string",
"customer_address": {
"address_line1": "string",
"address_line2": "string",
"city": "string",
"county": "string",
"post_code": "string"
},
"balance_summary": [
{
"product": "string",
"opening_balance": number,
"money_in": number,
"money_out": number,
"closing_balance": number
}
],
"account_transactions": [
{
"date": "string",
"description": "string",
"money_in": number,
"money_out": number,
"balance": number
}
],
"iban_details": [
{
"iban": "string",
"bic": "string"
}
]
}
You can find sample data to use in the samples folder
-
- Visit the PDF Generator web application.
- Upload a JSON file containing the data to be converted into a PDF document and it downloads instantly
-
- You need an API key to use the local version of the application. You can obtain an API key by signing up on the UniDoc website.
You need to have .env file with the following content:
apiKey=<your_api_key> PORT=8080 useApi=false
-
Local version is made of two aspects, first is, you can use the api which support upload of
.jsonfile and downloads the generated pdf file to your computer instantly. It requires some data in the.envfile, there's a.env.examplefile you can follow through:-
Clone the repository to your local machine.
-
Navigate to the project directory.
-
Set the
useApitotruein the .env file. -
Run the following command to start the server:
make run
or
go run main.go
-
Open your browser and visit
http://localhost:8080. -
Upload a JSON file containing the data to be converted into a PDF document using the defined schema above.
-
-
Second is, you can run the application on your local machine and generate the pdf file with the useApi set to false or left empty string in the .env file.
- Clone the repository to your local machine.
- Navigate to the project directory.
- Run the following command to generate a PDF statement:
or
make run
e.ggo run main.go || go run main.go -json_file=<path_to_json_file>
go run main.go -json_file=./samples/acc_stmt2.json
-
Run the following command to execute the unit tests:
make testor
go test -v ./...
main.go - The entry point of the application.
static/ - Contains the static files for the web application.
internal/
generator/ - Contains the API client for interacting with the UniDoc API and the PDF generator.
rest/ - Contains the REST API server implementation.
types/ - Contains the data structures used in the application.
utils/ - Contains utility functions used in the application.