gotenberg-go-client icon indicating copy to clipboard operation
gotenberg-go-client copied to clipboard

failed to generate the result PDF

Open unstppbl opened this issue 5 years ago • 1 comments

Why would I receive failed to generate the result PDF error? Running gotenberg in docker-compose, and sending pdf generation request from other service like so:

index, err := gotenberg.NewDocumentFromPath(filename, sourceHTMLPath)
	if err != nil {
		return fmt.Errorf("Error getting document from path: %s", err)
	}
	style, err := gotenberg.NewDocumentFromPath("styles.css", m.cfg.Get("pdf", "stylesPath").String(""))
	if err != nil {
		return fmt.Errorf("Error getting document from path: %s", err)
	}

	font1, err := gotenberg.NewDocumentFromPath("Gilroy-Bold.woff", m.cfg.Get("pdf", "font1path").String(""))
	if err != nil {
		return fmt.Errorf("Error getting document from path: %s", err)
	}

	font2, err := gotenberg.NewDocumentFromPath("Gilroy-ExtraBold.woff", m.cfg.Get("pdf", "font2path").String(""))
	if err != nil {
		return fmt.Errorf("Error getting document from path: %s", err)
	}

	font3, err := gotenberg.NewDocumentFromPath("Gilroy-Light.woff", m.cfg.Get("pdf", "font3path").String(""))
	if err != nil {
		return fmt.Errorf("Error getting document from path: %s", err)
	}

	font4, err := gotenberg.NewDocumentFromPath("Gilroy-Medium.woff", m.cfg.Get("pdf", "font4path").String(""))
	if err != nil {
		return fmt.Errorf("Error getting document from path: %s", err)
	}

	req := gotenberg.NewHTMLRequest(index)

	req.Assets(style, font1, font2, font3, font4)
	req.Margins(gotenberg.NoMargins)
	req.PaperSize(gotenberg.A4)

	if err := m.pdfClient.Store(req, outputPDFPath); err != nil {
		return fmt.Errorf("Error generating pdf: %s", err)
	}

unstppbl avatar Sep 22 '20 08:09 unstppbl

I had created a pull request to fix this bug. https://github.com/thecodingmachine/gotenberg-go-client/pull/34

khndhkx123 avatar Aug 11 '22 10:08 khndhkx123