Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thecodingmachine/gotenberg-go-client
Go client for the Gotenberg API
https://github.com/thecodingmachine/gotenberg-go-client
api excel go gotenberg html markdown pdf pdf-converter powerpoint word
Last synced: about 2 months ago
JSON representation
Go client for the Gotenberg API
- Host: GitHub
- URL: https://github.com/thecodingmachine/gotenberg-go-client
- Owner: thecodingmachine
- License: mit
- Archived: true
- Created: 2019-03-15T13:27:35.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-13T23:30:43.000Z (7 months ago)
- Last Synced: 2024-06-19T17:37:39.965Z (5 months ago)
- Topics: api, excel, go, gotenberg, html, markdown, pdf, pdf-converter, powerpoint, word
- Language: Go
- Homepage:
- Size: 439 KB
- Stars: 55
- Watchers: 11
- Forks: 31
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-gotenberg - Go - thecodingmachine/gotenberg-go-client - Gotenberg **6.x** ⚠️ (Clients)
README
**⚠️ Not working for Gotenberg >= 7 ⚠️**
# Gotenberg Go client
A simple Go client for interacting with a Gotenberg API.
## Install
```bash
$ go get -u github.com/thecodingmachine/gotenberg-go-client/v7
```## Usage
```golang
import (
"time"
"net/http""github.com/thecodingmachine/gotenberg-go-client/v7"
)// create the client.
client := &gotenberg.Client{Hostname: "http://localhost:3000"}
// ... or use your own *http.Client.
httpClient := &http.Client{
Timeout: time.Duration(5) * time.Second,
}
client := &gotenberg.Client{Hostname: "http://localhost:3000", HTTPClient: httpClient}// prepare the files required for your conversion.
// from a path.
index, _ := gotenberg.NewDocumentFromPath("index.html", "/path/to/file")
// ... or from a string.
index, _ := gotenberg.NewDocumentFromString("index.html", "Foo")
// ... or from bytes.
index, _ := gotenberg.NewDocumentFromBytes("index.html", []byte("Foo"))header, _ := gotenberg.NewDocumentFromPath("header.html", "/path/to/file")
footer, _ := gotenberg.NewDocumentFromPath("footer.html", "/path/to/file")
style, _ := gotenberg.NewDocumentFromPath("style.css", "/path/to/file")
img, _ := gotenberg.NewDocumentFromPath("img.png", "/path/to/file")req := gotenberg.NewHTMLRequest(index)
req.Header(header)
req.Footer(footer)
req.Assets(style, img)
req.PaperSize(gotenberg.A4)
req.Margins(gotenberg.NoMargins)
req.Scale(0.75)// store method allows you to... store the resulting PDF in a particular destination.
client.Store(req, "path/you/want/the/pdf/to/be/stored.pdf")// if you wish to redirect the response directly to the browser, you may also use:
resp, _ := client.Post(req)
```For more complete usages, head to the [documentation](https://gotenberg.dev/).
## Badges
[![Travis CI](https://travis-ci.org/thecodingmachine/gotenberg-go-client.svg?branch=master)](https://travis-ci.org/thecodingmachine/gotenberg-go-client)
[![GoDoc](https://godoc.org/github.com/thecodingmachine/gotenberg-go-client?status.svg)](https://godoc.org/github.com/thecodingmachine/gotenberg-go-client)
[![Go Report Card](https://goreportcard.com/badge/github.com/thecodingmachine/gotenberg-go-client)](https://goreportcard.com/report/thecodingmachine/gotenberg-go-client)