This is a service that creates a PDF file from a HTML source. The request is made via API REST and the response
is a []byte
that contains the PDF file.
We need install wkhtmltopdf
b/c we are using that library for create PDF files.
sudo apt install wkhtmltopdf
We need download de project, configure the .env
file, compile and run.
Clone the project:
git clone [email protected]:alexyslozada/gohtmltopdf.git
cd gohtmltopdf
Configure the .env
file:
cp .env.example .env
# Edit the file with your desire config.
Compile and run:
go mod tidy
go build -o gohtmltopdf cmd/main.go
./gohtmltopdf
This project has a client example in order to know how to write your own client.
The client is in client/main.go
. You only need to know how to make a request
to the server and how to process the response.
If you want to run the client:
go run client/main.go
If you need to use the service into a Docker image, you can follow this steps:
- Compile to Linux
GOOS=linux go build -ldflags "-s -w" -o gohtmltopdf cmd/main.go
- Configure the
.env
cp .env.example .env
# Edit the file with your desire config.
- Create the docker image
docker build -t alexys/gohtmltopdf .
- Run the deamon
docker run --name myhtmltopdf -p 8080:8080 -d alexys/gohtmltopdf