Golang HTML to PDF Converter

68747470733a2f2f7472617669732d63692e6f72672f4d696e64696e76656e746f72792f476f6c616e672d48544d4c2d544f2d5044462d436f6e7665727465722e7376673f6272616e63683d6d617374657268747470733a2f2f696d672e736869656c64732e696f2f62616467652f676f2d646f63756d656e746174696f6e2d626c75652e73766768747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f4d696e64696e76656e746f72792f476f6c616e672d48544d4c2d544f2d5044462d436f6e76657274657268747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667

For reading any document, one prefers PDF format over any other formats as it is considered as a standard format for any document in our day to day life. We often come across converting any form details or previews on the website in the form of HTML to PDF. For GoLang, understanding such usability, Developers at Mindinventory made an effort for making one HTML to PDF Converter which can be used for converting HTML content to PDF.

What it is?

It is a repository, integrating which one can offer HTML to PDF Conversion to their customers.

Prerequisite

Install wkhtmltopdf using below command

sudo apt install wkhtmltopdf - for Ubuntu

brew install Caskroom/cask/wkhtmltopdf - For Mac

Steps to Follow

8a785fcc5ab7de2888862302abc95f43.gif

Create a sample HTML file inside of your project.

Get go package using the below command for parsing the HTMl template.

go get github.com/SebastiaanKlippert/go-wkhtmltopdf

Get another go package for converting this html parse data to pdf using the below command.

go get html/template

Run below command

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.

LICENSE!

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 sales@mindinventory.com And do let us know if you have any questions or suggestion regarding our work.