SebastiaanKlippert / go-wkhtmltopdf

Golang commandline wrapper for wkhtmltopdf
MIT License
1.06k stars 146 forks source link

Question : add constant header and footer #92

Closed georgeroumieh-pon closed 2 years ago

georgeroumieh-pon commented 2 years ago

I have an HTML template and I put it in bytes. Buffer and it returns a pdf. awesome, thank you for your work. I want to add a constant header and footer but it's not working in my local I tried all of this to implement footer but didn't work :
page.FooterHTML.Set("./footer.html") page.FooterHTML.Set("file:///footer.html") thanks in advance

SebastiaanKlippert commented 2 years ago

Can you try page.EnableLocalFileAccess.Set(true)?

georgeroumieh-pon commented 2 years ago

I already added it @SebastiaanKlippert

georgeroumieh-pon commented 2 years ago

I am trying just to test add footer and I put the HTML file in my root folder but always the error : error: Loading pages (1/6) Error: Failed to load http://footer.html/, with network status code 3 and http status code 0 - Host footer.html not found Error: Failed loading page http:/footer.html (sometimes it will work just to ignore this error with --load-error-handling ignore) Exit with code 1 due to network error: HostNotFoundError

SebastiaanKlippert commented 2 years ago

In your example you have two lines calling FooterHTML.Set, is that the same in your code? It is trying to get the file online and not from disk, the file:/// prefix should be OK and work. Are you sure that footer.html is located in the right place? Try an absolute path as well (file:///C:/footer.html) to debug. Is footer.html only containing HTML or scripts as well?

georgeroumieh-pon commented 2 years ago

Thanks, it's working now @SebastiaanKlippert