From 953a1601e6029c99ec61842e68d1f25fffd4c109 Mon Sep 17 00:00:00 2001 From: Minho Date: Sat, 13 May 2017 12:15:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96pdf=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/document.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/controllers/document.go b/controllers/document.go index e9dc0760..e19a6ce4 100644 --- a/controllers/document.go +++ b/controllers/document.go @@ -760,9 +760,8 @@ func (c *DocumentController) Export() { pdfpath := "cache/" + identify + "_" + c.CruSession.SessionID() + ".pdf" if _,err := os.Stat(pdfpath); os.IsNotExist(err){ - paths := make([]string, len(docs)) - index := 0 + wkhtmltopdf.SetPath(beego.AppConfig.String("wkhtmltopdf")) pdfg, err := wkhtmltopdf.NewPDFGenerator() if err != nil { @@ -771,7 +770,9 @@ func (c *DocumentController) Export() { } for e := pathList.Front(); e != nil; e = e.Next() { - pdfg.AddPage(wkhtmltopdf.NewPage(paths[index])) + if page,ok := e.Value.(string); ok { + pdfg.AddPage(wkhtmltopdf.NewPage(page)) + } } err = pdfg.Create() if err != nil {