unoconv

package
v7.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package unoconv provides a module which abstracts the CLI tool unoconv.

Index

Constants

This section is empty.

Variables

View Source
var ErrMalformedPageRanges = errors.New("page ranges are malformed")

ErrMalformedPageRanges happens if the page ranges option cannot be interpreted by LibreOffice.

Functions

This section is empty.

Types

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 unoconv.

See https://github.com/unoconv/unoconv.

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

	// PDFArchive allows to convert the resulting PDF to PDF/A-1a.
	// In a module, prefer the Convert method from the gotenberg.PDFEngine
	// interface.
	// Optional.
	PDFArchive bool
}

Options gathers available options when converting a document to PDF.

type Provider

type Provider interface {
	Unoconv() (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(unoconv.Provider))
	uno, _      := provider.(unoconv.Provider).Unoconv()
}

type Unoconv

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

Unoconv is a module which provides an API to interact with unoconv.

func (Unoconv) Descriptor

func (Unoconv) Descriptor() gotenberg.ModuleDescriptor

Descriptor returns a Unoconv's module descriptor.

func (Unoconv) Extensions

func (mod Unoconv) Extensions() []string

Extensions returns the file extensions available with unoconv.

func (Unoconv) Metrics added in v7.1.0

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

Metrics returns the metrics.

func (Unoconv) PDF

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

PDF converts a document to PDF.

In stateless mode, it creates a dedicated LibreOffice instance thanks to a custom user profile directory and a free port. Substantial calls to this method may increase CPU and memory usage drastically. In such a scenario, the given context may also be done before the end of the conversion.

In listener mode, it calls the unoconv listener to interact with LibreOffice, improving substantially the performance. However, it cannot perform parallel operations and have to wait for the lock to be available.

func (*Unoconv) Provision

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

Provision sets the module properties. It returns an error if the environment variable UNOCONV_BIN_PATH is not set.

func (*Unoconv) Start added in v7.4.0

func (mod *Unoconv) Start() error

func (Unoconv) StartupMessage added in v7.4.0

func (mod Unoconv) StartupMessage() string

StartupMessage returns a custom startup message.

func (*Unoconv) Stop added in v7.4.0

func (mod *Unoconv) Stop(ctx context.Context) error

Stop stops the HTTP server.

func (*Unoconv) Unoconv

func (mod *Unoconv) Unoconv() (API, error)

Unoconv returns an API for interacting with unoconv.

func (Unoconv) Validate

func (mod Unoconv) 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