unoconv

package
v7.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 9 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) PDF

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

PDF converts a document to PDF. 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.

func (*Unoconv) Provision

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

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

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