2017-07-14 1 views
0

J'essaie de développer une petite application pour convertir html en pdf en utilisant wkhtmltopdf et GoLang. Mais lorsque je tente de passer des arguments à lui, obtenir un statut de sortie 1.Passer des arguments à wkhtmltopdf en utilisant GoLang

args: = [] string { "- 420mm Page hauteur", "- page largeur 297mm", "/path/src/edit.html","/path/src/edit.pdf"} fmt.Println (args) cmd: = exec.Command ("/ home/local/ZOHOCORP/santhosh-4759/Téléchargements/wkhtmltox/bin/wkhtmltopdf », args ...) fmt.Println (cmd)

ouptut de cmd et args

cmd: & {/ chemin/wkhtmltopdf [/ chemin/wkhtmltopdf --page-hauteur 420mm --page largeur 297mm /path/src/edit.html /path/src/edit.pdf ] [] [] false [] [] [] []}

args [--page-hauteur 420mm --page largeur 297mm /path/src/edit.html/chemin/src/modifier. pdf]

Répondre

0

Essayez cette façon, vous devrez remplacer les chemins avec le vôtre

args := []string{"./wkhtmltopdfTest/edit.html","./wkhtmltopdfTest/edit.pdf"} 
cmd := exec.Command("/usr/local/bin/wkhtmltopdf",args...) 

out,err := cmd.CombinedOutput() 

if err == nil { 
    fmt.Printf("PDF succesfully generated") 
} else { 
    fmt.Printf("Error: %s %s", err, out) 
} 

S'il est bon, vous pouvez ajouter les arguments --page

0

Vous pouvez utiliser Go obligatoire pour wkhtmltopdf. Vérifiez this