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.

David Ball
  • 553
  • 9
  • 19
  • Have you checked http://stackoverflow.com/questions/9135109/wkhtmltopdf-add-content-to-the-bottom-of-the-last-page?rq=1? – connexo Jul 07 '15 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 08 '15 at 09:22
  • You can suppress footers on all but the first page to achieve what you want. – ashkulz Jul 13 '15 at 10:35

3 Answers3

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%;
}
Carlo
  • 4,016
  • 7
  • 44
  • 65
  • 2
    It puts the element at the bottom of the _document_, not the bottom of the _first page_. – krzaq Jun 27 '20 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.

Ben Page
  • 3,011
  • 4
  • 35
  • 37
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%;
}
Cas Wolters
  • 371
  • 3
  • 11