mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-09-20 19:07:56 +08:00
优化导出
This commit is contained in:
@@ -593,6 +593,15 @@ func (c *DocumentController) Export() {
|
||||
}
|
||||
|
||||
if output == "pdf" {
|
||||
|
||||
exe := beego.AppConfig.String("wkhtmltopdf")
|
||||
|
||||
if exe == "" {
|
||||
c.TplName = "errors/error.tpl";
|
||||
c.Data["ErrorMessage"] = "没有配置PDF导出程序"
|
||||
c.Data["ErrorCode"] = 50010
|
||||
return
|
||||
}
|
||||
dpath := "cache/" + book.Identify
|
||||
|
||||
os.MkdirAll(dpath, 0766)
|
||||
@@ -606,23 +615,21 @@ func (c *DocumentController) Export() {
|
||||
os.MkdirAll("./cache", 0766)
|
||||
pdfpath := "cache/" + identify + ".pdf"
|
||||
|
||||
paths := make([]string, len(docs))
|
||||
index := 0
|
||||
for e := pathList.Front(); e != nil; e = e.Next() {
|
||||
paths[index] = e.Value.(string)
|
||||
index ++
|
||||
if _,err := os.Stat(pdfpath); os.IsNotExist(err){
|
||||
paths := make([]string, len(docs))
|
||||
index := 0
|
||||
for e := pathList.Front(); e != nil; e = e.Next() {
|
||||
paths[index] = e.Value.(string)
|
||||
index ++
|
||||
}
|
||||
|
||||
beego.Info(paths)
|
||||
|
||||
utils.ConverterHtmlToPdf(paths, pdfpath)
|
||||
}
|
||||
|
||||
beego.Info(paths)
|
||||
|
||||
utils.ConverterHtmlToPdf(paths, pdfpath)
|
||||
|
||||
|
||||
|
||||
c.Ctx.Output.Download(pdfpath, identify + ".pdf")
|
||||
|
||||
defer os.Remove(pdfpath)
|
||||
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user