Giter Site home page Giter Site logo

Comments (9)

SebastiaanKlippert avatar SebastiaanKlippert commented on May 12, 2024

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.

flrnt avatar flrnt commented on May 12, 2024

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.

grmat avatar grmat commented on May 12, 2024

I have the same issue with wkhtmltopdf 0.12.5

from go-wkhtmltopdf.

SebastiaanKlippert avatar SebastiaanKlippert commented on May 12, 2024

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.

grmat avatar grmat commented on May 12, 2024

Thanks for your response.

I've just ran the test and this is the result:

TestSetFooter.pdf

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.

SebastiaanKlippert avatar SebastiaanKlippert commented on May 12, 2024

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.

Limero avatar Limero commented on May 12, 2024

I have the same problem on Arch Linux with wkhtmltopdf 0.12.5. Did anyone create an upstream bug report?

from go-wkhtmltopdf.

Limero avatar Limero commented on May 12, 2024

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.

SebastiaanKlippert avatar SebastiaanKlippert commented on May 12, 2024

Good info, thanks a lot. Never used that version of wkhtmltopdf.

from go-wkhtmltopdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.