Add footer with xhtml2pdf on specific pages with Django

Asked

Viewed 143 times

0

I have a standard footer that is displayed on some pages when generating the PDF with the xhtml2pdf using Django which should be positioned at the bottom of the page. But in some I don’t want to display. With the current code I can position at the bottom of the page. However, when it is applied to all of them. How do I position the footer at the bottom of the page and not apply at all when generating the PDF?

xhtm2pdf style:

 @page {
    size: a4 portrait;
    @frame content_frame {
        left: 25pt; width: 550pt; top: 10pt; height: 850pt;
    }
    @frame footer_frame {
        -pdf-frame-content: footer_content;
        left: 50pt; width: 512pt; top: 750pt; height: 200pt;
    }
}

Footer:

<div id="footer_content">
<hr>
<p align="center">
    www.site.com.br <br/>

</p>

1 answer

0

If I understand, what you want to do is insert a specific footer in the pages that can be reentered as PDF, correct?

If that’s right, you can use {% include %} and {% if %} within the templates of Django. With these two template tags and context variables that are passed from view to the template, you can validate a condition and include the footer dynamically in the pages that must have the same.

If that’s not what you want you can try to edit the question, including more code examples, or even try to explain in a more direct way so that maybe the community can reproduce.

I hope I’ve helped!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.