Java iText飞碟如何更改最后一页的背景

Java iText飞碟如何更改最后一页的背景,java,pdf,pdf-generation,itext,flying-saucer,Java,Pdf,Pdf Generation,Itext,Flying Saucer,我有一份具体的文件。背景第一页和最后一页与文档的其他页面不同 根据这里回答的问题: 我使用技巧定义的第一页@page:first: @page{ background-image: url('... my regular background ...'); } @page :first { background-image: url('... first page background ... '); } 如何更改最后一页的背景?如果您事先知道最后一页

我有一份具体的文件。背景第一页和最后一页与文档的其他页面不同

根据这里回答的问题:

我使用技巧定义的第一页
@page:first

@page{      
    background-image: url('... my regular background ...');
}
@page :first {      
    background-image: url('... first page background ... ');
}

如何更改最后一页的背景?

如果您事先知道最后一页将显示什么,可以使用

下面是一个简单的例子:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <style type="text/css">
    .newpage{page-break-before:always}

    @page {@bottom-center {content: element(footer)}}
    #footer {position: running(footer);}

    @page last {@bottom-center {content: element(lastfooter)}}
    #lastfooter{position: running(lastfooter);}
    #lastpage  {page:last}
}
 </style>
</head>
    <body>  
        <div id="footer">Footer page 1 and 2</div>
        <div id="lastfooter">Footer for last page</div>

        <div>Page 1 content</div>
        <div class="newpage">Page 2 content</div>
        <div id="lastpage">Page 3 content</div>
    </body>
</html>

.newpage{之前的分页符:始终}
@页面{@底部中间{内容:元素(页脚)}
#页脚{位置:运行(页脚);}
@最后一页{@bottomcenter{content:element(lastfooter)}
#lastfooter{位置:正在运行(lastfooter);}
#最后一页{page:last}
}
页脚第1页和第2页
最后一页的页脚
第1页内容
第2页内容
第3页内容

谢谢。工作起来很有魅力。多亏了文档链接,我应该提高我的css3技能。