Documentation
¶
Overview ¶
Package unoconv provides a module which abstracts the CLI tool unoconv.
Index ¶
- Variables
- type API
- type Options
- type Provider
- type Unoconv
- func (Unoconv) Descriptor() gotenberg.ModuleDescriptor
- func (mod Unoconv) Extensions() []string
- func (mod Unoconv) Metrics() ([]gotenberg.Metric, error)
- func (mod Unoconv) PDF(ctx context.Context, logger *zap.Logger, inputPath, outputPath string, ...) error
- func (mod *Unoconv) Provision(_ *gotenberg.Context) error
- func (mod Unoconv) Unoconv() (API, error)
- func (mod Unoconv) Validate() error
Constants ¶
This section is empty.
Variables ¶
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.
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 ¶
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 ¶
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 ¶
Provision sets the module properties. It returns an error if the environment variable UNOCONV_BIN_PATH is not set.