Hi!
\n\n\nThe issue I have been having is that it doesn't create the watermark on the last page of each section.
\n
I can't readily say why this happens, but rinohtype already provides a simpler way to set background images for pages. In your template configuration file, you can set the background property on a page template:
\n[contents_page]\nbackground = 'contents_background.pdf', scale=fit
If you do want to lose the configurability of the watermark (document_status
), try setting the container type to BACKGROUND
instead to see whether that solves your issue.
P.S. I see you're using a PNG image for the background. You should use vector images where appropriate to improve print quality (and reduce file size).
","upvoteCount":1,"url":"https://github.com/brechtm/rinohtype/discussions/394#discussioncomment-4795182"}}}-
Hi, I am attempting to build some pdf documents with a draft watermark. I have added the draft watermark by adding a semi-transparent image with no background layered over every page so the text can be read from under the image. The issue I have been having is that it doesn't create the watermark on the last page of each section. If anyone has any ideas why this might be happening, please let me know? This is the code that creates the watermark: class ContentPageTemplate(BodyPageTemplate):
def __init__(self, *args, **attributes):
super().__init__(*args, **attributes)`
def page(self, document_part, page_number, chain, **kwargs):
return ContentPage(document_part, self, page_number, chain, **kwargs)
class ContentPage(BodyPage):
def __init__(self, document_part, template, page_number, chain):
super().__init__(document_part, template, page_number, chain)
metadata = self.document.metadata
document_status = metadata[DOCUMENT_STATUS]
if document_status.lower() == "draft":
self.watermark_area = DownExpandingContainer("watermark_area", CONTENT, self)
draft_water = Image(path_to("images/DRAFT_MARK.png"), width=21 * CM, height=29.70 * CM, style="Draft watermark")
self.watermark_area << draft_water |
Beta Was this translation helpful? Give feedback.
-
Hi!
I can't readily say why this happens, but rinohtype already provides a simpler way to set background images for pages. In your template configuration file, you can set the background property on a page template: [contents_page]
background = 'contents_background.pdf', scale=fit If you do want to lose the configurability of the watermark ( P.S. I see you're using a PNG image for the background. You should use vector images where appropriate to improve print quality (and reduce file size). |
Beta Was this translation helpful? Give feedback.
Hi!
I can't readily say why this happens, but rinohtype already provides a simpler way to set background images for pages. In your template configuration file, you can set the background property on a page template:
If you do want to lose the configurability of the watermark (
document_status
), try setting the container type toBACKGROUND
instead to see whether that solves your issue.P.S. I see you're using a PNG image for the background. You should use vector images where appropriate to improve print quality (and reduce…