gotenberg

package module
v4.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: MIT Imports: 10 Imported by: 0

README

Gotenberg Go client

A simple Go client for interacting with a Gotenberg API.

Install

$ go get -u github.com/thecodingmachine/gotenberg-go-client/v4

Usage

import "github.com/thecodingmachine/gotenberg-go-client/v4"

func main() {
    // HTML conversion example.
    c := &gotenberg.Client{Hostname: "http://localhost:3000"}
    req, _ := gotenberg.NewHTMLRequest("index.html")
    req.SetHeader("header.html")
    req.SetFooter("footer.html")
    req.SetAssets(
        "font.woff",
        "img.gif",
        "style.css",
    )
    req.SetPaperSize(gotenberg.A4)
    req.SetMargins(gotenberg.NormalMargins)
    req.SetLandscape(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}
)
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}
)

Functions

This section is empty.

Types

type ChromeRequest

type ChromeRequest interface {
	SetHeader(fpath string) error
	SetFooter(fpath string) error
	SetPaperSize(size [2]float64)
	SetMargins(margins [4]float64)
	SetLandscape(isLandscape bool)
	SetWebFontsTimeout(timeout int64)
}

ChromeRequest is a type for sending conversion requests which will be handle by Google Chrome.

type Client

type Client struct {
	Hostname string
}

Client facilitates interacting with the Gotenberg API.

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.

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) SetAssets

func (html *HTMLRequest) SetAssets(fpaths ...string) error

SetAssets sets assets form files.

func (*HTMLRequest) SetFooter

func (html *HTMLRequest) SetFooter(fpath string) error

SetFooter sets footer form file.

func (*HTMLRequest) SetHeader

func (html *HTMLRequest) SetHeader(fpath string) error

SetHeader sets header form file.

func (*HTMLRequest) SetLandscape

func (html *HTMLRequest) SetLandscape(isLandscape bool)

SetLandscape sets landscape form field.

func (*HTMLRequest) SetMargins

func (html *HTMLRequest) SetMargins(margins [4]float64)

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

func (*HTMLRequest) SetPaperSize

func (html *HTMLRequest) SetPaperSize(size [2]float64)

SetPaperSize sets paperWidth and paperHeight form fields.

func (*HTMLRequest) SetWebFontsTimeout

func (html *HTMLRequest) SetWebFontsTimeout(timeout int64)

SetWebFontsTimeout sets webFontsTimeout form field.

func (*HTMLRequest) SetWebhookURL

func (html *HTMLRequest) SetWebhookURL(webhookURL string)

SetWebhookURL sets webhookURL 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) SetAssets

func (markdown *MarkdownRequest) SetAssets(fpaths ...string) error

SetAssets sets assets form files.

func (*MarkdownRequest) SetFooter

func (markdown *MarkdownRequest) SetFooter(fpath string) error

SetFooter sets footer form file.

func (*MarkdownRequest) SetHeader

func (markdown *MarkdownRequest) SetHeader(fpath string) error

SetHeader sets header form file.

func (*MarkdownRequest) SetLandscape

func (markdown *MarkdownRequest) SetLandscape(isLandscape bool)

SetLandscape sets landscape form field.

func (*MarkdownRequest) SetMargins

func (markdown *MarkdownRequest) SetMargins(margins [4]float64)

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

func (*MarkdownRequest) SetPaperSize

func (markdown *MarkdownRequest) SetPaperSize(size [2]float64)

SetPaperSize sets paperWidth and paperHeight form fields.

func (*MarkdownRequest) SetWebFontsTimeout

func (markdown *MarkdownRequest) SetWebFontsTimeout(timeout int64)

SetWebFontsTimeout sets webFontsTimeout form field.

func (*MarkdownRequest) SetWebhookURL

func (markdown *MarkdownRequest) SetWebhookURL(webhookURL string)

SetWebhookURL sets webhookURL 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) SetWebhookURL

func (merge *MergeRequest) SetWebhookURL(webhookURL string)

SetWebhookURL sets webhookURL 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(fpaths ...string) (*OfficeRequest, error)

NewOfficeRequest create OfficeRequest.

func (*OfficeRequest) SetLandscape

func (office *OfficeRequest) SetLandscape(isLandscape bool)

SetLandscape sets landscape form field.

func (*OfficeRequest) SetWebhookURL

func (office *OfficeRequest) SetWebhookURL(webhookURL string)

SetWebhookURL sets webhookURL form field.

type Request

type Request interface {
	SetWebhookURL(webhookURL string)
	// 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) SetFooter

func (url *URLRequest) SetFooter(fpath string) error

SetFooter sets footer form file.

func (*URLRequest) SetHeader

func (url *URLRequest) SetHeader(fpath string) error

SetHeader sets header form file.

func (*URLRequest) SetLandscape

func (url *URLRequest) SetLandscape(isLandscape bool)

SetLandscape sets landscape form field.

func (*URLRequest) SetMargins

func (url *URLRequest) SetMargins(margins [4]float64)

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

func (*URLRequest) SetPaperSize

func (url *URLRequest) SetPaperSize(size [2]float64)

SetPaperSize sets paperWidth and paperHeight form fields.

func (*URLRequest) SetWebFontsTimeout

func (url *URLRequest) SetWebFontsTimeout(timeout int64)

SetWebFontsTimeout sets webFontsTimeout form field.

func (*URLRequest) SetWebhookURL

func (url *URLRequest) SetWebhookURL(webhookURL string)

SetWebhookURL sets webhookURL form field.

type UnoconvRequest

type UnoconvRequest interface {
	SetLandscape(landscape bool)
}

UnoconvRequest is a type for sending conversion requests which will be handle by unoconv.

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