by Anonymous » 17 Feb 2025, 07:50
Ich muss ein PDF mit Kopfzeile, Fußzeile und Hintergrundfarbe erstellen. Der folgende Code generiert alle 3, aber es scheint
Code: Select all
from fpdf import FPDF
class PDF(FPDF):
def header(self):
self.set_font(family='Helvetica', size=8)
self.cell(0, 10, 'test_header', align='L')
def footer(self):
self.set_y(-15)
self.set_font(family='Helvetica', size=8)
self.cell(0, 10, 'test_footer', align='L')
pdf = PDF()
pdf.add_page()
pdf.set_font("Times", size=12)
# BG
pdf.set_fill_color(r=249, g=247, b=242)
pdf.rect(h=pdf.h, w=pdf.w, x=0, y=0, style="F")```
With the above only footer is visible but without it, both are visible.
How can I achieve the desired outcome?
Ich muss ein PDF mit Kopfzeile, Fußzeile und Hintergrundfarbe erstellen. Der folgende Code generiert alle 3, aber es scheint[code]from fpdf import FPDF
class PDF(FPDF):
def header(self):
self.set_font(family='Helvetica', size=8)
self.cell(0, 10, 'test_header', align='L')
def footer(self):
self.set_y(-15)
self.set_font(family='Helvetica', size=8)
self.cell(0, 10, 'test_footer', align='L')
pdf = PDF()
pdf.add_page()
pdf.set_font("Times", size=12)
# BG
pdf.set_fill_color(r=249, g=247, b=242)
pdf.rect(h=pdf.h, w=pdf.w, x=0, y=0, style="F")```
With the above only footer is visible but without it, both are visible.
How can I achieve the desired outcome?
[/code]