pdfengines

package
v1.7.1 Latest Latest
Warning

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

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

Documentation

Overview

Package pdfengines provides a client for the Gotenberg PDF Engines service. It offers a convenient API for converting PDFs to PDF/A & PDF/UA, reading/writing metadata, merging, splitting, and flattening PDFs.

Index

Constants

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"
	HeaderOutputFilename          = "Gotenberg-Output-Filename"
	HeaderGotenbergTrace          = "Gotenberg-Trace"
)
View Source
const (
	FieldPdfa       = "pdfa"
	FieldPdfua      = "pdfua"
	FieldMetadata   = "metadata"
	FieldSplitMode  = "splitMode"
	FieldSplitSpan  = "splitSpan"
	FieldSplitUnify = "splitUnify"
	FieldFlatten    = "flatten"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PDFEngines

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

PDFEngines represents a Gotenberg conversion request builder. It wraps the underlying multipart request and provides PDF Engines-specific methods.

func NewPDFEngines

func NewPDFEngines(client *httpclient.Client) *PDFEngines

func (*PDFEngines) Bool

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

Bool adds a boolean form parameter to the request.

func (*PDFEngines) Convert

func (r *PDFEngines) Convert(ctx context.Context) *PDFEngines

Convert creates a request to convert PDFs to PDF/A & PDF/UA.

func (*PDFEngines) DownloadFrom

func (r *PDFEngines) DownloadFrom(data any) *PDFEngines

DownloadFrom sets the download from configuration.

func (*PDFEngines) File

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

File adds a file to the request.

func (*PDFEngines) Flatten

func (r *PDFEngines) Flatten(ctx context.Context) *PDFEngines

Flatten creates a request to flatten PDFs.

func (*PDFEngines) FlattenPDF

func (r *PDFEngines) FlattenPDF(flatten bool) *PDFEngines

Flatten sets the flatten flag.

func (*PDFEngines) Header

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

Header adds a header to the request.

func (*PDFEngines) Merge

func (r *PDFEngines) Merge(ctx context.Context) *PDFEngines

Merge creates a request to merge PDFs.

func (*PDFEngines) Metadata

func (r *PDFEngines) Metadata(metadata map[string]any) *PDFEngines

Metadata sets the metadata for the PDF.

func (*PDFEngines) MetadataRead

func (r *PDFEngines) MetadataRead(ctx context.Context) *PDFEngines

MetadataRead creates a request to read metadata from PDFs.

func (*PDFEngines) MetadataWrite

func (r *PDFEngines) MetadataWrite(ctx context.Context) *PDFEngines

MetadataWrite creates a request to write metadata to PDFs.

func (*PDFEngines) OutputFilename

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

OutputFilename sets the output filename.

func (*PDFEngines) PDFA

func (r *PDFEngines) PDFA(pdfa string) *PDFEngines

PDFA converts to PDF/A format.

func (*PDFEngines) PDFUA

func (r *PDFEngines) PDFUA(pdfua bool) *PDFEngines

PDFUA enables PDF for Universal Access.

func (*PDFEngines) Param

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

Param adds a form parameter to the request.

func (*PDFEngines) Send

func (r *PDFEngines) Send() (*Response, error)

Send executes the request and returns the response. Returns an error if the request fails.

func (*PDFEngines) Split

func (r *PDFEngines) Split(ctx context.Context) *PDFEngines

Split creates a request to split PDFs.

func (*PDFEngines) SplitMode

func (r *PDFEngines) SplitMode(mode string) *PDFEngines

SplitMode sets the split mode.

func (*PDFEngines) SplitSpan

func (r *PDFEngines) SplitSpan(span string) *PDFEngines

SplitSpan sets the split span.

func (*PDFEngines) SplitUnify

func (r *PDFEngines) SplitUnify(unify bool) *PDFEngines

SplitUnify specifies whether to unify split pages.

func (*PDFEngines) Trace

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

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

func (*PDFEngines) WebhookErrorURL

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

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

func (*PDFEngines) WebhookHeader

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

WebhookHeader adds a custom header to be sent with webhook requests. Multiple headers can be added by calling this method multiple times.

func (*PDFEngines) WebhookURL

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

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

type Response

type Response struct {
	*http.Response
	GotenbergTrace string
}

Response represents a Gotenberg conversion response. It wraps the HTTP response and provides access to the Gotenberg trace header.

Jump to

Keyboard shortcuts

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