gotenberg

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2025 License: MIT Imports: 10 Imported by: 0

README ¶

gotenberg-client

Go Reference Go Report Card License

A high-performance Go client for the Gotenberg HTTP API with fluent interface and zero dependencies.

Quick Start

package main

import (
    "context"
    "log"
    "net/http"
    "strings"
    
    "github.com/nativebpm/gotenberg-client"
)

func main() {
    client, err := gotenberg.NewClient(&http.Client{}, "http://localhost:3000")
    if err != nil {
        log.Fatal(err)
    }
    
    html := strings.NewReader("<html><body><h1>Hello World!</h1></body></html>")
    
    resp, err := client.
        ConvertHTML(context.Background(), html).
        PaperSizeA4().
        Send()
        
    if err != nil {
        log.Fatal(err)
    }
    defer resp.Body.Close()
}

Installation

go get github.com/nativebpm/gotenberg-client

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation ¶

Index ¶

Constants ¶

View Source
const (
	ApplicationJSON = "application/json"
	ContentType     = "Content-Type"
	ContentLength   = "Content-Length"
)
View Source
const (
	ConvertHTML = "/forms/chromium/convert/html"
	ConvertURL  = "/forms/chromium/convert/url"
)
View Source
const (
	FieldSinglePage              = "singlePage"
	FieldPaperWidth              = "paperWidth"
	FieldPaperHeight             = "paperHeight"
	FieldMarginTop               = "marginTop"
	FieldMarginBottom            = "marginBottom"
	FieldMarginLeft              = "marginLeft"
	FieldMarginRight             = "marginRight"
	FieldPreferCSSPageSize       = "preferCssPageSize"
	FieldGenerateDocumentOutline = "generateDocumentOutline"
	FieldGenerateTaggedPDF       = "generateTaggedPdf"
	FieldPrintBackground         = "printBackground"
	FieldOmitBackground          = "omitBackground"
	FieldLandscape               = "landscape"
	FieldScale                   = "scale"
	FieldNativePageRanges        = "nativePageRanges"
)
View Source
const (
	HeaderWebhookURL              = "Gotenberg-Webhook-Url"
	HeaderWebhookErrorURL         = "Gotenberg-Webhook-Error-Url"
	HeaderWebhookMethod           = "Gotenberg-Webhook-Method"
	HeaderWebhookErrorMethod      = "Gotenberg-Webhook-Error-Method"
	HeaderWebhookExtraHTTPHeaders = "Gotenberg-Webhook-Extra-Http-Headers"
)
View Source
const (
	FieldURL       = "url"
	FieldFiles     = "files"
	FileIndexHTML  = "index.html"
	FileFooterHTML = "footer.html"
	FileHeaderHTML = "header.html"
	FileStylesCSS  = "styles.css"
)

Variables ¶

View Source
var (
	PaperSizeLetter  = [2]float64{8.5, 11}
	PaperSizeLegal   = [2]float64{8.5, 14}
	PaperSizeTabloid = [2]float64{11, 17}
	PaperSizeLedger  = [2]float64{17, 11}
	PaperSizeA0      = [2]float64{33.1, 46.8}
	PaperSizeA1      = [2]float64{23.4, 33.1}
	PaperSizeA2      = [2]float64{16.54, 23.4}
	PaperSizeA3      = [2]float64{11.7, 16.54}
	PaperSizeA4      = [2]float64{8.27, 11.7}
	PaperSizeA5      = [2]float64{5.83, 8.27}
	PaperSizeA6      = [2]float64{4.13, 5.83}
)

Functions ¶

This section is empty.

Types ¶

type Client ¶

type Client struct {
	// contains filtered or unexported fields
}

func NewClient ¶

func NewClient(client *http.Client, baseURL string) (*Client, error)

func (*Client) ConvertHTML ¶ added in v1.0.1

func (c *Client) ConvertHTML(ctx context.Context, html io.Reader) *Request

func (*Client) ConvertURL ¶ added in v1.0.1

func (c *Client) ConvertURL(ctx context.Context, url string) *Request

func (*Client) MethodDelete ¶ added in v1.2.0

func (c *Client) MethodDelete(ctx context.Context, path string) *Request

func (*Client) MethodGet ¶ added in v1.2.0

func (c *Client) MethodGet(ctx context.Context, path string) *Request

func (*Client) MethodPatch ¶ added in v1.2.0

func (c *Client) MethodPatch(ctx context.Context, path string) *Request

func (*Client) MethodPost ¶ added in v1.2.0

func (c *Client) MethodPost(ctx context.Context, path string) *Request

func (*Client) MethodPut ¶ added in v1.2.0

func (c *Client) MethodPut(ctx context.Context, path string) *Request

type Request ¶ added in v1.1.1

type Request struct {
	*Client
	// contains filtered or unexported fields
}

func (*Request) Body ¶ added in v1.2.0

func (r *Request) Body(body io.ReadCloser) *Request

func (*Request) Bool ¶ added in v1.1.1

func (r *Request) Bool(fieldName string, value bool) *Request

func (*Request) BytesBody ¶ added in v1.2.0

func (r *Request) BytesBody(body []byte) *Request

func (*Request) ContentType ¶ added in v1.2.0

func (r *Request) ContentType(contentType string) *Request

func (*Request) Err ¶ added in v1.2.0

func (r *Request) Err() error

func (*Request) File ¶ added in v1.1.1

func (r *Request) File(fieldName, filename string, content io.Reader) *Request

func (*Request) Float ¶ added in v1.1.1

func (r *Request) Float(fieldName string, value float64) *Request

func (*Request) FormField ¶ added in v1.1.1

func (r *Request) FormField(fieldName, value string) *Request

func (*Request) Header ¶ added in v1.1.1

func (r *Request) Header(key, value string) *Request

func (*Request) Headers ¶ added in v1.2.0

func (r *Request) Headers(headers map[string]string) *Request

func (*Request) JSONBody ¶ added in v1.2.0

func (r *Request) JSONBody(body any) *Request

func (*Request) JSONContentType ¶ added in v1.2.0

func (r *Request) JSONContentType() *Request

func (*Request) Margins ¶ added in v1.1.1

func (r *Request) Margins(top, right, bottom, left float64) *Request

func (*Request) Multipart ¶ added in v1.2.0

func (r *Request) Multipart() *Request

func (*Request) PaperSize ¶ added in v1.1.1

func (r *Request) PaperSize(width, height float64) *Request

func (*Request) PaperSizeA4 ¶ added in v1.1.1

func (r *Request) PaperSizeA4() *Request

func (*Request) PaperSizeLetter ¶ added in v1.1.1

func (r *Request) PaperSizeLetter() *Request

func (*Request) QueryParam ¶ added in v1.2.0

func (r *Request) QueryParam(key, value string) *Request

func (*Request) QueryParams ¶ added in v1.2.0

func (r *Request) QueryParams(params map[string]string) *Request

func (*Request) QueryValues ¶ added in v1.2.0

func (r *Request) QueryValues(values url.Values) *Request

func (*Request) Send ¶ added in v1.1.1

func (r *Request) Send() (*http.Response, error)

func (*Request) StringBody ¶ added in v1.2.0

func (r *Request) StringBody(body string) *Request

func (*Request) WebhookErrorURLMethodPost ¶ added in v1.1.1

func (r *Request) WebhookErrorURLMethodPost(url string) *Request

func (*Request) WebhookExtraHeaders ¶ added in v1.1.1

func (r *Request) WebhookExtraHeaders(headers map[string]string) *Request

func (*Request) WebhookURLMethodPost ¶ added in v1.1.1

func (r *Request) WebhookURLMethodPost(url string) *Request

Directories ¶

Path Synopsis
example
cmd/webhook command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL