Flying Saucer: Always having first blank page when setting background-image

48 views Asked by At

I want to have a pdf with a background image on a fix number of pages (2 in the example, the 3 page should not have it). I got this working with the following template:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <style>
        @page background-image {
            background-image: url("img/a4_wallpapper.png");
            background-size: cover;
        }

        .wallpaper {
            page: background-image;
        }

        .page-break-before {
            page-break-before: always
        }

        .page-break-after {
            page-break-after: always;
        }

    </style>
</head>
<body>
<div class="wallpaper">
    <h1>First Page</h1>
</div>
<div class="wallpaper page-break-before">
    <h1>Second Page</h1>
</div>
<div class="page-break-before">
    <h1>Third Page</h1>
</div>
</body>
</html>

The result ist this:

enter image description here

So the problem is, why is flying saucer adding the blank first page? And how can i get it without it?

0

There are 0 answers