Convert html text to pdf using go language .

576 views
Skip to first unread message

KRITIKA AWASTHI

unread,
Apr 5, 2024, 11:32:51 AM4/5/24
to golang-nuts
 I want to convert html text to pdf using go language .
Previously, I used chromedp to create PDFs, but it was consuming too much server capacity. So, currently I am using using wkhtmltopdf package  which is  deprecated .
There is one more package, gofpdf, which is also deprecated and no longer maintained  .
I would appreciate if you suggest  some other alternatives of these packages . 

Harmen

unread,
Apr 5, 2024, 12:24:32 PM4/5/24
to KRITIKA AWASTHI, golang-nuts
On Fri, Apr 05, 2024 at 06:45:03AM -0700, KRITIKA AWASTHI wrote:
> I want to convert html text to pdf using go language .
> Previously, I used chromedp
> <https://pkg.go.dev/github.com/chromedp/chromedp> to create PDFs, but it
> was consuming too much server capacity. So, currently I am using using
> wkhtmltopdf <https://github.com/wkhtmltopdf/wkhtmltopdf> package which is
> deprecated .
> There is one more package, gofpdf
> <https://pkg.go.dev/github.com/jung-kurt/gofpdf>, which is also deprecated
> and no longer maintained .
> I would appreciate if you suggest some other alternatives of these
> packages .

We use weasyprint with plain `cmd := exec.Command(Exe, "--stylesheet", cssfile, "-", "-")` and some Go templating. Nothing fancy, works, looks nice.

KRITIKA AWASTHI

unread,
Apr 6, 2024, 5:32:05 AM4/6/24
to golang-nuts
Thanks for suggestion but i want a package for go language .
weasyprint is for python.

Mihai

unread,
Apr 9, 2024, 12:41:17 PM4/9/24
to golang-nuts
Use princexml command line using https://pkg.go.dev/os/exec
There is no native Go package to render html into pdf. 
The issue is very complicated because both HTML and CSS (and potentially JS) are complex markup language and as no browser was ever written in Go nobody will write HTML and CSS renderers in Go. 
Reply all
Reply to author
Forward
0 new messages