fah/utils.go

40 lines
710 B
Go
Raw Normal View History

package main
import (
"fmt"
"os"
"os/exec"
)
func check(e error) bool {
if e != nil {
fmt.Println(e)
return false
}
return true
}
func fileExists(filename string) bool {
info, err := os.Stat(filename)
if os.IsNotExist(err) {
return false
}
return !info.IsDir()
}
func fileToString(filename string) string {
b, err := os.ReadFile(filename)
check(err)
return string(b)
}
func makepdf(odtdatei string) {
cmd := exec.Command("/usr/lib/libreoffice/program/soffice.bin", "--headless", "--convert-to", "pdf", "--outdir", "./www/data", odtdatei)
output, err := cmd.Output()
if err != nil {
fmt.Println("Fehler beim Ausführen des Befehls:", err)
return
}
fmt.Println(string(output))
}