# go-report-builder
**Repository Path**: sunbengu/go-report-builder
## Basic Information
- **Project Name**: go-report-builder
- **Description**: go-report-builder
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2021-07-30
- **Last Updated**: 2021-07-30
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# go-report-builder [](https://goreportcard.com/report/github.com/AdikaStyle/go-report-builder)
## Why
In the e-commerce business, you always have need to print labels, invoices and build reports online.
We've built this tool at Adika to get rid of the cumbersome process of creating such reports and moving them
to the server side.
## How
Download using `go get` or via the releases page:
`$> go get -u github.com/AdikaStyle/go-report-builder`
1) Build your template in pure HTML, for example:
2) Use [go's templating language](https://curtisvermeeren.github.io/2017/09/14/Golang-Templates-Cheatsheet) to template the data of your report.
3) Mark your printable area with the id tag `
...
`
4) Set the page size on the body tag
5) Start go-report-builder with a reference to the folder containing your templates:
`$> go-report-builder `
6) Use the API to export your rendered html report to HTML, PDF and PNG.
Example of html report:
```html
Hello {{ .Values.name }}
```
## Example
Check the examples folder.

## Api Reference
### List Reports
Will return a list of all loaded reports:
Url: ```GET /reports/list```
Example Response:
```json
{
"list": [
"report1",
"withdata/report2",
"withdata/report3"
]
}
```
### Render Report
Will render a report (as HTML) using the provided data.
Url: `GET /reports/render/${reportId}?d=${base64Data}`
Response: the rendered HTML report.
### Preview (and debug) Report
Will open a web page that allows you to debug and test your reports.
Url: `GET /reports/preview/${reportId}?d=${base64Data}`
Response: the rendered HTML preview tool.

### Export HTML/PDF/PNG
Will create a base64 encoded string containing your rendered report:
Urls:
`POST /reports/export/html/${reportId}`
`POST /reports/export/pdf/${reportId}`
`POST /reports/export/png/${reportId}`
Body: json body that represents the data input for that report.
Response: json response with the base64 encoded content:
```json
{
"reportId": "myReport",
"type": "png",
"data": "[BASE64 CONTENT]"
}
```