forked from bigbluebutton/voiceconfmanager
/
hello.go
executable file
·72 lines (66 loc) · 1.62 KB
/
hello.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"fmt"
"log"
"os/exec"
"path/filepath"
"syscall"
)
func ConvertOfficeDocToPdf2(file string) {
args := []string{"-f", "pdf",
"-eSelectPdfVersion=1",
"-eReduceImageResolution=true",
"-eMaxImageResolution=300",
"-p",
"8200",
"-o",
"~/foo1.pdf",
"~/foo.pptx",
}
cmd := exec.Command("unoconv", args...)
var waitStatus syscall.WaitStatus
if err := cmd.Run(); err != nil {
//fmt.Printf("Error:", err)
// Did the command fail because of an unsuccessful exit code
if exitError, ok := err.(*exec.ExitError); ok {
waitStatus = exitError.Sys().(syscall.WaitStatus)
fmt.Printf("Failed: %d", waitStatus.ExitStatus())
}
} else {
// Command was successful
waitStatus = cmd.ProcessState.Sys().(syscall.WaitStatus)
fmt.Printf("Success: %d", waitStatus.ExitStatus())
}
}
func ConvertOfficeDocToPdf(file string) {
args := []string{"-f", "pdf",
"-eSelectPdfVersion=1",
"-eReduceImageResolution=true",
"-eMaxImageResolution=300",
"-p",
"8100",
"-o",
"~/foo1.pdf",
"~/foo.pptx",
}
path, err := exec.LookPath("unoconv")
if err != nil {
log.Fatal("installing fortune is in your future")
}
fmt.Printf("unoconv is available at %s\n", path)
out, err := exec.Command("unoconv", args...).Output()
if err != nil {
log.Fatal("Error: ", err)
} else {
fmt.Printf("Success: %s\n", out)
}
}
func GetFilenameExt(filename string) {
extension := filepath.Ext(filename)
name := filename[0 : len(filename)-len(extension)]
fmt.Println(name)
}
func main() {
GetFilenameExt("foo.tex")
ConvertOfficeDocToPdf("foo")
}