Documentation
¶
Overview ¶
Package gotenberg provides a client for the Gotenberg service. It offers a convenient API for converting HTML and URLs to PDF documents.
Index ¶
- Constants
- Variables
- type Chromium
- func (r *Chromium) Bool(fieldName string, value bool) *Chromium
- func (r *Chromium) ConvertHTML(ctx context.Context, html io.Reader) *Chromium
- func (r *Chromium) ConvertMarkdown(ctx context.Context, html io.Reader) *Chromium
- func (r *Chromium) ConvertURL(ctx context.Context, url string) *Chromium
- func (r *Chromium) File(key, filename string, content io.Reader) *Chromium
- func (r *Chromium) Float(fieldName string, value float64) *Chromium
- func (r *Chromium) Header(key, value string) *Chromium
- func (r *Chromium) Margins(top, right, bottom, left float64) *Chromium
- func (r *Chromium) MarkdownFile(filename string, content io.Reader) *Chromium
- func (r *Chromium) OutputFilename(filename string) *Chromium
- func (r *Chromium) PaperSize(width, height float64) *Chromium
- func (r *Chromium) PaperSizeA4() *Chromium
- func (r *Chromium) PaperSizeA4Landscape() *Chromium
- func (r *Chromium) PaperSizeA6() *Chromium
- func (r *Chromium) PaperSizeA6Landscape() *Chromium
- func (r *Chromium) PaperSizeLetter() *Chromium
- func (r *Chromium) PaperSizeLetterLandscape() *Chromium
- func (r *Chromium) Param(key, value string) *Chromium
- func (r *Chromium) Send() (*Response, error)
- func (r *Chromium) WebhookErrorURL(url, method string) *Chromium
- func (r *Chromium) WebhookHeader(key, value string) *Chromium
- func (r *Chromium) WebhookURL(url, method string) *Chromium
- type Response
Constants ¶
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" HeaderOutputFilename = "Gotenberg-Output-Filename" HeaderGotenbergTrace = "Gotenberg-Trace" )
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" )
const ( FieldURL = "url" FieldFiles = "files" FileIndexHTML = "index.html" FileHeaderHTML = "header.html" FileStylesCSS = "styles.css" )
Variables ¶
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 Chromium ¶
type Chromium struct {
// contains filtered or unexported fields
}
Chromium represents a Gotenberg conversion request builder. It wraps the underlying multipart request and provides Gotenberg-specific methods.
func NewChromium ¶
func NewChromium(client *httpclient.Client) *Chromium
func (*Chromium) ConvertHTML ¶
ConvertHTML creates a request to convert HTML content to PDF. The html parameter should contain the HTML content to be converted.
func (*Chromium) ConvertMarkdown ¶
ConvertMarkdown creates a request to convert Markdown content to PDF.
func (*Chromium) ConvertURL ¶
ConvertURL creates a request to convert a web page at the given URL to PDF.
func (*Chromium) Margins ¶
Margins sets the page margins for the PDF in inches. Parameters are in order: top, right, bottom, left.
func (*Chromium) MarkdownFile ¶
MarkdownFile adds a markdown file to the conversion request. This method should be used with ConvertMarkdown to add .md files for conversion.
func (*Chromium) OutputFilename ¶
OutputFilename sets the output filename for the generated PDF.
func (*Chromium) PaperSize ¶
PaperSize sets the paper size for the PDF using width and height in inches.
func (*Chromium) PaperSizeA4 ¶
PaperSizeA4 sets the paper size to A4 format.
func (*Chromium) PaperSizeA4Landscape ¶
PaperSizeA4Landscape sets the paper size to A4 format in landscape orientation.
func (*Chromium) PaperSizeA6 ¶
PaperSizeA6 sets the paper size to A6 format.
func (*Chromium) PaperSizeA6Landscape ¶
PaperSizeA6Landscape sets the paper size to A6 format in landscape orientation.
func (*Chromium) PaperSizeLetter ¶
PaperSizeLetter sets the paper size to Letter format.
func (*Chromium) PaperSizeLetterLandscape ¶
PaperSizeLetterLandscape sets the paper size to Letter format in landscape orientation.
func (*Chromium) Send ¶
Send executes the conversion request and returns the response. Returns an error if the request fails or the conversion cannot be completed.
func (*Chromium) WebhookErrorURL ¶
WebhookErrorURL sets the webhook URL and HTTP method for failed conversions.
func (*Chromium) WebhookHeader ¶
WebhookHeader adds a custom header to be sent with webhook requests. Multiple headers can be added by calling this method multiple times.
func (*Chromium) WebhookURL ¶
WebhookURL sets the webhook URL and HTTP method for successful conversions.