Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wkhtmltopdf - Aligning logo to bottom without using a footer

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.

like image 656
David Ball Avatar asked Jul 07 '15 10:07

David Ball


3 Answers

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%;
}
like image 62
Carlo Avatar answered Oct 23 '22 22:10

Carlo


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.

like image 33
Ben Page Avatar answered Oct 23 '22 20:10

Ben Page


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%;
}
like image 24
Cas Wolters Avatar answered Oct 23 '22 20:10

Cas Wolters