libreoffice.go 473 B

123456789101112131415161718
  1. package libreoffice
  2. import "os/exec"
  3. func Convert(from, toExt string, options ...string) error {
  4. libreoffice_args := []string{"--headless", "--convert-to", toExt}
  5. libreoffice_args = append(libreoffice_args, options...)
  6. libreoffice_args = append(libreoffice_args, from)
  7. err := exec.Command("libreoffice", libreoffice_args...).Run()
  8. // if string(out) != "" {
  9. // return fmt.Errorf("libreoffice: %s", string(out))
  10. // }
  11. if err != nil {
  12. return err
  13. }
  14. return nil
  15. }