https://github.com/myussufz/html2pdf
Go for wkhtmltopdf - Convert HTML to PDF using Webkit (fasthttp template)
https://github.com/myussufz/html2pdf
fasthttp golang html2pdf pdf wkhtmltopdf
Last synced: about 1 year ago
JSON representation
Go for wkhtmltopdf - Convert HTML to PDF using Webkit (fasthttp template)
- Host: GitHub
- URL: https://github.com/myussufz/html2pdf
- Owner: myussufz
- License: mit
- Created: 2018-02-23T17:03:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-14T15:32:57.000Z (over 7 years ago)
- Last Synced: 2025-01-23T11:23:59.124Z (over 1 year ago)
- Topics: fasthttp, golang, html2pdf, pdf, wkhtmltopdf
- Language: Go
- Size: 16.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# html2pdf
html2pdf use wkhtmltopdf to generate PDF. It wrapper of the wkhtmltopdf using fasthttp template for html render.
This repo still under development. We accept any pull request. ^\_^
## Installation
```bash
// dependency
$ go get github.com/magicwebes/html2pdf
$ go get github.com/valyala/fasttemplate
// Downloading wkhtmltopdf from this website and install to the computer or server
https://wkhtmltopdf.org/downloads.html
```
## Quick Start
### Convert html file to pdf and download
```go
filepath := "public/views/index.html"
data := map[string]interface{}{
"message": "hello",
}
outputPath := "public/views/index.pdf"
if err := html2pdf.ParseHTML(filepath, data).ToFile(outputPath); err != nil {
log.Println("error", err)
}
```
## Advance Usage
###
```go
filepath := "public/views/data.html"
data := map[string]interface{}{
"message": "hello", // pass data to html file
}
outputPath := "public/views/data.pdf"
if err := html2pdf.ParseHTML(filepath, data).
SetConfig(&html2pdf.Config{
Orientation: html2pdf.OrientationLandscape,
PageSize: html2pdf.PageSizeA4,
}).
ToFile(outputPath); err != nil {
log.Println("error", err)
}
```