position:absolute; bottom:0 in PDF

16 views
Skip to first unread message

Рубен Гичунц

unread,
Aug 27, 2025, 11:46:19 AMAug 27
to Flying Saucer Users
Привет всем!

Заметил, что конец body не приравнивается к концу страницы. Как мне создать div внизу последней страницы? Спасибо

---

Hi all!

I noticed that the end of the body is not equal to the end of the page. How do I create a div at the bottom of the last page? Thanks

---

example

<!DOCTYPE html>

<html lang="ru">

<head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>test</title>

 </head>

<body>

    <div>text</div>

     <div style="position:absolute; bottom:0">bottom text</div>

</body>

</html>

 

expected pdf (ctrl+p in browser)


 

flying saucer html to pdf


Andrei Solntsev

unread,
Aug 27, 2025, 12:45:21 PMAug 27
to flying-sa...@googlegroups.com
You need to use @page and "footer":
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">

<head>
<style>
@page {
size: A4;
@top-left {
content: element(header);
}
@bottom-left {
content: element(footer);
}
}

#header {
position: running(header);
}

#footer {
position: running(footer);
}
</style>
<title></title>
</head>

<body>
<div id="header">Header</div>
<div id="body">Body</div>
<div id="footer">Footer</div>
</body>

</html>

See for example https://github.com/flyingsaucerproject/flyingsaucer/blob/main/flying-saucer-pdf/src/test/resources/page-with-header.html


Andrei Solntsev


--
You received this message because you are subscribed to the Google Groups "Flying Saucer Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flying-saucer-u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/flying-saucer-users/97ec34f7-2685-4cb0-852f-a4fbf228ee21n%40googlegroups.com.
Message has been deleted

Рубен Гичунц

unread,
Aug 29, 2025, 11:19:45 AMAug 29
to Flying Saucer Users
Hi!

I don't need a footer on all sheets. Only on the last one.

As far as I know, you can define the first page (@page :first ), but not the last one.

That's why I wanted to do something via absolute position

среда, 27 августа 2025 г. в 19:45:21 UTC+3, andrei....@gmail.com:
Reply all
Reply to author
Forward
0 new messages