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 ( // ErrInvalidPdfFormats happens if the PDF formats option cannot be handled // by LibreOffice. ErrInvalidPdfFormats = errors.New("invalid PDF formats") // ErrUnoException happens when unoconverter returns an exit code 5. ErrUnoException = errors.New("uno exception") // ErrRuntimeException happens when unoconverter returns an exit code 6. ErrRuntimeException = errors.New("uno exception") // ErrCoreDumped happens randomly; sometime a conversion will work as // expected, and some other time the same conversion will fail. // See https://github.com/gotenberg/gotenberg/issues/639. ErrCoreDumped = errors.New("core dumped") )
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 { // Password specifies the password for opening the source file. Password string // Landscape allows to change the orientation of the resulting PDF. Landscape bool // PageRanges allows to select the pages to convert. PageRanges string // ExportFormFields specifies whether form fields are exported as widgets // or only their fixed print representation is exported. ExportFormFields bool // AllowDuplicateFieldNames specifies whether multiple form fields exported // are allowed to have the same field name. AllowDuplicateFieldNames bool // ExportBookmarks specifies if bookmarks are exported to PDF. ExportBookmarks bool // ExportBookmarksToPdfDestination specifies that the bookmarks contained // in the source LibreOffice file should be exported to the PDF file as // Named Destination. ExportBookmarksToPdfDestination bool // ExportPlaceholders exports the placeholders fields visual markings only. // The exported placeholder is ineffective. ExportPlaceholders bool // ExportNotes specifies if notes are exported to PDF. ExportNotes bool // ExportNotesPages specifies if notes pages are exported to PDF. // Notes pages are available in Impress documents only. ExportNotesPages bool // ExportOnlyNotesPages specifies, if the property ExportNotesPages is set // to true, if only notes pages are exported to PDF. ExportOnlyNotesPages bool // ExportNotesInMargin specifies if notes in margin are exported to PDF. ExportNotesInMargin bool // ConvertOooTargetToPdfTarget specifies that the target documents with // .od[tpgs] extension, will have that extension changed to .pdf when the // link is exported to PDF. The source document remains untouched. ConvertOooTargetToPdfTarget bool // ExportLinksRelativeFsys specifies that the file system related // hyperlinks (file:// protocol) present in the document will be exported // as relative to the source document location. ExportLinksRelativeFsys bool // ExportHiddenSlides exports, for LibreOffice Impress, slides that are not // included in slide shows. ExportHiddenSlides bool // SkipEmptyPages specifies that automatically inserted empty pages are // suppressed. This option is active only if storing Writer documents. SkipEmptyPages bool // AddOriginalDocumentAsStream specifies that a stream is inserted to the // PDF file which contains the original document for archiving purposes. AddOriginalDocumentAsStream bool // SinglePageSheets ignores each sheet’s paper size, print ranges and // shown/hidden status and puts every sheet (even hidden sheets) on exactly // one page. SinglePageSheets bool // LosslessImageCompression specifies if images are exported to PDF using // a lossless compression format like PNG or compressed using the JPEG // format. LosslessImageCompression bool // Quality specifies the quality of the JPG export. A higher value produces // a higher-quality image and a larger file. Between 1 and 100. Quality int // ReduceImageResolution specifies if the resolution of each image is // reduced to the resolution specified by the property MaxImageResolution. ReduceImageResolution bool // MaxImageResolution, if the property ReduceImageResolution is set to // true, tells if all images will be reduced to the given value in DPI. // Possible values are: 75, 150, 300, 600 and 1200. MaxImageResolution int // PdfFormats allows to convert the resulting PDF to PDF/A-1b, PDF/A-2b, // PDF/A-3b and PDF/UA. PdfFormats gotenberg.PdfFormats }
Options gathers available options when converting a document to PDF. See: https://help.libreoffice.org/latest/en-US/text/shared/guide/pdf_params.html.
func DefaultOptions ¶ added in v8.8.0
func DefaultOptions() Options
DefaultOptions returns the default values for Options.
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)