Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page header and Page content overlapped but not footer. #177

Open
prdpspkt opened this issue Nov 15, 2020 · 4 comments
Open

Page header and Page content overlapped but not footer. #177

prdpspkt opened this issue Nov 15, 2020 · 4 comments

Comments

@prdpspkt
Copy link

prdpspkt commented Nov 15, 2020

In my generated pdf page header template (not table header) is overlapped with content added in page. . What might be the problem ?

@gijsriet
Copy link

I have the same issue. Did you find a solution?

@gijsriet
Copy link

gijsriet commented Dec 23, 2020

What fixed it for me was creating a container in the header template's body with the height set to the same value as margin-top).

<body>
	<div style="height: {{template.header_height}}pt;">
        </div>
</body>

@prdpspkt
Copy link
Author

from wkhtmltopdf.views import PDFTemplateResponse
class Pdf():
    def __init__(self, request, template, context):
        self.request = request
        self.template = template
        self.margin_top = 45
        self.margin_left = self.margin_bottom = self.margin_right = 10
        self.show_content_in_browser = True
        self.context = context
        self.filename = 'new_file.pdf'
        self.header = 'print/header.html'
        self.footer = 'print/footer.html'


    def response(self):
        return PDFTemplateResponse(request=self.request,
                                   template=self.template,
                                   filename=self.filename,
                                   context=self.context,
                                   show_content_in_browser=self.show_content_in_browser,
                                   header_template=self.header,
                                   footer_template=self.footer,
                                   cmd_options={
                                       'header-spacing': 40,
                                       'margin-top': self.margin_top,
                                       'margin-left': self.margin_left,
                                       'margin-right': self.margin_right,
                                       'margin-bottom': self.margin_bottom
                                   }
                                   )

@prdpspkt
Copy link
Author

Header spacing and margin top

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants