Comments (9)
Hi, your code looks fine.
I have tested this in my own tests by modifying test TestPDFGeneratorOutputFile to
func TestPDFGeneratorOutputFile(t *testing.T) {
pdfg, err := NewPDFGenerator()
if err != nil {
t.Fatal(err)
}
htmlfile, err := os.Open("./testfiles/htmlsimple.html")
if err != nil {
t.Fatal(err)
}
defer htmlfile.Close()
pdfg.OutputFile = "./testfiles/TestPDFGeneratorOutputFile.pdf"
page := NewPageReader(htmlfile)
page.FooterRight.Set("[page]")
page.FooterFontSize.Set(10)
pdfg.AddPage(page)
err = pdfg.Create()
if err != nil {
t.Fatal(err)
}
pdfFile, err := os.Open("./testfiles/TestPDFGeneratorOutputFile.pdf")
if err != nil {
t.Fatal(err)
}
defer pdfFile.Close()
stat, err := pdfFile.Stat()
if err != nil {
t.Fatal(err)
}
if stat.Size() < 100 {
t.Errorf("generated PDF is size under 100 bytes")
}
}
When opening this PDF, I see the page number in the footer (page 1).
Can you try the same? If it does not work for you, it might be your wkhtmltopdf version, or something in your HTML template.
You could also try to add a web page, for example page := NewPage("https://www.google.com")
and see if that includes the footer, if it does, there is a problem in your template.
I have tested this on wkhtmltopdf versions 0.12.4 and 0.12.5.
If everything else fails, try from a console to call wkhtmltopdf directly with parameters --footer-right [page] --footer-font-size 10
, but, because I cannot reproduce, I don't think it is an issue in my library.
from go-wkhtmltopdf.
Sorry for the late update but it doesn't seems to work. Footer does not appear even with a simple :
page := NewPage("https://www.google.com")
page.FooterRight.Set("[page]")
page.FooterFontSize.Set(10)
from go-wkhtmltopdf.
I have the same issue with wkhtmltopdf 0.12.5
from go-wkhtmltopdf.
I have added this test which installs wkhtmltopdf 0.12.5 and then produces this PDF which prints the footer as expected.
The same happens on my Windows 10 machine with 0.12.5 and 0.12.4
So any issue you are facing is most likely not in this package, but probably a wkhtmltopdf issue.
@grmat Can you run the same test and post the output?
from go-wkhtmltopdf.
Thanks for your response.
I've just ran the test and this is the result:
So yes, the problem seems to be unrelated to this project. It was the first place to look and had an issue open already. Sorry for the noise!
from go-wkhtmltopdf.
Thanks for testing anyway, it is an interesting problem, best to report it at https://github.com/wkhtmltopdf/wkhtmltopdf and include your OS version.
from go-wkhtmltopdf.
I have the same problem on Arch Linux with wkhtmltopdf 0.12.5. Did anyone create an upstream bug report?
from go-wkhtmltopdf.
I tried running wkhmltopdf directly from the terminal with a footer option and got an error message The switch --footer-right, is not support using unpatched qt, and will be ignored.
.
After replacing the official Arch Linux wkhtmlpdftopdf package with wkhtmltopdf-static it works as it should.
from go-wkhtmltopdf.
Good info, thanks a lot. Never used that version of wkhtmltopdf.
from go-wkhtmltopdf.
Related Issues (20)
- Identify Blank PDF generated by go-wkhtmltopdf HOT 1
- Warning: Blocked access to file C:/Users/Administrator/.... HOT 2
- ResetPages() does not clear buffers HOT 5
- undefined: exec.ErrDot HOT 2
- Can't create Docker build HOT 1
- Margin setting support mm HOT 2
- "built against an unpatched version of QT" with active TOC HOT 3
- emoji not support HOT 1
- Go get not working for v1.9.0 Feb 11, 2023 HOT 13
- GetPath function return nothing.
- SetPath permission denied HOT 1
- CSS Display flex don't work. HOT 1
- do not support convert SPA to pdf
- How to set footer styles HOT 1
- Error failed to load... network status 301 HOT 8
- Second page of pdf don't display any content HOT 1
- PDF has blank pages from second page onwards HOT 4
- Create() returning not nil error on valid html HOT 12
- 用了该库后,需要在哪释放资源,会吃内存吗? HOT 1
- wkhtmltopdf not found HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-wkhtmltopdf.