fix(handlers): Return cards as pdf

This commit is contained in:
Nicolai Ort 2024-12-03 19:04:09 +01:00
parent 5098d27ae9
commit b179541532
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F

View File

@ -62,17 +62,16 @@ func GenerateCard(c *fiber.Ctx) error {
})
}
c.Set(fiber.HeaderContentType, "text/html")
return c.SendString(result)
// converter := services.GotenbergConverter{BaseUrl: "http://localhost:3001"}
// pdf, err := converter.ToPdf(result, "a4", false)
// if err != nil {
// return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
// "error": err.Error(),
// })
// }
converter := services.GotenbergConverter{BaseUrl: "http://localhost:3001"}
pdf, err := converter.ToPdf(result, "a4", false)
if err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
"error": err.Error(),
})
}
// c.Set(fiber.HeaderContentType, "application/pdf")
// return c.Send(pdf)
c.Set(fiber.HeaderContentType, "application/pdf")
return c.Send(pdf)
}
func invertCardArrayItems(cards []models.Card) []models.Card {