Documentation ¶
Overview ¶
Package api provides a module which manages a LibreOffice instance and interacts with it via the UNO (Universal Network Objects) API.
Index ¶
- Variables
- type Api
- func (a *Api) Checks() ([]health.CheckerOption, error)
- func (a *Api) Descriptor() gotenberg.ModuleDescriptor
- func (a *Api) Extensions() []string
- func (a *Api) LibreOffice() (Uno, error)
- func (a *Api) Metrics() ([]gotenberg.Metric, error)
- func (a *Api) Pdf(ctx context.Context, logger *zap.Logger, inputPath, outputPath string, ...) error
- func (a *Api) Provision(ctx *gotenberg.Context) error
- func (a *Api) Ready() error
- func (a *Api) Start() error
- func (a *Api) StartupMessage() string
- func (a *Api) Stop(ctx context.Context) error
- func (a *Api) Validate() error
- type ApiMock
- type Options
- type Provider
- type ProviderMock
- type Uno
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 struct {
// contains filtered or unexported fields
}
Api is a module which provides a Uno to interact with LibreOffice.
func (*Api) Checks ¶
func (a *Api) Checks() ([]health.CheckerOption, error)
Checks adds a health check that verifies if LibreOffice is healthy.
func (*Api) Descriptor ¶
func (a *Api) Descriptor() gotenberg.ModuleDescriptor
Descriptor returns a Api's module descriptor.
func (*Api) Extensions ¶
Extensions returns the file extensions available for conversions. FIXME: don't care, take all on the route level?
func (*Api) LibreOffice ¶
LibreOffice returns a Uno for interacting with LibreOffice.
func (*Api) Pdf ¶
func (a *Api) Pdf(ctx context.Context, logger *zap.Logger, inputPath, outputPath string, options Options) error
Pdf converts a document to PDF.
func (*Api) Start ¶
Start does nothing if auto-start is not enabled. Otherwise, it starts a LibreOffice instance.
func (*Api) StartupMessage ¶
StartupMessage returns a custom startup message.
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 Uno 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. // Optional. PageRanges string // PdfFormats allows to convert the resulting PDF to PDF/A-1b, PDF/A-2b, // PDF/A-3b and PDF/UA. // Optional. PdfFormats gotenberg.PdfFormats }
Options gathers available options when converting a document to PDF.
type Provider ¶
Provider is a module interface which exposes a method for creating a Uno for other modules.
func (m *YourModule) Provision(ctx *gotenberg.Context) error { provider, _ := ctx.Module(new(libreofficeapi.Provider)) libreOffice, _ := provider.(api.Provider).LibreOffice() }
type ProviderMock ¶
ProviderMock is a mock for the Provider interface.
func (*ProviderMock) LibreOffice ¶
func (provider *ProviderMock) LibreOffice() (Uno, error)