chromium

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package chromium provides a client for the Gotenberg Chromium service. It offers a convenient API for converting HTML, URLs, and Markdown to PDF documents and screenshots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chromium

type Chromium struct {
	*gotenberg.Gotenberg
}

Chromium represents a Gotenberg conversion request builder.

func NewChromium

func NewChromium(client *httpclient.Client) *Chromium

func (*Chromium) Bool

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

Bool adds a boolean form parameter to the conversion request.

func (*Chromium) ConvertHTML

func (r *Chromium) ConvertHTML(ctx context.Context, html io.Reader) *Chromium

ConvertHTML creates a request to convert HTML content to PDF. The html parameter should contain the HTML content to be converted.

func (*Chromium) ConvertMarkdown

func (r *Chromium) ConvertMarkdown(ctx context.Context, html io.Reader) *Chromium

ConvertMarkdown creates a request to convert Markdown content to PDF.

func (*Chromium) ConvertURL

func (r *Chromium) ConvertURL(ctx context.Context, url string) *Chromium

ConvertURL creates a request to convert a web page at the given URL to PDF.

func (*Chromium) DownloadFrom

func (r *Chromium) DownloadFrom(data gotenberg.DownloadFrom) *Chromium

DownloadFrom sets the downloadFrom parameter for downloading files from URLs. The data should be a slice of DownloadItem representing the download configuration.

func (*Chromium) File

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

File adds a file to the conversion request.

func (*Chromium) Float

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

Float adds a float64 form parameter to the conversion request.

func (*Chromium) GenerateDocumentOutline

func (r *Chromium) GenerateDocumentOutline() *Chromium

GenerateDocumentOutline sets whether the document outline should be embedded into the PDF.

func (*Chromium) GenerateTaggedPdf

func (r *Chromium) GenerateTaggedPdf() *Chromium

GenerateTaggedPdf sets whether to generate tagged (accessible) PDF.

func (*Chromium) Header

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

Header adds a header to the conversion request.

func (*Chromium) Landscape

func (r *Chromium) Landscape() *Chromium

Landscape sets the paper orientation to landscape.

func (*Chromium) MarginBottom

func (r *Chromium) MarginBottom(value float64) *Chromium

MarginBottom sets the bottom margin in inches.

func (*Chromium) MarginLeft

func (r *Chromium) MarginLeft(value float64) *Chromium

MarginLeft sets the left margin in inches.

func (*Chromium) MarginRight

func (r *Chromium) MarginRight(value float64) *Chromium

MarginRight sets the right margin in inches.

func (*Chromium) MarginTop

func (r *Chromium) MarginTop(value float64) *Chromium

MarginTop sets the top margin in inches.

func (*Chromium) Margins

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

Margins sets the page margins for the PDF in inches. Parameters are in order: top, right, bottom, left.

func (*Chromium) NativePageRanges

func (r *Chromium) NativePageRanges(value string) *Chromium

NativePageRanges sets the page ranges to print, e.g., '1-5, 8, 11-13'.

func (*Chromium) OmitBackground

func (r *Chromium) OmitBackground() *Chromium

OmitBackground hides the default white background and allows generating PDFs with transparency.

func (*Chromium) OutputFilename

func (r *Chromium) OutputFilename(filename string) *Chromium

OutputFilename sets the output filename for the generated PDF.

func (*Chromium) PaperHeight

func (r *Chromium) PaperHeight(value float64) *Chromium

PaperHeight sets the paper height in inches.

func (*Chromium) PaperSize

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

PaperSize sets the paper size for the PDF using width and height in inches.

func (*Chromium) PaperSizeA4

func (r *Chromium) PaperSizeA4() *Chromium

PaperSizeA4 sets the paper size to A4 format.

func (*Chromium) PaperSizeA6

func (r *Chromium) PaperSizeA6() *Chromium

PaperSizeA6 sets the paper size to A6 format.

func (*Chromium) PaperSizeLetter

func (r *Chromium) PaperSizeLetter() *Chromium

PaperSizeLetter sets the paper size to Letter format.

func (*Chromium) PaperWidth

func (r *Chromium) PaperWidth(value float64) *Chromium

PaperWidth sets the paper width in inches.

func (*Chromium) Param

func (r *Chromium) Param(key, value string) *Chromium

Param adds a form parameter to the conversion request.

func (*Chromium) PreferCssPageSize

func (r *Chromium) PreferCssPageSize() *Chromium

PreferCssPageSize sets whether to prefer page size as defined by CSS.

func (*Chromium) PrintBackground

func (r *Chromium) PrintBackground() *Chromium

PrintBackground sets whether to print the background graphics.

func (*Chromium) Scale

func (r *Chromium) Scale(value float64) *Chromium

Scale sets the scale of the page rendering.

func (*Chromium) ScreenshotClip

func (r *Chromium) ScreenshotClip(clip bool) *Chromium

ScreenshotClip defines whether to clip the screenshot according to the device dimensions.

func (*Chromium) ScreenshotFormat

func (r *Chromium) ScreenshotFormat(format string) *Chromium

ScreenshotFormat sets the image compression format.

func (*Chromium) ScreenshotHTML

func (r *Chromium) ScreenshotHTML(ctx context.Context, html io.Reader) *Chromium

ScreenshotHTML creates a request to take a screenshot of HTML content.

func (*Chromium) ScreenshotHeight

func (r *Chromium) ScreenshotHeight(height int) *Chromium

ScreenshotHeight sets the device screen height in pixels.

func (*Chromium) ScreenshotMarkdown

func (r *Chromium) ScreenshotMarkdown(ctx context.Context, html io.Reader) *Chromium

ScreenshotMarkdown creates a request to take a screenshot of Markdown content.

func (*Chromium) ScreenshotOmitBackground

func (r *Chromium) ScreenshotOmitBackground(omit bool) *Chromium

ScreenshotOmitBackground hides the default white background and allows generating screenshots with transparency.

func (*Chromium) ScreenshotOptimizeForSpeed

func (r *Chromium) ScreenshotOptimizeForSpeed(optimize bool) *Chromium

ScreenshotOptimizeForSpeed defines whether to optimize image encoding for speed, not for resulting size.

func (*Chromium) ScreenshotQuality

func (r *Chromium) ScreenshotQuality(quality int) *Chromium

ScreenshotQuality sets the compression quality from range 0 to 100 (jpeg only).

func (*Chromium) ScreenshotURL

func (r *Chromium) ScreenshotURL(ctx context.Context, url string) *Chromium

ScreenshotURL creates a request to take a screenshot of a web page at the given URL.

func (*Chromium) ScreenshotWidth

func (r *Chromium) ScreenshotWidth(width int) *Chromium

ScreenshotWidth sets the device screen width in pixels.

func (*Chromium) Send

func (r *Chromium) Send() (*gotenberg.Response, error)

Send executes the conversion request and returns the response. Returns an error if the request fails or the conversion cannot be completed.

func (*Chromium) SinglePage

func (r *Chromium) SinglePage() *Chromium

SinglePage sets whether to print the entire content in one single page.

func (*Chromium) Timeout added in v1.8.2

func (r *Chromium) Timeout(duration time.Duration) *Chromium

Timeout sets a timeout for the request.

func (*Chromium) Trace

func (r *Chromium) Trace(trace string) *Chromium

Trace sets the request trace identifier for debugging and monitoring. If not set, Gotenberg will assign a unique UUID trace.

func (*Chromium) WaitDelay

func (r *Chromium) WaitDelay(value string) *Chromium

WaitDelay sets the duration to wait when loading an HTML document before converting it into PDF.

func (*Chromium) WaitForExpression

func (r *Chromium) WaitForExpression(value string) *Chromium

WaitForExpression sets the JavaScript expression to wait before converting an HTML document into PDF until it returns true.

func (*Chromium) WebhookErrorURL

func (r *Chromium) WebhookErrorURL(url, method string) *Chromium

WebhookErrorURL sets the webhook URL and HTTP method for failed conversions.

func (*Chromium) WebhookHeader

func (r *Chromium) WebhookHeader(key, value string) *Chromium

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

func (r *Chromium) WebhookURL(url, method string) *Chromium

WebhookURL sets the webhook URL and HTTP method for successful conversions.

Jump to

Keyboard shortcuts

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