Using LibreOffice as a server for converting documents.
-
Go 1.20 or later
-
Apache OpenOffice or LibreOffice; the latest stable version is usually recommended.
go get -u github.com/xbmlz/uniconv
package main
import (
"fmt"
"github.com/xbmlz/uniconv"
)
func main() {
// create a new processor, the default port is 2002
p := uniconv.NewProcessor()
// Start an office process and connect to the started instance (on port 2002).
p.Start()
defer p.Stop()
// Convert
c := uniconv.NewConverter()
c.Convert("input.docx", "output.pdf")
}