thecodingmachine/gotenberg-go-client

Try to use the client ,but no feedback...

systemcia opened this issue · 3 comments

Your issue may already be reported!
Please search on the issue tracker before creating one.

Expected Behavior

Current Behavior

Possible Solution

Steps to Reproduce (for bugs)

1.install client and build successfully
2.use client follow the examples:
func main() {
c := &gotenberg.Client{Hostname: "http://172.16.66.38:3000"}
req := gotenberg.NewURLRequest("https://www.baidu.com")
req.SetMargins(gotenberg.NoMargins)
dest := "result.pdf"
c.Store(req, dest)
}

3.but after run the main.go , there's no feedback ,no result.pdf generate in the directory...
4.

Context

Your Environment

  • Version used: go version go1.9.2 windows/amd64
  • Operating System and version: windows10 64bit
  • Link to your project:

If something goes wrong, you should check the returned error. For instance:

func main() {
    c := &gotenberg.Client{Hostname: "http://172.16.66.38:3000"}
    req := gotenberg.NewURLRequest("https://www.baidu.com")
    req.SetMargins(gotenberg.NoMargins)
    dest := "result.pdf"
    err := c.Store(req, dest)
    // do something here with the error
}
  1. I have tried as you said , it show one error :
    $ go run main.go
    header.html: opening file: open : The system cannot find the file specified.
  2. i also executed the curl command :
    curl --request POST --url http://172.16.66.38:3000/convert/url --header 'Content-Type: multipart/form-data' --form remoteURL=https://www.baidu.com -o result_image.pdf
    it's ok .
  3. then i compare the difference and change the code :
    func main() {
    c := &gotenberg.Client{Hostname: "http://172.16.66.38:3000"}
    req := gotenberg.NewURLRequest("https://www.baidu.com")
    req.SetHeader("Content-Type: multipart/form-data")
    req.SetMargins(gotenberg.NoMargins)
    dest := "result.pdf"
    err := c.Store(req, dest)
    fmt.Println(err)
    }
    but also have error:
    $ go run main.go
    header.html: opening file: open Content-Type: multipart/form-data: The filename, directory name, or volume label syntax is incorrect.
  4. at last , i specify the header and footer path , in my code :
    func main() {
    c := &gotenberg.Client{Hostname: "http://172.16.66.38:3000"}
    req := gotenberg.NewURLRequest("https://www.baidu.com")
    req.SetHeader("header.html")
    req.SetFooter("footer.html")

    req.SetMargins(gotenberg.NoMargins)
    dest := "result.pdf"
    err := c.Store(req, dest)
    fmt.Println(err)
    }
    it's ok ...

so i want to know that : must i put the header.html and footer.html in one directory and specify the path in the code ? i think the server side show have the default ones .
and i think the gotenberg instruction document should also clarify this .

@systemcia There was an issue with header and footer. This has been fixed in 4.3.1 😄