wkhtmltopdf repeatitive background image on all pages

被刻印的时光 ゝ 提交于 2019-12-04 19:29:12
Herr Nentu'

I managed to "solve" the problem.

Based on this question Why doesn't wkhtmltopdf page-break-after have any effect? I actually forced the page to manually break after a fixed point and create a new page with the same background.

OK, it's a "hackish" way but it did the job...

now my code looks like this

CSS

.main_container{
    background: url({{ resourceDir ~ 'img/certificate_margin.jpg' }}) 0 0;
    padding-top:15px;
    padding-left:5px;
    z-index: 99;
    background-size: cover;
    width:652px;
    height:975px;
    position:relative;
 }
.break{
        display: block;
        clear: both;
        page-break-after: always;
}

And the twig

...
<body>
<div class="main_container break" style='position:relative'>

    first page content 

    {% block body %}

    {% endblock %}

    {% include 'BlablaBundle:Pdf:_partial_certificate/_footer_contact.html.twig' with {'page': 'Seite 1/2'} %}
</div>

<div class="main_container" style='position:relative'>

    second page content

        {% include 'BlablaBundle:Pdf:_partial_certificate/_footer_contact.html.twig' with {'page': 'Seite 2/2'} %}
</div>
</body>
...

After thinking about this problem, I recommend just delegating out to something like pdftk and use the same logic for watermarks for a recurring background image.

https://www.pdflabs.com/docs/pdftk-man-page/#dest-op-multistamp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!