|
|
|
@ -5,6 +5,7 @@ import (
|
|
|
|
|
"compress/gzip"
|
|
|
|
|
"fmt"
|
|
|
|
|
"moredoc/util"
|
|
|
|
|
"moredoc/util/command"
|
|
|
|
|
"os"
|
|
|
|
|
"os/exec"
|
|
|
|
|
"path/filepath"
|
|
|
|
@ -121,7 +122,7 @@ func (c *Converter) ConvertPDFToTxt(src string) (dst string, err error) {
|
|
|
|
|
src,
|
|
|
|
|
}
|
|
|
|
|
c.logger.Info("convert pdf to txt", zap.String("cmd", mutool), zap.Strings("args", args))
|
|
|
|
|
_, err = util.ExecCommand(mutool, args, c.timeout)
|
|
|
|
|
_, err = command.ExecCommand(mutool, args, c.timeout)
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.logger.Error("convert pdf to txt", zap.String("cmd", mutool), zap.Strings("args", args), zap.Error(err))
|
|
|
|
|
return
|
|
|
|
@ -190,7 +191,7 @@ func (c *Converter) convertPDFToPage(src string, fromPage, toPage int, ext strin
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c.logger.Info("convert pdf to page", zap.String("cmd", mutool), zap.Strings("args", args))
|
|
|
|
|
_, err = util.ExecCommand(mutool, args, c.timeout)
|
|
|
|
|
_, err = command.ExecCommand(mutool, args, c.timeout)
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.logger.Error("convert pdf to page", zap.String("cmd", mutool), zap.Strings("args", args), zap.Error(err))
|
|
|
|
|
return
|
|
|
|
@ -222,7 +223,7 @@ func (c *Converter) convertToPDFBySoffice(src string) (dst string, err error) {
|
|
|
|
|
}
|
|
|
|
|
args = append(args, src)
|
|
|
|
|
c.logger.Info("convert to pdf by soffice", zap.String("cmd", soffice), zap.Strings("args", args))
|
|
|
|
|
_, err = util.ExecCommand(soffice, args, c.timeout)
|
|
|
|
|
_, err = command.ExecCommand(soffice, args, c.timeout)
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.logger.Error("convert to pdf by soffice", zap.String("cmd", soffice), zap.Strings("args", args), zap.Error(err))
|
|
|
|
|
}
|
|
|
|
@ -244,7 +245,7 @@ func (c *Converter) convertToPDFByCalibre(src string) (dst string, err error) {
|
|
|
|
|
}
|
|
|
|
|
os.MkdirAll(filepath.Dir(dst), os.ModePerm)
|
|
|
|
|
c.logger.Info("convert to pdf by calibre", zap.String("cmd", ebookConvert), zap.Strings("args", args))
|
|
|
|
|
_, err = util.ExecCommand(ebookConvert, args, c.timeout)
|
|
|
|
|
_, err = command.ExecCommand(ebookConvert, args, c.timeout)
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.logger.Error("convert to pdf by calibre", zap.String("cmd", ebookConvert), zap.Strings("args", args), zap.Error(err))
|
|
|
|
|
}
|
|
|
|
@ -259,7 +260,7 @@ func (c *Converter) CountPDFPages(file string) (pages int, err error) {
|
|
|
|
|
}
|
|
|
|
|
c.logger.Info("count pdf pages", zap.String("cmd", mutool), zap.Strings("args", args))
|
|
|
|
|
var out string
|
|
|
|
|
out, err = util.ExecCommand(mutool, args, c.timeout)
|
|
|
|
|
out, err = command.ExecCommand(mutool, args, c.timeout)
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.logger.Error("count pdf pages", zap.String("cmd", mutool), zap.Strings("args", args), zap.Error(err))
|
|
|
|
|
return
|
|
|
|
@ -307,7 +308,7 @@ func (c *Converter) CompressSVGBySVGO(svgFolder string) (err error) {
|
|
|
|
|
}
|
|
|
|
|
c.logger.Info("compress svg by svgo", zap.String("cmd", svgo), zap.Strings("args", args))
|
|
|
|
|
var out string
|
|
|
|
|
out, err = util.ExecCommand(svgo, args, c.timeout*10)
|
|
|
|
|
out, err = command.ExecCommand(svgo, args, c.timeout*10)
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.logger.Error("compress svg by svgo", zap.String("cmd", svgo), zap.Strings("args", args), zap.Error(err))
|
|
|
|
|
}
|
|
|
|
|