v7.5.4 Latest Latest

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

Go to latest
Published: Aug 19, 2022 License: MIT Imports: 14 Imported by: 0



Package uno provides a module which interacts with the UNO (Universal Network Objects) API.



This section is empty.


View Source
var (
	// ErrInvalidPDFformat happens if the PDF format option cannot be handled
	// by LibreOffice.
	ErrInvalidPDFformat = errors.New("invalid PDF format")

	// ErrMalformedPageRanges happens if the page ranges option cannot be
	// interpreted by LibreOffice.
	ErrMalformedPageRanges = errors.New("page ranges are malformed")


This section is empty.


type API

type API interface {
	PDF(ctx context.Context, logger *zap.Logger, inputPath, outputPath string, options Options) error
	Extensions() []string

API is an abstraction on top of uno.

type APIMock

type APIMock struct {
	PDFMock        func(ctx context.Context, logger *zap.Logger, inputPath, outputPath string, options Options) error
	ExtensionsMock func() []string

APIMock is a mock for the API interface.

func (APIMock) Extensions

func (api APIMock) Extensions() []string

func (APIMock) PDF

func (api APIMock) PDF(ctx context.Context, logger *zap.Logger, inputPath, outputPath string, options Options) error

type Options

type Options struct {
	// Landscape allows to change the orientation of the resulting PDF.
	// Optional.
	Landscape bool

	// PageRanges allows to select the pages to convert.
	// TODO: should prefer a method form PDFEngine.
	// Optional.
	PageRanges string

	// PDFformat allows to convert the resulting PDF to PDF/A-1a, PDF/A-2b, or
	// PDF/A-3b.
	// Optional.
	PDFformat string

Options gathers available options when converting a document to PDF.

type Provider

type Provider interface {
	UNO() (API, error)

Provider is a module interface which exposes a method for creating an API for other modules.

func (m *YourModule) Provision(ctx *gotenberg.Context) error {
	provider, _ := ctx.Module(new(uno.Provider))
	unoAPI, _      := provider.(uno.Provider).UNO()

type ProviderMock

type ProviderMock struct {
	UNOMock func() (API, error)

ProviderMock is a mock for the Provider interface.

func (ProviderMock) UNO

func (provider ProviderMock) UNO() (API, error)

type UNO

type UNO struct {
	// contains filtered or unexported fields

UNO is a module which provides an API to interact with LibreOffice.

func (UNO) Checks

func (mod UNO) Checks() ([]health.CheckerOption, error)

Checks adds a health check that verifies the health of the long-running LibreOffice listener.

func (UNO) Descriptor

func (UNO) Descriptor() gotenberg.ModuleDescriptor

Descriptor returns a UNO's module descriptor.

func (UNO) Extensions

func (mod UNO) Extensions() []string

Extensions returns the file extensions available for conversions.

func (UNO) Metrics

func (mod UNO) Metrics() ([]gotenberg.Metric, error)

Metrics returns the metrics.

func (UNO) PDF

func (mod UNO) PDF(ctx context.Context, logger *zap.Logger, inputPath, outputPath string, options Options) error

PDF converts a document to PDF.

If there is no long-running LibreOffice listener, it creates a dedicated LibreOffice instance for the conversion. Substantial calls to this method may increase CPU and memory usage drastically

If there is a long-running LibreOffice listener, the conversion performance improves substantially. However, it cannot perform parallel operations.

func (*UNO) Provision

func (mod *UNO) Provision(ctx *gotenberg.Context) error

Provision sets the module properties. It returns an error if the environment variables UNOCONV_BIN_PATH and LIBREOFFICE_BIN_PATH are not set.

func (UNO) Start

func (mod UNO) Start() error

Start does nothing: it is here to validate the contract from the gotenberg.App interface. The long-running LibreOffice Listener will be started on the first call to PDF.

func (UNO) StartupMessage

func (mod UNO) StartupMessage() string

StartupMessage returns a custom startup message.

func (UNO) Stop

func (mod UNO) Stop(ctx context.Context) error

Stop stops the long-running LibreOffice Listener if it exists.

func (UNO) UNO

func (mod UNO) UNO() (API, error)

UNO returns an API for interacting with LibreOffice.

func (UNO) Validate

func (mod UNO) Validate() error

Validate validates the module properties.

Jump to

Keyboard shortcuts

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