Golang HTML to PDF Converter
Follow below steps to generate HTML to PDF using Golang:
Create a sample HTML file inside of your project.
Make sure to download the below library in your system using the following command.
sudo apt install wkhtmltopdf- for Ubuntu
brew install Caskroom/cask/wkhtmltopdf- For Mac
Download go package using the below command for parsing the HTMl template.
go get github.com/SebastiaanKlippert/go-wkhtmltopdf
We need to download another package for converting this html parse data to pdf using the below command.
go get html/template
go run main.go
After finish above steps, You can generate pdf file from html.
NOTES: Don't forget to mention your html and pdf path details inside your code. If you want to generate pdf for static data then it is not mandatory to generate another html for clone data. Use that same sample html inside the code.
Golang HTML to PDF Converter is MIT-licensed
Let us know!
We’d be really happy if you sent us links to your projects where you use our component. Just send an email to email@example.com And do let us know if you have any questions or suggestion regarding our work.