Documentation
¶
Overview ¶
Package uno provides a module which interacts with the UNO (Universal Network Objects) API.
Index ¶
- Variables
- type API
- type APIMock
- type Options
- type Provider
- type ProviderMock
- type UNO
- func (mod UNO) Checks() ([]health.CheckerOption, error)
- func (UNO) Descriptor() gotenberg.ModuleDescriptor
- func (mod UNO) Extensions() []string
- func (mod UNO) Metrics() ([]gotenberg.Metric, error)
- func (mod UNO) PDF(ctx context.Context, logger *zap.Logger, inputPath, outputPath string, ...) error
- func (mod *UNO) Provision(ctx *gotenberg.Context) error
- func (mod UNO) Start() error
- func (mod UNO) StartupMessage() string
- func (mod UNO) Stop(ctx context.Context) error
- func (mod UNO) UNO() (API, error)
- func (mod UNO) Validate() error
Constants ¶
This section is empty.
Variables ¶
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") )
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 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 ¶
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 ¶
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 ¶
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 ¶
Extensions returns the file extensions available for conversions.
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 ¶
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 ¶
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 ¶
StartupMessage returns a custom startup message.