Bouton d'export dans l'interface + nommage du pdf

This commit is contained in:
2020-06-15 15:31:22 -04:00
parent 6ebe4c90d7
commit 47020f7beb
2 changed files with 40 additions and 11 deletions

View File

@ -119,12 +119,6 @@ func handleExportProject(w http.ResponseWriter, r *http.Request) {
log.Fatal(err)
}
// Write buffer contents to file on disk
err = pdfg.WriteFile("./sample.pdf")
if err != nil {
log.Fatal(err)
}
rsp, err := writePDF(w, http.StatusOK, pdfg.Bytes())
if err != nil {
panic(errors.Wrap(err, "could not write pdf response"))
@ -307,7 +301,7 @@ func writeJSON(w http.ResponseWriter, statusCode int, data interface{}) error {
}
func writePDF(w http.ResponseWriter, statusCode int, data []byte) (int, error) {
w.Header().Set("Content-Disposition", "attachment; filename=foo.pdf")
w.Header().Set("Content-Disposition", "attachment; filename=estimation.pdf")
w.Header().Set("Content-Type", "application/pdf")
w.WriteHeader(statusCode)