wkhtmltopdf - Aligning logo to bottom without using a footer
Asked Answered
W

3

10

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.

Wheelbarrow answered 7/7, 2015 at 10:19 Comment(3)
Have you checked #9135609?Kathe
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.Wheelbarrow
You can suppress footers on all but the first page to achieve what you want.Aggrandize
A
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%;
}
Awakening answered 29/8, 2017 at 10:38 Comment(1)
It puts the element at the bottom of the document, not the bottom of the first page.Riana
P
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.

Pope answered 22/1, 2020 at 23:12 Comment(0)
B
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%;
}
Bennett answered 8/1, 2021 at 9:59 Comment(2)
I want to logo at the bottom of the last page how we do that can you please help meFerbam
Checkout this post on SO: #9135609Bennett

© 2022 - 2024 — McMap. All rights reserved.