9

I want to add a logo at the bottom of the very first page. Ideally I'd position:absolute it bottom:0 - but anything positioned to the bottom in wkhtmltopdf doesn't seem to work.

This is a problem because the logo is dynamic and could have different heights depending on the aspect-ratio of the uploaded image.

I see that I can add a footer, but this adds it to all pages, and I only want this on one page.

What are my options? Do I have to position-absolute it from the top? If so, what if the page size changes? This needs to work in A4 and US Letter.

3
  • Have you checked stackoverflow.com/questions/9135109/…?
    – connexo
    Jul 7, 2015 at 10:26
  • Thanks but the solution discussed adds a footer (using --footer-html) but this solution isn't good for me because I want something aligned to the bottom of the 1st page only.
    – David Ball
    Jul 8, 2015 at 9:22
  • You can suppress footers on all but the first page to achieve what you want.
    – ashkulz
    Jul 13, 2015 at 10:35

3 Answers 3

6

I was having the same issue and solved by actually adding a width to the element. So, for the element I want to stick to the bottom I have this css:

.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
}
1
  • 2
    It puts the element at the bottom of the document, not the bottom of the first page.
    – krzaq
    Jun 27, 2020 at 16:33
3

This didn't work for me. (using python's pdfkit)

I had a one page document and I wanted a footer. I had to set the height of the page to be the height of a sheet of paper (<body style="height: 297mm">) and then absolute position worked correctly.

1

Had the same issue, used the answer of Carlo but changed it to use the top margin since it is using the document margins. This way the element was always on the bottom of the first page.

.footer {
      position: absolute;
      top: 700px;
      width: 100%;
}
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.