gotenberg

package module
v6.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2020 License: MIT Imports: 10 Imported by: 2

README

Gotenberg Go client

A simple Go client for interacting with a Gotenberg API.

Install

$ go get -u github.com/meateam/gotenberg-go-client/v6

Usage

import "github.com/meateam/gotenberg-go-client/v6"

func main() {
    // HTML conversion example.
    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
    req, _ := gotenberg.NewHTMLRequest("index.html")
    req.Header("header.html")
    req.Footer("footer.html")
    req.Assets(
        "font.woff",
        "img.gif",
        "style.css",
    )
    req.PaperSize(gotenberg.A4)
    req.Margins(gotenberg.NormalMargins)
    req.Landscape(false)
    dest := "foo.pdf"
    c.Store(req, dest)
}

For more complete usages, head to the documentation.

Badges

Travis CI GoDoc Go Report Card

Documentation

Overview

Package gotenberg is a Go client for interacting with a Gotenberg API.

For more complete usages, head to the documentation: https://thecodingmachine.github.io/gotenberg/

Index

Constants

This section is empty.

Variables

View Source
var (
	// A3 paper size.
	A3 = [2]float64{11.7, 16.5}
	// A4 paper size.
	A4 = [2]float64{8.27, 11.7}
	// A5 paper size.
	A5 = [2]float64{5.8, 8.3}
	// A6 paper size.
	A6 = [2]float64{4.1, 5.8}
	// Letter paper size.
	Letter = [2]float64{8.5, 11}
	// Legal paper size.
	Legal = [2]float64{8.5, 14}
	// Tabloid paper size.
	Tabloid = [2]float64{11, 17}
)

nolint: gochecknoglobals

View Source
var (
	// NoMargins removes margins.
	NoMargins = [4]float64{0, 0, 0, 0}
	// NormalMargins uses 1 inche margins.
	NormalMargins = [4]float64{1, 1, 1, 1}
	// LargeMargins uses 2 inche margins.
	LargeMargins = [4]float64{2, 2, 2, 2}
)

nolint: gochecknoglobals

Functions

This section is empty.

Types

type Client

type Client struct {
	Hostname string
}

Client facilitates interacting with the Gotenberg API.

func (*Client) Healthy added in v6.0.7

func (c *Client) Healthy() bool

Healthy returns true if the gotenberg server at c.Hostname is healthy, false otherwise.

func (*Client) Post

func (c *Client) Post(req Request) (*http.Response, error)

Post sends a request to the Gotenberg API and returns the response.

func (*Client) Store

func (c *Client) Store(req Request, dest string) error

Store creates the resulting PDF to given destination.

func (*Client) StoreWriter added in v6.0.5

func (c *Client) StoreWriter(req Request, dest io.Writer) error

StoreWriter copies the resulting PDF to given destination writer.

type HTMLRequest

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

HTMLRequest facilitates HTML conversion with the Gotenberg API.

func NewHTMLRequest

func NewHTMLRequest(indexFilePath string) (*HTMLRequest, error)

NewHTMLRequest create HTMLRequest.

func (*HTMLRequest) Assets

func (req *HTMLRequest) Assets(fpaths ...string) error

Assets sets assets form files.

func (HTMLRequest) Footer

func (req HTMLRequest) Footer(fpath string) error

Footer sets footer form file.

func (HTMLRequest) GoogleChromeRpccBufferSize

func (req HTMLRequest) GoogleChromeRpccBufferSize(bufferSize int64)

GoogleChromeRpccBufferSize sets googleChromeRpccBufferSize form field.

func (HTMLRequest) Header

func (req HTMLRequest) Header(fpath string) error

Header sets header form file.

func (HTMLRequest) Landscape

func (req HTMLRequest) Landscape(isLandscape bool)

Landscape sets landscape form field.

func (HTMLRequest) Margins

func (req HTMLRequest) Margins(margins [4]float64)

Margins sets marginTop, marginBottom, marginLeft and marginRight form fields.

func (HTMLRequest) PaperSize

func (req HTMLRequest) PaperSize(size [2]float64)

PaperSize sets paperWidth and paperHeight form fields.

func (HTMLRequest) WaitDelay

func (req HTMLRequest) WaitDelay(delay float64)

WaitDelay sets waitDelay form field.

type MarkdownRequest

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

MarkdownRequest facilitates Markdown conversion with the Gotenberg API.

func NewMarkdownRequest

func NewMarkdownRequest(indexFilePath string, markdownFilePaths ...string) (*MarkdownRequest, error)

NewMarkdownRequest create MarkdownRequest.

func (*MarkdownRequest) Assets

func (req *MarkdownRequest) Assets(fpaths ...string) error

Assets sets assets form files.

func (MarkdownRequest) Footer

func (req MarkdownRequest) Footer(fpath string) error

Footer sets footer form file.

func (MarkdownRequest) GoogleChromeRpccBufferSize

func (req MarkdownRequest) GoogleChromeRpccBufferSize(bufferSize int64)

GoogleChromeRpccBufferSize sets googleChromeRpccBufferSize form field.

func (MarkdownRequest) Header

func (req MarkdownRequest) Header(fpath string) error

Header sets header form file.

func (MarkdownRequest) Landscape

func (req MarkdownRequest) Landscape(isLandscape bool)

Landscape sets landscape form field.

func (MarkdownRequest) Margins

func (req MarkdownRequest) Margins(margins [4]float64)

Margins sets marginTop, marginBottom, marginLeft and marginRight form fields.

func (MarkdownRequest) PaperSize

func (req MarkdownRequest) PaperSize(size [2]float64)

PaperSize sets paperWidth and paperHeight form fields.

func (MarkdownRequest) WaitDelay

func (req MarkdownRequest) WaitDelay(delay float64)

WaitDelay sets waitDelay form field.

type MergeRequest

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

MergeRequest facilitates merging PDF with the Gotenberg API.

func NewMergeRequest

func NewMergeRequest(fpaths ...string) (*MergeRequest, error)

NewMergeRequest create MergeRequest.

func (MergeRequest) ResultFilename

func (req MergeRequest) ResultFilename(filename string)

ResultFilename sets resultFilename form field.

func (MergeRequest) WaitTimeout

func (req MergeRequest) WaitTimeout(timeout float64)

WaitTiemout sets waitTimeout form field.

func (MergeRequest) WebhookURL

func (req MergeRequest) WebhookURL(url string)

WebhookURL sets webhookURL form field.

func (MergeRequest) WebhookURLTimeout

func (req MergeRequest) WebhookURLTimeout(timeout float64)

WebhookURLTimeout sets webhookURLTimeout form field.

type OfficeRequest

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

OfficeRequest facilitates Office documents conversion with the Gotenberg API.

func NewOfficeRequest

func NewOfficeRequest(filename string, fileReader io.Reader) (*OfficeRequest, error)

NewOfficeRequest create OfficeRequest.

func NewOfficeRequestWithBuffer added in v6.0.6

func NewOfficeRequestWithBuffer(filename string, fileReader io.Reader, readerCopyBuffer []byte) (*OfficeRequest, error)

NewOfficeRequestWithBuffer create OfficeRequest.

func (*OfficeRequest) Landscape

func (req *OfficeRequest) Landscape(isLandscape bool)

Landscape sets landscape form field.

func (OfficeRequest) ResultFilename

func (req OfficeRequest) ResultFilename(filename string)

ResultFilename sets resultFilename form field.

func (OfficeRequest) WaitTimeout

func (req OfficeRequest) WaitTimeout(timeout float64)

WaitTiemout sets waitTimeout form field.

func (OfficeRequest) WebhookURL

func (req OfficeRequest) WebhookURL(url string)

WebhookURL sets webhookURL form field.

func (OfficeRequest) WebhookURLTimeout

func (req OfficeRequest) WebhookURLTimeout(timeout float64)

WebhookURLTimeout sets webhookURLTimeout form field.

type Request

type Request interface {
	// contains filtered or unexported methods
}

Request is a type for sending form values and form files to the Gotenberg API.

type URLRequest

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

URLRequest facilitates remote URL conversion with the Gotenberg API.

func NewURLRequest

func NewURLRequest(url string) *URLRequest

NewURLRequest create URLRequest.

func (URLRequest) Footer

func (req URLRequest) Footer(fpath string) error

Footer sets footer form file.

func (URLRequest) GoogleChromeRpccBufferSize

func (req URLRequest) GoogleChromeRpccBufferSize(bufferSize int64)

GoogleChromeRpccBufferSize sets googleChromeRpccBufferSize form field.

func (URLRequest) Header

func (req URLRequest) Header(fpath string) error

Header sets header form file.

func (URLRequest) Landscape

func (req URLRequest) Landscape(isLandscape bool)

Landscape sets landscape form field.

func (URLRequest) Margins

func (req URLRequest) Margins(margins [4]float64)

Margins sets marginTop, marginBottom, marginLeft and marginRight form fields.

func (URLRequest) PaperSize

func (req URLRequest) PaperSize(size [2]float64)

PaperSize sets paperWidth and paperHeight form fields.

func (URLRequest) WaitDelay

func (req URLRequest) WaitDelay(delay float64)

WaitDelay sets waitDelay form field.

Directories

Path Synopsis
Package test contains useful functions used across tests.
Package test contains useful functions used across tests.

Jump to

Keyboard shortcuts

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