windows export pdf
This commit is contained in:
@ -447,7 +447,11 @@ func (c Note) ExportPdf(noteId string) revel.Result {
|
|||||||
binPath := configService.GetGlobalStringConfig("exportPdfBinPath")
|
binPath := configService.GetGlobalStringConfig("exportPdfBinPath")
|
||||||
// 默认路径
|
// 默认路径
|
||||||
if binPath == "" {
|
if binPath == "" {
|
||||||
binPath = "/usr/local/bin/wkhtmltopdf"
|
if runtime.GOOS == "windows" {
|
||||||
|
binPath = `C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe`
|
||||||
|
} else {
|
||||||
|
binPath = "/usr/local/bin/wkhtmltopdf"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
url := configService.GetSiteUrl() + "/note/toPdf?noteId=" + noteId + "&appKey=" + appKey
|
url := configService.GetSiteUrl() + "/note/toPdf?noteId=" + noteId + "&appKey=" + appKey
|
||||||
@ -457,15 +461,28 @@ func (c Note) ExportPdf(noteId string) revel.Result {
|
|||||||
// http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf_0.10.0_rc2-doc.html
|
// http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf_0.10.0_rc2-doc.html
|
||||||
// wkhtmltopdf参数大全
|
// wkhtmltopdf参数大全
|
||||||
var cc string
|
var cc string
|
||||||
|
// var cc []string
|
||||||
|
var ccWindows []string
|
||||||
if note.IsMarkdown {
|
if note.IsMarkdown {
|
||||||
cc = binPath + " --lowquality --window-status done \"" + url + "\" \"" + path + "\"" // \"" + cookieDomain + "\" \"" + cookieName + "\" \"" + cookieValue + "\""
|
cc = binPath + " --lowquality --window-status done \"" + url + "\" \"" + path + "\"" // \"" + cookieDomain + "\" \"" + cookieName + "\" \"" + cookieValue + "\""
|
||||||
|
// cc = []string{binPath, "--lowquality", "--window-status", "done", "\"" + url + "\"", "\"" + path + "\""}
|
||||||
|
ccWindows = []string{"/C", binPath, "--lowquality", "--window-status", "done", url, path}
|
||||||
} else {
|
} else {
|
||||||
cc = binPath + " --lowquality \"" + url + "\" \"" + path + "\"" // \"" + cookieDomain + "\" \"" + cookieName + "\" \"" + cookieValue + "\""
|
cc = binPath + " --lowquality \"" + url + "\" \"" + path + "\"" // \"" + cookieDomain + "\" \"" + cookieName + "\" \"" + cookieValue + "\""
|
||||||
|
// cc = []string{binPath, "--lowquality", "\"" + url + "\"", "\"" + path + "\""}
|
||||||
|
ccWindows = []string{"/C", binPath, "--lowquality", url, path}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command("/bin/sh", "-c", cc)
|
var cmd *exec.Cmd
|
||||||
if runtime.GOARCH == "windows" {
|
|
||||||
cmd = exec.Command("cmd", "/C", cc)
|
// fmt.Println("-------1", runtime.GOOS, ccWindows)
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
fmt.Println(ccWindows)
|
||||||
|
// cmd = exec.Command("cmd", ccWindows...)
|
||||||
|
cmd = exec.Command(ccWindows[1], ccWindows[2:]...)
|
||||||
|
} else {
|
||||||
|
fmt.Println(cc)
|
||||||
|
cmd = exec.Command("/bin/sh", "-c", cc)
|
||||||
}
|
}
|
||||||
_, err := cmd.Output()
|
_, err := cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<input type="text" class="form-control" placeholder="/usr/local/bin/wkhtmltopdf" name="path" value="{{.str.exportPdfBinPath}}">
|
<input type="text" class="form-control" placeholder="/usr/local/bin/wkhtmltopdf" name="path" value="{{.str.exportPdfBinPath}}">
|
||||||
Leanote use <a target="_blank" href="http://wkhtmltopdf.org">wkhtmltopdf</a> to export pdf. You should install it on your server.
|
Leanote use <a target="_blank" href="http://wkhtmltopdf.org">wkhtmltopdf</a> to export pdf. You should install it on your server.
|
||||||
<br />
|
<br />
|
||||||
Please input the path that wkhtmltopdf installed, e.g. <code>/usr/local/bin/wkhtmltopdf</code>
|
Please input the path that wkhtmltopdf installed, e.g. <code>/usr/local/bin/wkhtmltopdf</code> on mac os/linux or <code><C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe/code> on windows.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@ cd..
|
|||||||
set SCRIPTPATH=%cd%
|
set SCRIPTPATH=%cd%
|
||||||
|
|
||||||
: top src directory
|
: top src directory
|
||||||
set path="%SCRIPTPATH%\bin\src\github.com\leanote"
|
set leanotePath="%SCRIPTPATH%\bin\src\github.com\leanote"
|
||||||
|
|
||||||
if not exist "%path%" mkdir "%path%"
|
if not exist "%leanotePath%" mkdir "%leanotePath%"
|
||||||
|
|
||||||
: create software link
|
: create software link
|
||||||
if exist "%path%\leanote" del /Q "%path%\leanote"
|
if exist "%leanotePath%\leanote" del /Q "%leanotePath%\leanote"
|
||||||
mklink /D "%path%\leanote" %SCRIPTPATH%
|
mklink /D "%leanotePath%\leanote" %SCRIPTPATH%
|
||||||
|
|
||||||
: set GOPATH
|
: set GOPATH
|
||||||
set GOPATH="%SCRIPTPATH%\bin"
|
set GOPATH="%SCRIPTPATH%\bin"
|
||||||
|
Reference in New Issue
Block a user